HNHacker News
TopNewBestAskShowJobs

ruediger

59 karma · joined December 21, 2007

submissionscomments
ruediger··on Ask HN Emacs Users: What's in your .emacs file?
Some tricks from my .emacs:

  (server-start)

  ;; no Tabs
  (setq-default indent-tabs-mode nil)
  (setq-default tabs-width 2)

  ;; List more buffers in the buffer menu
  (setq-default buffers-menu-max-size 30)

  ;; Prevent startup message and switch to empty *scratch*
  (setq inhibit-startup-message t)
  (setq initial-scratch-message nil)

  ;; Fix C&P
  (setq x-select-enable-clipboard t)

  ;; Make Caps Lock LED blink instead of audio bell
  (setq visible-bell 1)
  (setq ring-bell-function
        (lambda ()
          (when (getenv "DISPLAY")
            (call-process-shell-command "xset led named \"Scoll Lock\"; xset -led named \"Scroll Lock\"" nil 0 nil))))

  (show-paren-mode 1)
  (column-number-mode 1)

  ;; Keep the custom stuff separate
  (setq custom-file "~/.emacs.d/custom.el")
  (load custom-file)

  ;; I know what downcase-region does. Me no noob anymore ;). So undisable it.
  (put 'downcase-region 'disabled nil)

  ;; This can be a life saver!
  (push '("." . "~/.emacs.d/backups") backup-directory-alist)

  ;; Create better buffer names. foo.c++:src, foo.c++:extra instead of foo.c++ and foo.c++<2>
  ;; This should really be the default behaviour for Emacs!
  (require 'uniquify)
  (setq 
    uniquify-buffer-name-style 'reverse
    uniquify-separator ":")

  ;; c-mode hook to set better default compile-command if no Makefile exists and activate flyspell-prog-mode
  ;; I have similar hooks for c-mode and fortran-mode
  (add-hook 'c++-mode-hook
          (lambda ()
            (flyspell-prog-mode)
            (unless (or (file-exists-p "Makefile")
                        (local-variable-p 'compile-command)
                        (not buffer-file-name))
              (set (make-local-variable 'compile-command)
                   (format "%s %s %s"
                           (or (getenv "CXX") "g++")
                           (or (getenv "CXXFLAGS")
                               "-pipe -std=c++0x -pedantic-errors -Wall -Wextra -Weffc++ -g3")
                           (file-name-nondirectory buffer-file-name))))))

  ;; Set f9 to compiler and f8 to make clean
  (global-set-key '[f9] 'compile)
  (global-set-key '[f8] '(lambda ()
                          (interactive)
                          (when (file-exists-p "Makefile") (compile "make clean"))))

The rest is just some specific mode setup and minor key bindings stuff.
← PreviousPage 2 of 2