My .emacs file
June 26th, 2008 by Daniel Høyer Iversen
Here is my .emacs file. Copy it to ~/ and it will modify your emacs.
.emacs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | ;;File: .emacs
;;Author: Daniel Høyer Iversen
;; Time-stamp: \<Last changed 29-06-2008 23:24:51 by Daniel, dahoiv>
;; URL: http://dahoiv.net/.emacs
;; This file is free software; you can redistribute it and/or modify
;; it undr the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; what kind of system are we using?
(defconst console-p (eq (symbol-value 'window-system) nil)
"Are we running in a console (non-X) environment?")
;; Keyboard
;; ============
;;
(global-set-key [C-tab] 'yic-next-buffer)
(global-set-key [(shift tab)] 'yic-prev-buffer)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end] 'end-of-buffer)
(global-set-key [f7] 'next-error)
(global-set-key [C-a] 'mark-whole-buffer)
(global-set-key "C-z" 'undo)
(global-set-key "C-v" 'yank)
(global-set-key (kbd "C-c c") 'comment-region) ;; make C-c C-c and C-c C-u work
(global-set-key (kbd "C-c u") 'uncomment-region) ;; for comment/uncomment region in all modes
(global-set-key (kbd "M-<up>") 'move-line-up)
(global-set-key (kbd "M-<down>") 'move-line-down)
;; Window colors
;; =============
;;
(setq default-frame-alist
(append
'((width . 120)
(height . 40)
(background-color . "black")
(foreground-color . "white")
(mouse-color . "blue")
(cursor-color . "red")
; (face-color . "black")
; (face-backgound-color . "#FFFFEEEECCCC")
) default-frame-alist))
;; MISC SECTION
;; =============
;;
;syntax highlite
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(custom-set-faces)
;make the y or n suffice for a yes or no question
(fset 'yes-or-no-p 'y-or-n-p)
;; Bruk aspell til stavekontroll
(custom-set-variables
'(ispell-program-name "aspell"))
;; Show column-number in the mode line
(column-number-mode 1)
;; Turn on mouse wheel
(mouse-wheel-mode t)
;; show mark visually
(transient-mark-mode t)
;; show parenthesis
(show-paren-mode t)
;; highlighted
(when (not console-p)
(global-hl-line-mode 1)
(set-face-background 'highlight "#444")
)
;; copy-paste should work with other X clients
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
;; =============
;; Programing, scripts
;; =============
;;
;; Python mode
;; =============
;;
(setq auto-mode-alist (cons '("\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("python" . python-mode)
interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
;; LaTeX mode
;; =============
;;
(setq latex-mode-hook'(lambda ()
(setq skeleton-pair t)
(global-set-key "(" 'skeleton-pair-insert-maybe)
(global-set-key "[" 'skeleton-pair-insert-maybe)
(global-set-key "{" 'skeleton-pair-insert-maybe)
(global-set-key "$" 'skeleton-pair-insert-maybe)
)
)
;;; Matlab-mode setup:
;; Add local lisp folder to load-path
;;(setq load-path (append load-path (list "~/emacs")))
;; Set up matlab-mode to load on .m files
;;(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
;;(setq auto-mode-alist (cons '("\.m\'" . matlab-mode) auto-mode-alist))
;;(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)
;; Customization:
;;(setq matlab-indent-function t) ; if you want function bodies indented
;;(setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save
;;(defun my-matlab-mode-hook ()
;; (setq fill-column 76)) ; where auto-fill should wrap
;;(add-hook 'matlab-mode-hook 'my-matlab-mode-hook)
;;(defun my-matlab-shell-mode-hook ()
;; '())
;;(add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook)
;; Turn off Matlab desktop
;;(setq matlab-shell-command-switches '("-nojvm"))
;; =============
;; Methods
;; =============
;;
;; Prevent accidentally killing emacs.
(global-set-key [(control x) (control c)]
'(lambda ()
(interactive)
(if (y-or-n-p-with-timeout "Do you really want to exit Emacs ? " 4 nil)
(save-buffers-kill-emacs))))
;; time-stamps from http://www.djcbsoftware.nl/dot-emacs.html
;; when there is a "Time-stamp: <>" in the first 10 lines of the file,
;; emacs will write time-stamp information there when saving the file.
;; see the top of this file for an example...
(setq
time-stamp-active t ; do enable time-stamps
time-stamp-line-limit 10 ; check first 10 buffer lines for Time-stamp: <>
time-stamp-format "Last changed %02d-%02m-%04y %02H:%02M:%02S by %L, %u") ; date format
(add-hook 'write-file-hooks 'time-stamp) ; update when saving
;; Move current line up or down with M-up or M-down
(defun move-line (n)
"Move the current line up or down by N lines."
(interactive "p")
(let ((col (current-column))
start
end)
(beginning-of-line)
(setq start (point))
(end-of-line)
(forward-char)
(setq end (point))
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(insert line-text)
;; restore point to original column in moved line
(forward-line -1)
(forward-char col))))
(defun move-line-up (n)
"Move the current line up by N lines."
(interactive "p")
(move-line (if (null n) -1 (- n))))
(defun move-line-down (n)
"Move the current line down by N lines."
(interactive "p")
(move-line (if (null n) 1 n)))
;; ----------------------------------------------------------------------
;; Original yic-buffer.el
;; From: choo@cs.yale.edu (young-il choo)
;; Date: 7 Aug 90 23:39:19 GMT
;;
;; Modified
;; ----------------------------------------------------------------------
(defun yic-ignore (str)
(or
;;buffers I don't want to switch to
(string-match "\*Buffer List\*" str)
(string-match "^TAGS" str)
(string-match "^\*Messages\*$" str)
(string-match "^\*Completions\*$" str)
(string-match "^ " str)
;;Test to see if the window is visible on an existing visible frame.
;;Because I can always ALT-TAB to that visible frame, I never want to
;;Ctrl-TAB to that buffer in the current frame. That would cause
;;a duplicate top-level buffer inside two frames.
(memq str
(mapcar
(lambda (x)
(buffer-name
(window-buffer
(frame-selected-window x))))
(visible-frame-list)))
))
(defun yic-next (ls)
"Switch to next buffer in ls skipping unwanted ones."
(let* ((ptr ls)
bf bn go
)
(while (and ptr (null go))
(setq bf (car ptr) bn (buffer-name bf))
(if (null (yic-ignore bn)) ;skip over
(setq go bf)
(setq ptr (cdr ptr))
)
)
(if go
(switch-to-buffer go))))
(defun yic-prev-buffer ()
"Switch to previous buffer in current window."
(interactive)
(yic-next (reverse (buffer-list))))
(defun yic-next-buffer ()
"Switch to the other buffer (2nd in list-buffer) in current window."
(interactive)
(bury-buffer (current-buffer))
(yic-next (buffer-list)))
;;end of yic buffer-switching methods |
You will find the updated version here: http://dahoiv.net/.emacs
You will find the updated version here: http://dahoiv.net/.emacs