My DotEmacs (~/.emacs)

My usual .emacs file, not that exciting i dont mess with things too much, i have some other .el files like my crules.el for hacking on crule code etc but here it is:

  1.  
  2. (custom-set-variables
  3.   ;; custom-set-variables was added by Custom.
  4.   ;; If you edit it by hand, you could mess it up, so be careful.
  5.   ;; Your init file should contain only one such instance.
  6.   ;; If there is more than one, they won’t work right.
  7.  ’(inhibit-startup-screen t)
  8.  ’(initial-scratch-message ";; Hapy Hacking")
  9.  ’(scroll-bar-mode nil)
  10.  ’(show-paren-mode t))
  11. (custom-set-faces
  12.   ;; custom-set-faces was added by Custom.
  13.   ;; If you edit it by hand, you could mess it up, so be careful.
  14.   ;; Your init file should contain only one such instance.
  15.   ;; If there is more than one, they won’t work right.
  16.  ’(default ((t (:inherit nil :stipple nil :background "grey20" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 123 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))
  17.  ’(cursor ((t (:background "red")))))
  18.  
  19. (defun fc-turn-on-show-trailing-whitespace ()
  20.   "Set `show-trailing-whitespace’ to t."
  21.   (setq show-trailing-whitespace t))
  22.  
  23. (mapc (lambda (hook)
  24.         (add-hook hook ‘fc-turn-on-show-trailing-whitespace))
  25.       ‘(c-mode-hook))
  26.  
  27. (setq-default tab-width 2) ; or any other preferred value
  28. (setq cua-auto-tabify-rectangles nil)
  29.  
  30. (defadvice align (around smart-tabs activate)
  31.   (let ((indent-tabs-mode nil)) ad-do-it))
  32.  
  33. (defadvice align-regexp (around smart-tabs activate)
  34.   (let ((indent-tabs-mode nil)) ad-do-it))
  35.  
  36. (defadvice indent-relative (around smart-tabs activate)
  37.   (let ((indent-tabs-mode nil)) ad-do-it))
  38.  
  39. (defadvice indent-according-to-mode (around smart-tabs activate)
  40.   (let ((indent-tabs-mode indent-tabs-mode))
  41.     (if (memq indent-line-function
  42.               ‘(indent-relative
  43.                 indent-relative-maybe))
  44.         (setq indent-tabs-mode nil))
  45.     ad-do-it))
  46.  
  47. (defmacro smart-tabs-advice (function offset)
  48.   (defvaralias offset ‘tab-width)
  49.   `(defadvice ,function (around smart-tabs activate)
  50.      (cond
  51.       (indent-tabs-mode
  52.        (save-excursion
  53.          (beginning-of-line)
  54.          (while (looking-at "\t*\\( +\\)\t+")
  55.            (replace-match "" nil nil nil 1)))
  56.        (setq tab-width tab-width)
  57.        (let ((tab-width fill-column)
  58.              (,offset fill-column))
  59.          ad-do-it))
  60.       (t
  61.        ad-do-it))))
  62.  
  63. (smart-tabs-advice c-indent-line c-basic-offset)
  64. (smart-tabs-advice c-indent-region c-basic-offset)
  65.  
  66. (smart-tabs-advice cperl-indent-line cperl-indent-level)
  67.  
  68. (smart-tabs-advice python-indent-line-1 python-indent)
  69. (add-hook ‘python-mode-hook
  70.           (lambda ()
  71.             (setq indent-tabs-mode t)
  72.             (setq tab-width (default-value ‘tab-width))))
  73.  
  74. (setq-default indent-tabs-mode nil)
  75.  
  76. (add-hook ‘c-mode-common-hook
  77.           (lambda () (setq indent-tabs-mode t)))
  78.  
  79. (define-generic-mode ‘crules-mode
  80.   ‘("#")
  81.   ‘("workflow" "class" "rule" "defun" "each" "break" "where"
  82.     "continue" "return" "in" "for" "while" "until" "import"
  83.     "from" "if" "elif" "else" "print" "true" "false" "eval"
  84.     "let" "null" "this" "at" "defre")
  85.   ‘(("[a-zA-Z_][a-zA-Z0-9_]+" . font-lock-variable-name-face)
  86.     ("[0-9]+" "true" "false" . font-lock-constant-face)
  87.     ("\\[.*\\]" . font-lock-type-face))
  88.   ‘(".crl\\‘")
  89.   nil
  90.   "Generic Major mode for the Crules programming language!")
  91.  
  92. (defun set-newline-and-indent ()
  93.   (local-set-key (kbd "RET") ‘newline-and-indent))
  94. (add-hook ‘crules-mode-hook ‘set-newline-and-indent)
  95.  
  96.