9

I have been a programmer for a decade now, but I believe this is the first time I've ever asked a question on a forum. I just can't figure this out and can't find the answer already online.

I am trying to turn on CUA mode so that emacs is more bearable for a windows user (normal copy paste functions). I am running Windows 7 and installed emacs through the Lisp In A Box package. I understand that I need to add a line to my .emacs file or init.el file. I'm not sure which, but I can't find either in my Lip In A Box install directory. The emacs package install also did not come with any tutorials or help files, so its really hard to pick this up.

I am stuck, any help is greatly appreciated!

  • if you don't have CUA, install it. Though, I would guess that a newer Emacs comes with it bundled. When Emacs starts up and it is not already loaded, you need to load it. Use (require 'cua) if it is in the Emacs load path. See http://www.emacswiki.org/CuaMode . Then turn it on. (cua-mode t) . You can also use the function (LOAD some-pathname) to load the file. – Rainer Joswig Feb 16 '10 at 14:29
  • @Rainer: LOAD should be lower-case according to the nitpicker's guide, so (load some-pathname). Also, (load-file some-pathname) is a somewhat less frightening variation. – Thomas Feb 16 '10 at 17:09
  • 'load' is a Lisp function. You can use it from init files. 'load-file' is not different, just that it is thought to be called as extended command. – Rainer Joswig Feb 16 '10 at 18:22

3 Answers3

5

The .emacs can be found by looking at the answers to this similar question.

Regarding documentation and tutorials, it looks like the link you provided for "Lisp in a Box" says:

If you are new to Emacs, it is recommended that you read the Emacs Tutorial which you can access from with Emacs by going to the Help menu, or by typing Control-h, letting go, and hitting t. A more extensive manual is also available from the Help menu, or on the web at http://www.gnu.org/software/emacs/manual/.

Which makes it sound like the manual is there, and certainly the tutorial (I made bold the directions to get to the tutorial).

As far as other places to get information, there is a collection of screencasts on the wiki.

Your question doesn't specify whether or not you what to add to your .emacs to activate CUA mode. You can check out the CUA mode documentation on the wiki (which has links to the manual). The minimal installation is just adding this to your .emacs: (cua-mode t).

Community
  • 1
  • 1
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
4

For GNU/Emacs, you can choose to use any one of the following three file names as the start-up configuration file:

${HOME}/.emacs
${HOME}/.emacs.el
${HOME}/.emacs.d/init.el

It would probably be a good idea to decide on one of the three options and then stick to it - the first one seems to be the most widely used one. In any case, ${HOME} stands for your home directory -- which is likely to be different from the Lisp In A Box install directory!

Coming from a Unix tradition, Emacs understands ~ (tilde) as an abbreviation for your home directory, so you can visit the .emacs file by typing:

C-x C-f ~/.emacs [ENTER]

(Note that the capital C is Emacs standard notation for a combination of the CTRL key and a second key, i.e. here you press CTRL-x CTRL-f which stands for "find-file" and will then ask you for a file name in the bottom part of the Frame (aka mini-buffer).)

If these are your first customizations, you will just see an empty buffer. Enter

;; start CUA mode every time Emacs starts
(cua-mode t)

and save the buffer with C-x C-s.

Next time you start Emacs, CUA mode should be turned on automatically.

Thomas
  • 17,016
  • 4
  • 46
  • 70
  • Thank you for your help, this is exactly what I was confused about! However, I'm still having a problem with CUA mode. It appears I don't have the library installed, so I've gone ahead and downloaded the package from http://www.cua.dk/cua.el. I placed it in several locations, including my root directory, but I see ".el" files scattered throughout the file structure? As instructed, I byte-compiled the cua.el file. But I'm still getting the error in my 'Message' buffer: An error has occurred while loading `c:/.emacs': Symbol's function definition is void: cua-mode – davetcoleman Feb 16 '10 at 13:58
  • As the cua.el file you downloaded states, you actually have to add two lines to .emacs (I've updated my original post accordingly). In order for emacs to find the cua.el file, you also have to adapt the load-path variable which you can do, e.g., with the command (add-to-list 'load-path "/path/to/dir/containing/cua.el") – Thomas Feb 16 '10 at 15:16
  • still no luck, even when adding that line. this windows programmer gives up. – davetcoleman Feb 17 '10 at 20:57
  • Don't give up so soon... Here, try this: type C-h C-v for the command "describe-variable" and then type "load-path" (without the quotes) at the prompt in the minibuffer. You'll get a (possibly) long list of path displayed in a new buffer. Is the path to the directory containing your cua.el file listed? – Thomas Feb 19 '10 at 15:02
  • Wait a minute... the Lisp-in-a-box website you linked states that it uses GNU Emacs 21.3 -- and that version has cua-mode already built in! That's good news, because you should be able to forget all that crap about load-path and so on. This should actually work : remove all the lines previously added to your .emacs file. Instead, add only one line: "(cua-mode t)" - without the quotes - save and restart Emacs. Important: note that the line is all lower-case. I have tried this with Emacs 22.1.1 (on Linux though) and it works fine for me. Crossing my fingers for you. – Thomas Feb 19 '10 at 15:14
1

What the others have told you is true: Simply adding (cua-mode t) to your dotfile would be sufficient. HOWEVER: Lisp in a box' Emacs doesn't load this file by default. Therefore, be sure to edit the shortcut so that it does load the dotfile. This is important, because otherwise you would get weird behavior, where you would add the correct line to the dotfile, start emacs, and then not get cua mode. That would suck.

The reason it does this is to ensure that it starts a vanilla emacs everytime, instead of finding, say C:/_emacs and loading that instead, giving you another user's customizations and confusing you.

The flag for not loading an init file is -q or --no-init-file. Also make sure that --no-site-file is not there.

(I realize that this is an old post, but I found this while looking for something related, and I don't want people walking away frustrated over something that doesn't work.)