Friday, July 16, 2010

A Foray into Emacs

I spent a day learning emacs.

Remapping CapsLock

One of the first things that I did was remap CapsLock as another Control button (in Gnome, so this applies system wide):

System -> Preferences -> Keyboard -> Layouts Tab -> Options -> Ctrl key position -> Make CapsLock an additional Ctrl

The only problem is that I keep hitting CapsLock instead of shift and accidentally starting commands. It's definitely a relief on the pinky though.


I went through the tutorial and proceeded to edit ~/.emacs for 6 hours (learning lisp in the process too).

  1. Change the default font-size to 10pt (height is in units of 1/10pt):
    (set-face-attribute 'default nil :height 100)
  2. Change the vertical scroll bars to the right side:
    (set-scroll-bar-mode 'right)
  3. Hide the top scroll bar:
    (tool-bar-mode -1) ;; hide top tool-bar
  4. Remap Alt+Tab to Ctrl+Tab (this does completion in a lot of modes):
    ;; remap alt-tab to control-tab
    (define-key function-key-map [(control tab)] [?\M-\t])
  5. Copying/Pasting from other applications - I used the shortcuts from gnome-terminal:
    • Ctrl+Shift+x to cut (clipboard-kill-region)
    • Ctrl+Shift+c to copy (clipboard-kill-ring-save)
    • Ctrl+Shift+v to paste (clipboard-yank)
    • Disable immediate copy into the kill ring with the mouse: (setq mouse-drag-copy-region nil)
    ;; stops mouse selection from copying immediately
    (setq mouse-drag-copy-region nil)
    (global-set-key [(control shift x)] 'clipboard-kill-region)
    (global-set-key [(control shift c)] 'clipboard-kill-ring-save)
    (global-set-key [(control shift v)] 'clipboard-yank)
  6. Open the bookmarks list on startup, unless we're opening a file explicitly:
    (setq bookmark-save-flag 1) ;; save every new bookmark
    ;; show bookmarks at start-up
    (when (= 1 (length command-line-args))
      (setq inhibit-startup-screen 1)
      (add-hook 'emacs-startup-hook 
         '(lambda ()
            (switch-to-buffer "*Bookmark List*"))))

Here's my .emacs:

(tip: keep your configuration files in your Dropbox and link to them from your home folder)

No comments:

Post a Comment