Tastaturbelegung
Die standardmässig eingestellte Tastaturbelegung des emacs ist nur bedingt empfehlenswert. Bevor man mit dem emacs arbeitet, ist es daher sinnvoll, sich die Tastaturkürzel für die gebräuchlichsten Funktionen umzudefinieren.
Der Emacs ist voll konfigurier- und programmierbar, da er vollständig in der Interpretersprache Lisp geschrieben ist. Man konfiguriert den emacs also, in dem man ihn umprogrammiert. Den entsprechenden Lisp Code speichert man in der Datei “~/.emacs” im Home-Verzeichnis. Diese Datei wird automatisch bei jedem Start geladen.
Eine in der Praxis erprobte Voreinstellung und Tastaturbelegung ist die folgende:
(require 'tabify)
(require 'dabbrev)
(require 'find-file)
(require 'font-lock)
(setq scroll-step 1)
(setq visible-bell t)
(transient-mark-mode 1)
(setq search-highlight t)
(setq paren-sexp-mode nil)
(setq mouse-yank-at-point t)
(setq next-line-add-newlines nil)
(setq dabbrev-case-fold-search nil)
(setq highlight-nonselected-windows nil)
(set-default 'truncate-lines t)
(setq auto-save-timeout 300)
(setq auto-save-interval 100)
(setq require-final-newline t)
(setq tab-width 8)
(setq c-basic-offset 3)
(setq c-tab-always-indent t)
(setq indent-tabs-mode nil)
(global-set-key "\M-z" 'undo)
(global-set-key "\C-l" 'recenter)
(global-set-key "\C-z" 'iconify-frame)
(global-set-key "\M-c" 'point-to-register)
(global-set-key "\M-g" 'jump-to-register)
(global-set-key "\M-l" 'goto-line)
(global-set-key "\C-s" 'isearch-forward)
(global-set-key "\M-s" 'isearch-forward-regexp)
(global-set-key "\C-r" 'query-replace)
(global-set-key "\M-r" 'query-replace-regexp)
(global-set-key "\M-d" 'downcase-word)
(global-set-key "\M-u" 'upcase-word)
(global-set-key "\C-t" 'transpose-chars)
(global-set-key "\M-t" 'transpose-lines)
(global-set-key "\M-k" 'kill-line)
(global-set-key "\M-." 'set-mark-command)
(global-set-key "\M-w" 'kill-region)
(global-set-key "\M-y" 'yank)
(global-set-key "\M-i" 'quoted-insert)
(global-set-key "\M-o" 'overwrite-mode)
(global-set-key "\M-p" 'fill-paragraph)
(global-set-key "\M-," 'ESC-prefix)
(global-set-key "\M-[" 'start-kbd-macro)
(global-set-key "\M-]" 'end-kbd-macro)
(global-set-key "\M-x" 'call-last-kbd-macro)
(global-set-key "\C-g" 'keyboard-quit)
(global-set-key [delete] 'delete-char)
(global-set-key [C-delete] 'kill-word)
(global-set-key [C-backspace] 'backward-kill-word)
(global-set-key [M-delete] 'fixup-whitespace)
(global-set-key [M-backspace] 'delete-horizontal-space)
(global-set-key [insert] 'overwrite-mode)
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
(global-set-key [S-left] 'beginning-of-line)
(global-set-key [S-right] 'end-of-line)
(global-set-key [C-left] 'backward-word)
(global-set-key [C-right] 'forward-word)
(global-set-key [M-left] 'beginning-of-buffer)
(global-set-key [M-right] 'end-of-buffer)
(global-set-key [M-up] 'scroll-down)
(global-set-key [M-down] 'scroll-up)
(global-set-key [C-tab] 'dabbrev-expand)
(global-set-key [M-tab] 'dabbrev-expand)
(global-set-key "\M-\C-l" 'find-file)
(global-set-key "\M-\C-i" 'insert-file)
(global-set-key "\M-\C-s" 'save-buffer)
(global-set-key "\M-\C-r" 'revert-buffer)
(global-set-key "\M-\C-k" 'kill-this-buffer)
(global-set-key "\M-\C-e" 'switch-to-buffer)
(global-set-key "\M-\C-q" 'server-edit)
(global-set-key "\M-\C-t" 'tabify)
(global-set-key "\M-\C-u" 'untabify)
(global-set-key "\M-\C-c" 'compile)
(global-set-key "\M-\C-o" 'other-window)
(global-set-key "\M-\C-d" 'delete-other-windows)
(global-set-key "\M-\C-[" 'split-window-vertically)
(global-set-key "\M-\C-]" 'split-window-horizontally)
(global-set-key "\M-\C-j" 'eval-print-last-sexp)
(global-set-key "\M-\C-x" 'execute-extended-command)
(global-set-key "\M-\C-z" 'save-buffers-kill-emacs)
(global-set-key [M-C-left] 'ff-find-other-file)
(global-set-key [M-C-right] 'next-buffer)
Obiger Lisp-Code wird in die .emacs-Datei kopiert. Danach können die Einstellungen je nach Geschmack angepasst werden. Zum Beispiel, indem wir einen größeren Standard-Font festlegen:
(set-face-attribute 'default nil :font "Droid Sans Mono-14")