Ambieditrous

When you screw up your .emacs file, there is something delightfully perverted in having to type

vim ~/.emacs

in order to set things straight... :-)

:: Comments (3)

Learning Emacs, part 2.5

Just read this post: Switching editors is just as hard as switching languages. Fortunately my experiences with Emacs have been somewhat different. I was not looking forward to the steep learning curve, but to my surprise it only took a few days to get up to working speed. I've probably only scratched the surface of what's possible, but I can use it without much problem for everyday Scheme hacking... and that was my intention.

To summarize it, here's what helped me:

  • Read a decent book (as I mentioned before, I chose Learning GNU Emacs)
  • Remap keys to something more familiar, if you don't want to use the funky C-this C-that combos for common actions; e.g. I use ⌘O to open a file, rather than C-x C-f; etc.
  • Study other people's .emacs files. There's a ton of them online. For example, here.
  • Take advantage of Emacs' introspective features, like C-h k and C-h f, to quickly see what a key combination or function does.

Right now, the only thing that really bugs me is that Emacs still likes to recenter the screen every now and then, for no apparent reason... that drives me up the wall. A "feature" like that should not be enabled by default. But aside from that, I think it's kind of an OK editor. ;-)

:: Comments (4)

Learning Emacs, part 2

More things I learned, after scraping together bits and pieces from all over the net:

  • Write a function that deletes the whole line, and bind it to a key (for some reason Emacs doesn't have this out of the box):
    (defun delete-line ()
      "Kill the whole damn line."
      (interactive)
      (beginning-of-line)
      (kill-line 1)) ; delete line including newline 
    
    (global-set-key [(super y)] 'delete-line)
  • Resize the window so the minibuffer no longer hides behind the dock:
    (add-to-list 'default-frame-alist '(height . 39))
  • When you scroll beyond the beginning or the end of the screen, Emacs has the annoying "feature" of re-centering the cursor. This turns it off (most of the time):
    (setq-default scroll-step 2)
  • Extend the Emacs load path so I can stick custom .el files in this directory and have them recognized by (require 'foobar):
    (add-to-list 'load-path "/Users/name/projects/scripts/macosx/emacs")
  • Match parentheses automatically, always, not just when inserting them:
    (show-paren-mode)
  • Turn off the sound:
    (setq visible-bell t)
  • Turn off cursor blinking:
    (blink-cursor-mode nil)
  • When marking, always show the highlighted region:
    (transient-mark-mode t)
  • Show current column:
    (column-number-mode t)
  • Don't use tabs for intending:
    (setq-default indent-tabs-mode nil)

I also added Quack to my .emacs file; let's see how well it does when hacking Scheme.

Emacs more or less does what I want now. There are still a few things missing (like the ability to select things by moving the cursor while pressing Shift), but they're not so important.

All in all, that wasn't so bad. I expected it to take more time to get things up and running. Granted, I've looked at Emacs before (although I never really got around to using it), so I'm not *completely* new to it. The Learning GNU Emacs book was (and still is) a great help too; I found it much more useful than the built-in tutorial.

(Assuming I stay with Emacs, I will need to unlearn some vi-isms. I find myself pressing Esc a lot, or typing things like "i" or "dd". :-)

:: Comments (3)

Learning Emacs, part 1

A few things I've learned since part 0:

  • Carbon Emacs does support Mac-style keybindings like ⌘Q, they just need to be activated. See Help -> Carbon Emacs Package -> Mac-Style Key Bindings.
  • I am now mapping Meta to Alt, as suggested (and demonstrated) in this comment. (Thanks Ozzi.)
  • I can set the Mac font using (set-default-font "-apple-monaco-medium-r-normal--13-140-72-72-m-140-mac-roman"). ^_^ Getting a list of available fonts is done using M-x set-default-font RET TAB TAB.
  • Good luck trying to look for ".emacs" in Google or any other search engine. Fortunately there's such a thing as the dotemacs site, which offers a ton of example .emacs files.

Open issues:

  • I'm still trying to figure out how to resize the window automatically. Right now, when Emacs opens, the window is a little too big, and the bottom hides behind the dock.
    Update: Solved with (add-to-list 'default-frame-alist '(height . 39)).
  • I'm still debating whether I should use the semi-default Mac-style key bindings, or define my own. I like ⌘O to map to C-x C-f, for example, but Carbon Emacs shows a dialog box. It appears I can either use the predefined key bindings, *or* map Super to ⌘ and define its key bindings myself, but not both.
  • I would like to select text by moving around with the cursor while pressing Shift... not sure if that can be done in Emacs.

:: Comments (1)

Learning Emacs, part 0

I am probably going to try and learn Emacs... or at least enough of it that I can use it for everyday Scheme editing. Learning GNU Emacs seems like a good start. The problem is more, finding a version for Mac OS X that does what I want (like recognizing my custom keybindings for Home/End, for example). Carbon Emacs seems to do at least that, unlike some other versions that I've found. (It has other issues though, like not recognizing common Apple key bindings like ⌘Q.) More about this later. In the meantime, I'm still using vim. :-)

(Unrelated: I just realized that "the problem is more" is probably a Dutch-ism... but I'll keep using it anyway. :-)

:: Comments (6)