Switching from XEmacs to Emacs
My first editor in the *nix world was Emacs. When I started university, some friend showed me how to get started. I have never really become a power user with it, but it is the tool I use for random small editing tasks. At some point in time when I started using Linux on desktop more often I put some effort into making Emacs work well with my habits, and in the process I actually settled on XEmacs. At the time I believe it was more advanced than Emacs, more defaults worked out of the box, and the GUI actually had a button for copying text. This was important since I could never remember how to do that from the keyboard (I could only remember how to cut).
It is now 2009, and I think Emacs has long since eclipsed XEmacs in features etc. At least on Ubuntu, Emacs also comes with the important copy toolbar button
. Besides, when I log in to remote systems they will almost certainly have Emacs but not XEmacs, meaning I can’t just upload my XEmacs customizations file and expect things to work. So I decided to see if I could make Emacs work at least as well as my XEmacs does.
Most of the settings were trivial; just copy to .emacs. Keyboard customization uses slightly different syntax in Emacs, but it was an easy conversion. The problematic things were font size and clipboard functionality. I wanted a bigger font size, and the best solution I found was to set the font face height explicitly (actual value will depend on your resolution and your likes), but the following gives me a nice 80×63 Emacs window that will use half horizontal and 100% vertical space:
;; With my resolution, dpi and fonts this let's me display 80x63 geometry (set-face-attribute 'default nil :height 100)
The XEmacs clipboard worked out of the box with my X and Gnome settings, but Emacs needed some tweaks:
;; Make copy and paste work with other applications (global-set-key [\C-z] 'undo) (global-set-key [\C-x] 'clipboard-kill-region) (global-set-key [\C-c] 'clipboard-kill-ring-save) (global-set-key [\C-v] 'clipboard-yank) (setq x-select-enable-primary nil) ; stops killing/yanking interacting with primary X11 selection (setq x-select-enable-clipboard t) ; makes killing/yanking interact with clipboard X11 selection
Incidentally, with those settings I have no problems with copying and pasting text since the key combinations are the same as in any other program I use. So I could even take out the toolbar, since I only needed it for copying.
Since I do most of my programming in Eclipse, I also wanted matching comment/uncomment region settings:
;; Comment/uncomment reqion similar to Eclipse: C-/ and C-? (control shift /) (global-set-key [(control /)] 'comment-region) (global-set-key [(control \?)] 'uncomment-region)
Probably my nicest customization (although not written by me) is to be able to cycle between buffers with Ctrl-tab and Ctrl-Shift-tab. They are kind of long, so see the links below.
I think I found the answers to most of my problems on EmacsWiki.
I have always found other people’s (X)Emacs customization files fascinating reads, so if you are like me, here you go: .emacs and .xemacs/custom.el.
Update: As was pointed out in the comments, binding C-x etc. breaks havoc with many Emacs bindings. However, I did this only after I was unable to get CUA mode to work properly (namely, copy and paste did not work between Emacs and other applications). But I gave it one more try, and it seems like adding these things to .emacs does indeed make copy and paste work like I want:
(cua-mode t) (transient-mark-mode 1) ;; No region when it is not highlighted (setq cua-keep-region-after-copy t) ;; Standard Windows behaviour
Of course, remove the lines that bound C-z, C-x, C-c and C-v (since CUA mode does that).


