parsed.org

Tips by tag: dot-emacs

Add Newline When Saving Files by cygnus on Feb 16, 2005 02:30 PM

Emacs can be configured to add a trailing newline by updating ~/.emacs as follows:

(setq require-final-newline t)
dot-emacseditorselispemacsnewline
Customization of global shortcut keys by cygnus on Jan 12, 2005 10:30 AM

To set your own global keybinding to a function, use global-set-key in your ~/.emacs as follows:

(global-set-key "C-cl" 'enlarge-window-horizontally)
configurationdot-emacseditorselispemacskeystrokes
Fixing the Backspace Key by cygnus on Nov 14, 2005 11:14 AM

On some systems (and for some terminal types), Emacs' use of the backspace key can be confusing. The backspace key may behave like the Delete key. You can fix this either by using this elisp in your ~/.emacs as follows:

(keyboard-translate ?\C-h ?\C-?)

This shell command may work if the elisp does not:

stty erase '^?'
backspacecrapdeletedot-emacseditorsemacsgotchakeystrokesterminal
Goto-line by cygnus on Jan 12, 2005 10:31 AM

Use this in your ~/.emacs to bind a key to goto-line:

(global-set-key "C-cl" 'goto-line)
configurationdot-emacseditorselispemacskeystrokes
Macros by xinu on Jan 12, 2005 10:50 AM

To create a macro:

C-x (

Once in macro recording mode, enter a series of commands. When finished:

C-x )

To name the most recently recorded macro:

M-x name-last-kbd-macro

Enter a name for the macro. The name will now be accessible as M-x <name>.

To generate macro elisp suitable for reload, run M-x insert-kbd-macro and enter the name of a defined macro. Paste the resulting code into ~/.emacs.

configurationdot-emacseditorsemacskeystrokesmacros
Make Emacs Use Spaces Instead of Tabs by cygnus on Dec 21, 2005 11:01 AM

To get emacs to stop inserting tab characters and insert spaces instead, use this in your ~/.emacs file:

(setq-default indent-tabs-mode nil)
configurationdot-emacseditorsemacsindentationspacestabs
Pasting With the Mouse by cygnus on Feb 09, 2006 04:12 PM

If you use middle-clicking to paste into Emacs windows but don't like how the paste occurs at the click location and would rather paste at point, use this in your ~/.emacs:

(setq mouse-yank-at-point t)

Thanks to Kevin Turner for pointing this out.

configurationdot-emacseditorselispemacsmousepointyank
Setting Modes by xinu on Jan 15, 2005 02:52 PM

If you wish for a particular file to be handled with a mode that isn't already associated with its extension, you may put a header like this anywhere in the file:

-*- mode: outline; mode: auto-fill -*-

Alternatively, you can update your ~/.emacs to use modes based on file extension or filename. For example, to use html-mode for files ending in .tpl:

(setq auto-mode-alist
  (cons '("\\.tpl$" . html-mode) auto-mode-alist))

You can also configure Emacs to use a specific major and minor mode together for a given file extension. This example defines my-mode to load outline-mode (a major mode) and auto-fill-mode (a minor mode) for files ending in .foo:

(defun my-mode ()
  (outline-mode)
  (auto-fill-mode))

(setq auto-mode-alist
  (append '(("\\.foo$" . my-mode))
    auto-mode-alist))
configurationdot-emacseditorselispemacs
RSS