My Emacs Memory

This is the place where I write down emacs commands and tricks that I often need and often forget. It is not sorted in any way, and of course, it is not complete.

General

  • Reload a file with: M-x revert-buffer, automatically reload changes with auto-revert, there is also a auto-revert-tail-mode to watch log files.
  • Spell checking on the fly with: M-x flyspell-mode. Middle mouse button will give you a list of possible corrections for each misspelled word.

Lines (ReFill-Mode)

  • M-q refills current paragraph, this is normally what you want.
  • Line wrapping with M-x toggle-truncate lines.
  • Insert line breaks after 80 chars automatically: auto-fill-mode
  • Change filled characters to 100 (default is 80): (set-fill-column 100)
  • Refill a region: M-x fill-region

CC Mode

  • C-c C-c is for commenting a region, uncomment it with C-u C-c C-c

My .emacs backup

This is to have my .emacs accessible from everywhere.

;; ----- Default .emacs ------
 
(setq user-mail-address "foo@bar")
(setq user-full-name "Foo Bar")
 
;; look and feel
(setq inhibit-startup-screen t)
(transient-mark-mode -1)
(tool-bar-mode -1)
(line-number-mode 1)
(column-number-mode 1)
(setq text-mode-hook 'turn-on-auto-fill)
(setq tab-width 4)
 
;; colors
(global-font-lock-mode 1) ;; always syntax color
(add-to-list 'default-frame-alist '(background-color . "White"))
(add-to-list 'default-frame-alist '(foreground-color . "Black"))
(add-to-list 'default-frame-alist '(cursor-color . "Blue"))
(add-to-list 'default-frame-alist '(border-color . "DimGray"))
 
;; compilation
(setq compilation-window-height 8)
(setq compilation-scroll-output 'first-error)
(global-set-key [(control c) (c)] 'compile-again)
 
;; keyboard shortcuts
(global-set-key [(f9)] 'recompile)
(global-set-key "\M-t" 'toggle-truncate-lines)
 
(global-set-key [(mouse-6)] 'windmove-left)
(global-set-key [(mouse-7)] 'windmove-right)
(global-set-key [(mouse-8)] 'windmove-down)
(global-set-key [(mouse-9)] 'windmove-up)
 
(global-set-key (kbd "\C-x C-<left>") 'windmove-left)
(global-set-key (kbd "\C-x C-<right>") 'windmove-right)
(global-set-key (kbd "\C-x C-<down>") 'windmove-down)
(global-set-key (kbd "\C-x C-<up>") 'windmove-up)
 
(require 'org)
;; org mode stuff
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-clock-persist t)
; (org-clock-persistence-insinuate)
 
;; latex mode stuff
(add-hook 'latex-mode-hook 'flyspell-mode)
(add-hook 'TeX-mode-hook 'flyspell-mode)
(add-hook 'latex-mode-hook 'reftex-mode)
 
;; c mode stuff
(require 'cc-mode)
(add-hook 'c-mode-common-hook
 	  (lambda () (subword-mode 1)))
(defun my-c-mode-common-hook ()
  (c-set-style "linux")
  (setq c-basic-offset 4)
  (setq tab-width 4)
  (c-set-offset 'substatement-open 0)
 
  (setq c-hungry-delete-key 1)
  (toggle-truncate-lines)
 
  (define-key c-mode-base-map "\C-m" 'c-context-line-break)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
 
;; custom functions
 
(defun german-mode () (interactive)
  (ispell-change-dictionary "de-neu")
  )
 
(defun fullscreen (&optional f)
  (interactive)
  (set-frame-parameter f 'fullscreen
		       (if (frame-parameter f 'fullscreen) nil 'fullboth)))
(global-set-key [f11] 'fullscreen)
(add-hook 'after-make-frame-functions 'fullscreen)
 
(autoload 'octave-mode "octave-mode" nil t)
(setq auto-mode-alist
      (cons '("\\.m$" . octave-mode) auto-mode-alist))
 
;; templates
 
(require 'autoinsert)
(auto-insert-mode)  ;;; Adds hook to find-files-hook
(setq auto-insert-directory "~/Templates/") ;;; Trailing slash important
(setq auto-insert-query nil) ;;; do not prompt
(define-auto-insert "\.org" "org-template.org")
 
;; FRL (feature request list) syntax highlighting
(require 'generic-x)
(define-generic-mode 
  'frl-mode
  '("#")
  '("//name" "//depends" "//description" "//long" "//break"
    "//done" "//progress" "//actual-time" 
    "//time")
  '(("md" . 'font-lock-buildin) 
    ("mm" . 'font-lock-buildin)
    ("my" . 'font-lock-builtin))
  '("\\.frl$")
   nil
  "A mode for frl (feature request list) files"
)
 
;; ----- local customization ------
;; follows here
devlog/blog/my_emacs_memory.txt · Last modified: 2010/07/23 13:25 by x4
Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! DevLog Atom feed Valid XHTML 1.0