Emacs: good (and how to create a foreign characters menu)

Foreign to me, at least.

I never tried to proselytize Emacs. Many times, when I saw someone using Windows Notepad, I told them "there are so many better, free alternatives out there, like Notepad++". These people inevitably responded by asking me if I used Notepad++, to which I replied "Well, you don't want to know what I use. It's a geek editor."

I thought that Emacs' learning curve would be too steep for most people, because although it's highly configurable and adaptable, it won't adapt too well to the typical Windows user's expectation that Ctrl+X means "cut" and Ctrl+C means "copy". Ctrl+X and Ctrl+C each begin enough important keystroke combinations in Emacs that you're better off not redefining them, so you can never make Emacs too comfortable for Windows users.

A December blog posting by Derek Slager titled The Case for Emacs makes a good case for non-Emacs users to switch, at least if you're a programmer. (I really don't do that much coding, by the way, and spend most of my time using Emacs in nxml mode to write XML and XHTML. If I am coding, it's usually XSLT, so of course I'm using nxml for that as well.) One of Slager's key points is that when Emacs users learn a new programming language, they don't need to learn a new IDE, because their existing development environment probably already has a full-featured mode for that language with keystrokes consistent with what they know from editing code in other languages. This makes them productive in their new language faster. As he put it,

If you're an Emacs user, you can be writing C# on Windows Monday, Ruby on Mac OS Tuesday, and Python on Linux on Wednesday. In each case, there are language-specific tools to use, but the place you spend the most time—your editor—is consistent across tools and platforms. Virtually all the time you invested in learning (and customizing) the editor comes along for the ride each time. Emacs lowers the bar.
[emacs menu screenshot]

Emacs just had its first significant upgrade in over four years. I haven't had the time to look through the new features, but there's one improvement that was immediately apparent to me: the little menus I had added to insert commonly needed foreign characters had worked correctly before, but displayed a little oddly, and now they both work and display properly.

As the picture shows, my "non-ASCII" menu shows the vowels plus a few more common symbols. Picking a vowel displays a cascade menu of that vowel with different accents, and picking one of those inserts that character. I actually have mine inserting the numeric character references (for example, ä for ä) but it would be easy enough to modify the code to insert the actual characters.

(require 'easymenu)

(easy-menu-define 
 non-ASCII-menu global-map "non-ASCII"
 '("non-ASCII"
    ("a"
    ["à" insert-agrave]
    ["á" insert-aacute]
    ["â" insert-acirc]
    ["ã" insert-atilde]
    ["ä" insert-auml]
    )
    ("e"
    ["è" insert-egrave]
    ["é" insert-eacute]
    ["ê" insert-ecirc]
    ["ë" insert-euml]
    )
    ("i"
    ["ì" insert-igrave]
    ["í" insert-iacute]
    ["î" insert-icirc]
    ["ï" insert-iuml]
    )
    ("o"
    ["ò" insert-ograve]
    ["ó" insert-oacute]
    ["ô" insert-ocirc]
    ["õ" insert-otilde]
    ["ö" insert-ouml]
    )
    ("u"
    ["ù" insert-ugrave]
    ["ù" insert-uacute]
    ["û" insert-ucirc]
    ["ü" insert-uuml]
    )
    ["ntilde" insert-ntilde]
    ["euro" insert-euro]
   )
)

(easy-menu-add non-ASCII-menu)

(defun insert-ntilde () (interactive) (insert "ñ") )
(defun insert-euro () (interactive) (insert "€") )

(defun insert-agrave () (interactive) (insert "à") )
(defun insert-aacute () (interactive) (insert "á") )
(defun insert-acirc () (interactive) (insert "â") )
(defun insert-atilde () (interactive) (insert "ã") )
(defun insert-auml () (interactive) (insert "ä") )

(defun insert-egrave () (interactive) (insert "è") )
(defun insert-eacute () (interactive) (insert "é") )
(defun insert-ecirc () (interactive) (insert "ê") )
(defun insert-euml () (interactive) (insert "ë") )

(defun insert-igrave () (interactive) (insert "ì") )
(defun insert-iacute () (interactive) (insert "í") )
(defun insert-icirc () (interactive) (insert "î") )
(defun insert-iuml () (interactive) (insert "ï") )

(defun insert-ograve () (interactive) (insert "ò") )
(defun insert-oacute () (interactive) (insert "ó") )
(defun insert-ocirc () (interactive) (insert "ô") )
(defun insert-otilde () (interactive) (insert "õ") )
(defun insert-ouml () (interactive) (insert "ö") )

(defun insert-ugrave () (interactive) (insert "ù") )
(defun insert-uacute () (interactive) (insert "ú") )
(defun insert-ucirc () (interactive) (insert "û") )
(defun insert-uuml () (interactive) (insert "ü") )

I look forward to finding out what else is new in Emacs 22.1.1.

Something else nice for Emacs users: the weblog minor Emacs wizardry has lots of great tips. That's where I learned that putting your cursor after any parenthesized expression and pressing C-x C-e evaluates that expression. Just now I was wondering how much 18 tons of gravel would be for our driveway at $15 each, so I typed (* 18 15) into the window I happened to be in, entered that keystroke combination, and had my answer.