dot/emacs: Turn on Magit extensions based on Git config.
[profile] / dot / emacs
CommitLineData
502f4699 1;;; -*- mode: emacs-lisp; coding: utf-8 -*-
f617db13 2;;;
f617db13
MW
3;;; Emacs configuration file
4;;;
5;;; (c) 1996-1999 Mark Wooding
6;;;
7
8;;;----- Licensing notice ---------------------------------------------------
9;;;
10;;; This program is free software; you can redistribute it and/or modify
11;;; it under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 2 of the License, or
13;;; (at your option) any later version.
14;;;
15;;; This program is distributed in the hope that it will be useful,
16;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with this program; if not, write to the Free Software
22;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
23
24(setq load-path (nconc load-path (list "~/lib/emacs")))
25(require 'dot-emacs)
a1bf764e 26(require 'cl)
f617db13 27
6132bc01
MW
28;;;--------------------------------------------------------------------------
29;;; Some random initialisation.
f617db13
MW
30
31(setq mdw-init-window (selected-window))
32
6132bc01 33;; Load some other bits of code.
f617db13 34
400223a1
MW
35(maybe-autoload 'cc-mode "cc-mode" nil t)
36(maybe-autoload 'rexx-mode "rexx-mode" nil t)
37(maybe-autoload 'cvs-update "pcl-cvs" nil t)
38(maybe-autoload 'debian-changelog-mode "debian-changelog-mode" nil t)
39(maybe-autoload 'git-status "git" nil t)
459c9fb2
MW
40(maybe-autoload 'git-blame-mode "git-blame" nil t)
41(maybe-autoload 'stgit "stgit" nil t)
b29312d0
MW
42(maybe-autoload 'nc-timesheet-prepare "nc-timesheet" nil t nil)
43(maybe-autoload 'nc-timesheet-submit "nc-timesheet" nil t nil)
44
eac7b622
MW
45(and (library-exists-p "debian-changelog-mode")
46 (add-to-list 'auto-mode-alist
47 `(,(concat "/debian/"
48 "\\("
43036e3a 49 "[" "[:lower:][:digit:]]"
eac7b622
MW
50 "[[:lower:][:digit:].+-" "]+"
51 "\\."
52 "\\)?"
53 "changelog\\'")
54 . debian-changelog-mode)))
55
400223a1
MW
56(and (library-exists-p "vc-git")
57 (not (memq 'GIT vc-handled-backends))
8d244e27 58 (not (memq 'Git vc-handled-backends))
79ba2d35 59 (not (memq 'git vc-handled-backends))
308b0b57 60 (setq vc-handled-backends (cons 'GIT vc-handled-backends)))
f617db13 61
0f2aab7b 62(setq magit-log-cutoff-length 512)
596c5c5f 63(add-hook 'magit-mode-hook 'magit-load-config-extensions)
0f2aab7b 64
ab9e097f
MW
65(trap (or mdw-fast-startup (require 'p4)))
66
c7a8da49 67(trap (or mdw-fast-startup (require 'tex-site)))
f617db13 68
c07e3e33 69(trap (or mdw-fast-startup t (semantic-load-enable-code-helpers)))
33abafd2 70(setq semanticdb-default-save-directory "~/.emacs.d/semanticdb/")
e74ad275
MW
71(eval-after-load "senator"
72 '(setq isearch-mode-hook
73 (remq 'senator-isearch-mode-hook isearch-mode-hook)
74 isearch-mode-end-hook
75 (remq 'senator-isearch-mode-hook isearch-mode-end-hook)))
75bd2d66 76
6132bc01 77;; Skeleton stuff.
f617db13 78
c7a8da49 79(trap (or mdw-fast-startup (require 'skel-init)))
f617db13 80
6132bc01 81;; Window system-dependent things.
f617db13
MW
82
83(require 'paren)
84(trap (show-paren-mode t))
85(or window-system (menu-bar-mode -1))
86
6132bc01 87;; Temporary directory handling.
f617db13
MW
88
89(defun mdw-check-dir-exists (dir)
90 (and dir
91 (file-directory-p dir)
92 dir))
93(setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
94 (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
95 "/tmp"))
96
6132bc01 97;; Emacs server behaviour.
f617db13 98
ccc2e1fa
MW
99(and (or window-system (>= emacs-major-version 23))
100 (progn (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$")
116259a9 101 edit-server-new-frame nil
ccc2e1fa 102 gnuserv-frame t)
116259a9
MW
103 (trap (server-start))
104 (trap (progn
105 (require 'edit-server)
955a327c
MW
106 (edit-server-start)
107 (let ((edit (get-process "edit-server")))
108 (and edit
109 (set-process-query-on-exit-flag edit nil)))))))
f617db13 110
6132bc01 111;; Control backup behaviour.
f617db13
MW
112
113(setq backup-by-copying nil)
114(setq backup-by-copying-when-linked t)
115(setq backup-by-copying-when-mismatch t)
116
2ae647c4
MW
117(setq mdw-backup-disable-regexps
118 '("/\\.git/COMMIT_EDITMSG$"
119 "/\\.stgit\\(-edit\\.txt\\|msg\\.txt\\|\\.msg\\)$"))
120
6132bc01 121;; Safe variables.
20d4403c
MW
122
123(setq safe-local-variable-values
124 '((make-backup-files . nil)))
125
6132bc01 126;; Calculator fiddling.
f617db13
MW
127
128(setq calc-settings-file "~/.emacs-calc")
129(load calc-settings-file)
130
131;; ---- Some mail and news configuration ---
132
c17fdbff 133(setq mail-from-style 'angles
c60cbbe8
MW
134 mail-signature t
135 mail-yank-prefix "> "
136 mail-archive-file-name "~/Mail/sent"
137 compose-mail-user-agent-warnings nil)
f617db13
MW
138
139(setq rmail-display-summary t)
140(setq rmail-file-name "~/Mail/rmail")
141
a3bdb4d9
MW
142(setq sendmail-program "~/bin/sendmail-hack")
143
cb1389c0
MW
144(setq mail-user-agent 'message-user-agent
145 read-mail-command 'gnus)
728fe976
MW
146(setq message-signature-separator "^-- \\(\\|\\[mdw\\]\\)$"
147 message-yank-prefix "> "
148 message-yank-cited-prefix "> "
98ed7cc2 149 message-send-mail-function 'message-send-mail-with-sendmail
f646ea77 150 message-sendmail-envelope-from 'header
728fe976
MW
151 message-indent-citation-function '(message-indent-citation
152 mdw-trim-spaces-after-citing))
153
154(defun mdw-trim-spaces-after-citing ()
155 (save-excursion
156 (save-restriction
157 (narrow-to-region (point) (mark t))
158 (while (re-search-forward "^> +$" nil t)
159 (replace-match ">")))))
a3bdb4d9
MW
160
161(and (fboundp 'turn-on-gnus-dired-mode)
162 (not mdw-fast-startup)
163 (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode))
164
165(or mdw-fast-startup
98a0bc3f 166 (trap (bbdb-initialize 'gnus 'sendmail 'message)))
a3bdb4d9
MW
167(setq bbdb-north-american-phone-numbers-p nil)
168
6132bc01 169;; Customization.
78100945
MW
170
171(setq custom-file "~/.emacs-custom")
172(trap (load custom-file))
173
174(trap (load "~/.emacs-local"))
175
6132bc01 176;; Internationalization twiddling.
f617db13
MW
177
178(trap
bc30f5c4 179 ;; Have top-bit-set characters work properly in terminals.
f617db13
MW
180 (let ((im (current-input-mode)))
181 (apply #'set-input-mode
bc30f5c4 182 (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im)))))
f617db13 183
6132bc01 184;; Don't disable any commands.
f617db13
MW
185
186(mapatoms #'(lambda (sym) (put sym 'disabled nil)))
187
6132bc01 188;; Split a wide window.
f617db13
MW
189
190(mdw-divvy-window)
191
6132bc01 192;; Postscript printing.
1a4d7e7d
MW
193
194(setq ps-paper-type 'a4
195 ps-print-color-p nil
196 ps-landscape-mode t
2c84dee2 197 ps-number-of-columns 2
1a4d7e7d 198 ps-font-family 'Courier
2c84dee2 199 ps-font-size 6.5)
1a4d7e7d 200
6132bc01 201;; Splash screen stuff.
1a4d7e7d
MW
202
203(or window-system
204 (setq inhibit-splash-screen t
205 inhibit-startup-message t))
206
6132bc01 207;; Other goodies.
f617db13 208
89a72209 209(trap (resize-minibuffer-mode 1)) ;Make minibuffer grow dynamically
f617db13 210(auto-compression-mode 1) ;Enable automatic compression
cf6c4653
MW
211(setq enable-local-variables :safe
212 enable-local-eval nil)
f617db13 213(setq dabbrev-case-replace nil) ;Retain case when completing
e2363e48 214(setq linum-format "%7d ")
f617db13 215(setq next-line-add-newlines nil) ;Don't add weird newlines
9a60965e 216(setq split-height-threshold nil) ;Reuse windows where sensible
9aea0679
MW
217(setq display-buffer-reuse-frames nil ;Don't confuse me by showing buffers
218 iswitchb-default-method 'samewindow) ;in other random frames
f617db13 219(setq dired-deletion-confirmer ;Make deletion easier in dired
f3f0c0a0
MW
220 (symbol-function 'y-or-n-p)
221 dired-listing-switches "-alF" ;Do `ls -F' things in dired windows
222 wdired-allow-to-change-permissions 'advanced)
85dc07c7 223(setq read-quoted-char-radix 16) ;C-q HEX-STUFF [RET]
f617db13
MW
224(setq case-fold-file-names nil) ;Don't translate file names (grr...)
225(setq scroll-step 5) ;Don't scroll too much at a time
226(setq-default fill-column 77) ;I use rather narrow windows
227(setq-default comment-column 40) ;Set a standard comment column
a2f12a94
MW
228(setq-default truncate-partial-width-windows nil
229 truncate-lines t)
3459d2cb
MW
230(setq default-indicate-empty-lines t)
231(setq whitespace-style
11a169c1 232 '(trailing space-before-tab space-after-tab empty indentation face))
4d4f9ad1
MW
233(setq woman-use-own-frame nil ;Keep man pages somewhere sensible
234 woman-fill-column 72) ;Right margin position.
f617db13
MW
235(setq diff-switches "-u" ;I like reading unified diffs
236 cvs-diff-flags (list diff-switches))
237(setq echo-keystrokes 10) ;Long delay before keystrokes echo
238(setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
239(setq find-ls-option ;Build file lists efficiently
240 '("-print0 | xargs -0r ls -ld" . "ld"))
6006518e 241(setq bookmark-save-flag 0) ;Save bookmarks automatically
91dba4e4 242(setq x-gtk-file-dialog-help-text nil)
e34a133f 243(setq Info-fontify-maximum-menu-size 100000)
3af826d8 244(setq set-mark-command-repeat-pop t)
38ddb67e 245(setq password-cache-expiry nil)
9de66169
MW
246(setq-default proced-filter 'all
247 proced-sort 'user)
68b2e9e6 248(setq ispell-program-name "aspell-hack"
cbffcf2b
MW
249 ispell-local-dictionary "en_GB-ize-w_accents"
250 flyspell-default-dictionary "en_GB-ize-w_accents"
30acc372
MW
251 ispell-local-dictionary-alist
252 '(("en_GB-ize-w_accents" "[[:alpha:]]" "[^[:alpha:]]" "'" t
253 ("-d" "en_GB-ize-w_accents") nil utf-8))
689009c0 254 ispell-silently-savep t)
f617db13
MW
255(trap
256 (require 'uniquify)
257 (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
258 (setq uniquify-after-kill-buffer-p t))
259(transient-mark-mode t)
9958af68 260(setq mark-even-if-inactive t)
f617db13
MW
261(trap
262 (tooltip-mode 0)
263 (tool-bar-mode 0))
4ae85887 264(trap (or mdw-fast-startup (global-auto-revert-mode t)))
f617db13
MW
265(setq psgml-html-build-new-buffer nil)
266
3d6a7d27
MW
267(defvar mdw-black-background t)
268
5de5db48
MW
269(eval-after-load "outline"
270 '(progn
271 (trap (require 'foldout))
272 (define-key outline-mode-prefix-map [?\C-r] 'reveal-mode)
273 (define-key outline-mode-prefix-map [?\C--] 'mdw-outline-collapse-all)))
8fd1960c 274
56becc91
MW
275(setq imenu-auto-rescan t
276 imenu-auto-rescan-maxout (* 128 1024)
277 imenu-max-items 60)
278
f141fe0f
MW
279(setq cltl2-root-url (mdw-config 'cltl-url))
280(setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
281
6132bc01
MW
282;;;--------------------------------------------------------------------------
283;;; W3 and URL fetching stuff.
f141fe0f 284
45d17e24 285(let ((proxy (mdw-config 'http-proxy)))
f141fe0f
MW
286 (setq url-proxy-services
287 `(("http" . ,proxy)
288 ("ftp" . ,proxy)
289 ("gopher" . ,proxy))))
290(setq url-cookie-untrusted-urls '("."))
852cd5fb 291
a203fba8 292(setq browse-url-browser-function (mdw-good-url-browser)
ed5e20a5 293 browse-url-generic-program "mdw-chrome"
a203fba8 294 browse-url-mozilla-program "firefox")
9b72460c 295
3d6231da
MW
296(setq w3m-default-display-inline-images t
297 w3m-use-cookies t)
9b72460c 298
b0ef6a66
MW
299(eval-after-load "w3m"
300 '(let ((entries '(("application/pdf" "\\.pdf\\'" ("evince" file) nil)
301 ("application/x-pdf" "\\.pdf\\'" ("evince" file) nil))))
302 (dolist (e entries)
303 (setq w3m-content-type-alist
304 (cons e (remove* (car e) w3m-content-type-alist
305 :key #'car :test #'string=))))))
306
f141fe0f
MW
307(setq w3-do-incremental-display t
308 w3-use-menus '(file edit view go bookmark options
309 buffers style search emacs nil help)
310 w3-display-inline-image t
311 w3-keybinding 'info)
f617db13 312
6132bc01
MW
313;;;--------------------------------------------------------------------------
314;;; Calendar configuration.
f617db13 315
ea09c6cb
MW
316(setq diary-file "~/etc/diary")
317
6132bc01 318;; Trivial stuff for the sunrise/sunset calculations.
f617db13
MW
319
320(setq calendar-latitude 52.2)
321(setq calendar-longitude 0.1)
322(setq calendar-location-name "Cambridge, UK")
323
6132bc01 324;; Holidays.
a1293ade
MW
325
326(and (not mdw-fast-startup)
327 (trap
328 (require 'ew-hols)
329 (setq other-holidays (append english-and-welsh-bank-holidays
330 other-holidays))))
331
6132bc01 332;; Date format fiddling.
f617db13
MW
333
334(setq european-calendar-style t)
335
336(setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
337 (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
338 (backup day " *" monthname "\\W+\\<[^*0-9]")
339 (day "[-/]" month "[-/]" year "[^0-9]")
340 (day " *" monthname " *" year "[^0-9]")
341 (year "[-/]" month "[-/]" day "[^0-9]")
342 (dayname "\\W")))
343
6132bc01 344;; Fancy diary handling.
f617db13
MW
345
346(add-hook 'diary-display-hook 'fancy-diary-display)
347(setq diary-list-include-blanks t)
348(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
349(add-hook 'list-diary-entries-hook 'include-other-diary-files)
350(add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
351
6132bc01 352;; Appointment management.
f617db13
MW
353
354(add-hook 'diary-hook 'appt-make-list)
355(setq appt-issue-message t)
356(setq appt-display-interval 3)
357(setq appt-message-warning-time 10)
358
6132bc01 359;; Org-mode agenda.
2d6b9d95 360
e3f433a2
MW
361(setq org-agenda-include-diary t
362 org-tags-column -77)
2d6b9d95 363
6132bc01 364;; Cosmetic stuff.
f617db13 365
b7a7bc64
MW
366(setq calendar-view-diary-initially-flag t
367 calendar-view-holidays-initially-flag t)
368
f617db13
MW
369(setq display-time-24hr-format t)
370(display-time)
dca9e3ae 371(column-number-mode 1)
f8faccda 372(trap (if window-system (calendar)))
f617db13 373
6132bc01
MW
374;;;--------------------------------------------------------------------------
375;;; MailCrypt.
f617db13 376
6132bc01 377;; Define more mode hooks for MailCrypt.
f617db13
MW
378
379(setq mdw-mc-modes
380 '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
381 (sign . mdwmail-mc-sign))))
382
6132bc01 383;; Load the MailCrypt support.
f617db13
MW
384
385(trap
386 (and (string-match "linux" (symbol-name system-type))
c7a8da49 387 (not mdw-fast-startup)
f617db13
MW
388 (progn (require 'mailcrypt-init)
389 (require 'mailcrypt)
390 (setq mc-default-scheme 'mc-scheme-gpg)
391 (setq mc-pgp-user-id "mdw-nsict-pgp")
392 (setq mc-gpg-user-id "mdw-nsict-gpg")
393 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
394 (setq mc-pgp-always-sign t)
395 (setq mc-gpg-always-sign t)
396 (setq mc-always-replace 'never)
397 (setq mc-passwd-timeout 3600)
398 (setq mc-temp-directory tmpdir)
399 (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
400 (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
401 (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
402 (add-hook 'text-mode-hook 'mc-install-write-mode))))
403
6132bc01
MW
404;;;--------------------------------------------------------------------------
405;;; Other common declarations.
f617db13 406
6132bc01 407;; Default frame size.
f617db13
MW
408
409(setq default-frame-alist
410 (mdw-uniquify-alist
411 '((width . 78)
412 (height . 33)
c14ce5af
MW
413 (vertical-scroll-bars . right)
414 (cursor-type . bar)
415 (cursor-blink . t)
416 (left-fringe . 5)
417 (right-fringe . 5)
418 (scroll-bar-width . 15)
419 (cursor-color . "red"))
f617db13 420 (if mdw-black-background
6dc0fd06 421 '((background-mode . dark))
2dd9081f
MW
422 '((background-mode . light)))))
423(setq window-system-default-frame-alist
424 '((pm (font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
425 (menu-font . "8.Helv")
426 (background-color . "lightgrey"))
427 (nil (menu-bar-lines . 0))))
f617db13 428
6132bc01 429;; Other frame fiddling.
f617db13
MW
430
431(setq frame-title-format '("" invocation-name "@" system-name ": %b"))
432
6132bc01 433;; Global keymap changes.
f617db13
MW
434
435(trap
f110f932
MW
436 (windmove-default-keybindings))
437(setq windmove-wrap-around t)
f617db13 438(trap (iswitchb-mode))
f9d83bff
MW
439(progn
440 (global-set-key [?\C-x ?w left] 'windmove-left)
441 (global-set-key [?\C-x ?w ?h] 'windmove-left)
442 (global-set-key [?\C-x ?w up] 'windmove-up)
443 (global-set-key [?\C-x ?w ?k] 'windmove-up)
444 (global-set-key [?\C-x ?w down] 'windmove-down)
445 (global-set-key [?\C-x ?w ?j] 'windmove-down)
446 (global-set-key [?\C-x ?w right] 'windmove-right)
447 (global-set-key [?\C-x ?w ?l] 'windmove-right)
448 (global-set-key [?\C-x ?g ?l] 'org-store-link)
449 (global-set-key [?\C-x ?g ?a] 'org-agenda)
450 (global-set-key [?\C-x ?g ?b] 'org-iswitchb)
451 (global-set-key [?\C-x ?t ?i] 'timeclock-in)
452 (global-set-key [?\C-x ?t ?c] 'timeclock-change)
453 (global-set-key [?\C-x ?t ?o] 'timeclock-out)
454 (global-set-key [?\C-x ?t ?r] 'timeclock-reread-log)
455 (global-set-key [?\C-x ?t ?w] 'timeclock-workday-remaining-string)
456 (global-set-key [?\C-x ?t ?s] 'timeclock-status-string)
457 (global-set-key [?\C-x ?t ?p] 'nc-timesheet-prepare)
458 (global-set-key [?\C-x ?t ?\C-m] 'nc-timesheet-submit)
3ba0b777 459 (global-set-key [?\C-x ?3] 'mdw-split-window-horizontally)
f9d83bff
MW
460 (global-set-key [?\M-#] 'calc-dispatch)
461 (global-set-key [?\C-x ?/] 'auto-fill-mode)
462 (global-set-key [?\C-x ?w ?d] 'mdw-divvy-window)
463 (global-set-key [insertchar] 'overwrite-mode)
464 (global-set-key [?\C-x ?\C-n] 'skel-create-file)
465 (global-set-key [?\C-x ?4 ?n] 'skel-create-file-other-window)
466 (global-set-key [?\C-x ?5 ?n] 'skel-create-file-other-frame)
467 (global-set-key [delete] 'delete-char)
468 (global-set-key [?\M-q] 'mdw-fill-paragraph)
469 (global-set-key [?\C-h ?\C-m] 'manual-entry)
470 (global-set-key [C-M-backspace] 'backward-kill-sexp)
471 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
472 (global-set-key [vertical-scroll-bar C-down-mouse-1]
473 'mouse-drag-vertical-line)
474 (global-set-key [vertical-scroll-bar C-mouse-1]
475 #'(lambda () (interactive)))
56becc91 476 (global-set-key [M-S-mouse-3] 'imenu)
f9d83bff
MW
477 (global-set-key [XF86WakeUp] "")
478 (and (not mdw-fast-startup) (fboundp 'hippie-expand)
479 (global-set-key [?\M-/] 'hippie-expand)))
f617db13 480
cadc9736
MW
481(eval-after-load "dired"
482 '(progn
8cb828d5
MW
483 (or (lookup-key dired-mode-map [?\C-x ?\C-q])
484 (define-key dired-mode-map [?\C-x ?\C-q]
485 'wdired-change-to-wdired-mode))
d9d0aed3 486 (trap (require 'dired-x))
8cb828d5
MW
487 (and (fboundp 'dired-do-relsymlink)
488 (define-key dired-mode-map [?\C-c ?\C-s] 'dired-do-relsymlink))))
cadc9736 489
16fe7c41
MW
490(add-hook 'org-mode-hook
491 #'(lambda () (mdw-clobber-evil-keymap org-mode-map)))
492(add-hook 'org-agenda-mode-hook
493 #'(lambda () (mdw-clobber-evil-keymap org-agenda-mode-map)))
f351e828 494(or mdw-fast-startup
f6cd49f1
MW
495 (trap (progn
496 (org-remember-insinuate)
497 (global-set-key [?\C-c ?r] 'org-remember))))
4849ea18 498
9b63bcd2
MW
499;; Minor mode listing
500
501(setq minor-mode-alist
502 (mdw-uniquify-alist '((reveal-mode (hs-minor-mode
503 " hs/r"
504 (global-reveal-mode
505 "" " Reveal")))
506 (hs-minor-mode (reveal-mode "" " hs"))
507 (abbrev-mode "")
508 (gtags-mode ""))
509 minor-mode-alist))
510
6132bc01 511;; Recognising types of files.
f617db13
MW
512
513(setq auto-mode-alist
514 (append `(("\\.p[lm]$" . perl-mode)
515 ("\\.m$" . objc-mode)
516 ("\\.mxd$" . c-mode)
e6cb5770 517 ("\\.cs$" . csharp-mode)
07965a39 518 ("\\.go$" . go-mode)
133cf81d 519 ("\\.org$" . org-mode)
10ac316c 520 ("\\.make$" . makefile-mode)
f617db13
MW
521 ;; ("/[ch]/" . c-mode)
522 (,(concat "/\\("
523 "\\.stgit\\.msg" "\\|"
03372583 524 "\\.topmsg" "\\|"
f617db13
MW
525 "\\.git/COMMIT_EDITMSG" "\\|"
526 "svn-commit\\.tmp" "\\|"
527 "svk-commit[^/.]*\\.tmp"
528 "\\)$")
529 . text-mode)
530 (,(concat "^" tmpdir "/\\("
531 "svk-commit[^/.]*\\.tmp" "\\|"
532 "gitci\\.[^/.]*" "\\|"
533 "cvs[^/.]\\{6\\}" "\\|"
400223a1 534 "quilt_header\.[^/.]\\{6\\}"
f617db13
MW
535 "\\)$")
536 . text-mode)
537 ("\\.calc?$" . apcalc-mode)
538 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
539 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
540 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
541 ("\\.st$" . smalltalk-mode)
1e52f579
MW
542 ("\\.msgs$" . messages-mode)
543 ("/all-cmds\\.in$" . cpp-messages-mode)
f617db13
MW
544 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
545 ("\\.gc$" . haskell.-mode)
546 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
870778ff 547 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\|mutt\\)")
f617db13
MW
548 . mdwmail-mode))
549 auto-mode-alist))
550
27cb4215 551(setq interpreter-mode-alist
8b064239 552 (append `(("runlisp" . lisp-mode)
9a60965e 553 ("@BASH@" . sh-mode)
8b064239
MW
554 ("@PYTHON@" . python-mode)
555 ("@PERL@" . perl-mode)
556 ("@TCLSH@" . tcl-mode)
6905514a
MW
557 ("@WISH@" . tcl-mode)
558 ("/tclsh" . tcl-mode)
559 ("/wish" . tcl-mode))
27cb4215
MW
560 interpreter-mode-alist))
561
f617db13
MW
562(setq completion-ignored-extensions
563 (append `(".hc" ".hi") completion-ignored-extensions))
298fab5b
MW
564(dolist (dir (remove-if-not (lambda (ext)
565 (= (aref ext (- (length ext) 1)) ?/))
566 completion-ignored-extensions))
567 (if (/= (aref dir 0) ?/)
568 (setq completion-ignored-extensions
569 (cons (concat "/" dir)
570 (remove dir completion-ignored-extensions)))))
f617db13 571
6132bc01 572;; Some common local definitions.
f617db13
MW
573
574(make-variable-buffer-local 'mdw-auto-indent)
575
32194bba
MW
576(mapc (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
577 '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
578 csharp-mode-hook perl-mode-hook cperl-mode-hook
579 python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook
c24a0acd
MW
580 tcl-mode-hook go-mode-hook js-mode-hook javascript-mode-hook
581 conf-mode-hook m4-mode-hook autoconf-mode-hook autotest-mode-hook
32194bba
MW
582 asm-mode-hook TeX-mode-hook LaTeX-mode-hook
583 TeXinfo-mode-hook tex-mode-hook latex-mode-hook
584 texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook
585 lisp-mode-hook lisp-interaction-mode-hook makefile-mode-hook
586 inferior-lisp-mode-hook slime-repl-mode-hook
587 sml-mode-hook haskell-mode-hook erlang-mode-hook
588 smalltalk-mode-hook rexx-mode-hook
589 arm-assembler-mode-hook))
f617db13
MW
590
591(global-font-lock-mode t)
592(defalias 'perl-mode 'cperl-mode)
593
6132bc01
MW
594;;;--------------------------------------------------------------------------
595;;; Rootly editingness.
f617db13
MW
596
597(eval-after-load "tramp"
ae7460d4 598 '(let ((fix-args (if (mdw-version-< tramp-version "2.1")
507ebf80 599 #'append #'list)))
f617db13
MW
600 (setq tramp-methods
601 (mdw-uniquify-alist
602 `(("become"
603 (tramp-connection-function tramp-open-connection-su)
604 (tramp-remote-sh "/bin/sh")
605 (tramp-login-program "become")
606 (tramp-copy-program nil)
607 (tramp-copy-args nil)
608 (tramp-copy-keep-date-arg nil)
ae7460d4 609 (tramp-login-args ,(funcall fix-args `("TERM=dumb" "%u"))))
f617db13
MW
610 ("really"
611 (tramp-connection-function tramp-open-connection-su)
612 (tramp-login-program "really")
ae7460d4
MW
613 (tramp-login-args ,(funcall fix-args
614 `("-u" "%u")
615 `("--")
616 `("env" "TERM=dumb" "/bin/sh")))
f617db13
MW
617 (tramp-copy-program nil)
618 (tramp-copy-args nil)
619 (tramp-copy-keep-date-arg nil)
620 (tramp-remote-sh "/bin/sh"))
621 ,@tramp-methods)))
f617db13 622 (setq tramp-default-method "ssh")
415c9a27
MW
623 (let ((rootlyness (cond ((executable-find "really") "really")
624 ((executable-find "become") "become")
625 ((executable-find "sudo") "sudo")
ac667d04
MW
626 (t "su")))
627 (this-host (concat "\\`\\(localhost\\|"
628 (system-name) "\\|\\)\\'"))
629 (this-user (concat "\\`\\(" (user-login-name) "\\|"
630 (user-real-login-name) "\\|\\)\\'")))
415c9a27 631 (setq tramp-default-method-alist
ac667d04
MW
632 `((,this-host nil ,rootlyness)
633 (nil ,this-user "ssh")
634 (nil "." ,rootlyness)))
635 (setq tramp-default-proxies-alist
636 `((,this-host nil nil)
637 (nil "." "/ssh:%h:"))))))
f617db13 638
6132bc01
MW
639;;;--------------------------------------------------------------------------
640;;; General fontification.
f617db13 641
6132bc01 642;; Configure lazy fontification.
f617db13 643
f29cc9b2
MW
644(and (fboundp 'lazy-lock-mode)
645 (setq font-lock-support-mode 'lazy-lock-mode))
f617db13 646; (setq lazy-lock-defer-contextually t)
f9d83bff
MW
647(setq lazy-lock-defer-time nil
648 font-lock-maximum-decoration 3
649 lazy-lock-minimum-size 0
650 lazy-lock-stealth-time 5
651 lazy-lock-stealth-lines 100
652 lazy-lock-stealth-verbose t)
f617db13 653
f9d83bff
MW
654(progn
655 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
656 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
657 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
658 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
659 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
07965a39 660 (add-hook 'go-mode-hook 'mdw-fontify-go t)
f617db13 661
f9d83bff 662 (add-hook 'icon-mode-hook 'mdw-fontify-icon t)
f617db13 663
f9d83bff
MW
664 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
665 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
cc1980e1 666
f9d83bff 667 (add-hook 'java-mode-hook 'mdw-fontify-java t)
61d63206 668 (add-hook 'js-mode-hook 'mdw-fontify-javascript t)
f9d83bff 669 (add-hook 'csharp-mode-hook 'mdw-fontify-csharp t)
f617db13 670
f9d83bff 671 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
f617db13 672
f9d83bff
MW
673 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
674 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t))
f617db13 675
f9d83bff
MW
676(progn
677 (setq-default py-indent-offset 2
85e430d4 678 python-indent 2
f9d83bff
MW
679 py-python-command-args
680 `("-i" "-colors" ,(if mdw-black-background
681 "Linux" "LightBG")))
682 (add-hook 'python-mode-hook 'mdw-fontify-python t)
683 (add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t))
f617db13
MW
684
685(setq-default tcl-indent-level 2)
686(add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
687
688(add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
689
f9d83bff
MW
690(setq sml-nested-if-indent t
691 sml-case-indent nil
692 sml-indent-level 4
693 sml-type-of-indent nil)
f617db13
MW
694(add-hook 'sml-mode-hook 'mdw-fontify-sml t)
695
696(add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
697(setq-default haskell-indent-offset 2)
698
2ded9493
MW
699(add-hook 'erlang-mode-hook 'mdw-fontify-erlang t)
700
f617db13
MW
701(add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
702(add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
703
704(setq LaTeX-table-label "tbl:")
f617db13
MW
705(setq TeX-auto-untabify nil)
706(add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
707(add-hook 'tex-mode-hook 'mdw-fontify-tex t)
708(add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
709(add-hook 'latex-mode-hook 'mdw-fontify-tex t)
710
711(add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
ec007bea 712(add-hook 'autoconf-mode-hook #'mdw-setup-m4)
32194bba 713(add-hook 'autotest-mode-hook #'mdw-setup-m4)
ec007bea 714(add-hook 'm4-mode-hook #'mdw-setup-m4)
f617db13
MW
715
716(add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
717(add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
718
f9d83bff
MW
719(progn
720 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
721 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
722 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
723 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
724 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
725 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
726 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
727 (add-hook 'inferior-lisp-mode-hook
f617db13 728 #'(lambda ()
f9d83bff 729 (local-set-key "\C-m" 'comint-send-and-indent)) t))
f617db13
MW
730
731(add-hook 'text-mode-hook 'mdw-text-mode t)
732
6132bc01
MW
733;;;--------------------------------------------------------------------------
734;;; TeX stuff.
e9955c63
MW
735
736(setq TeX-output-view-style
737 '(("^dvi$"
738 ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
739 "%(o?)dvips -t landscape %d -o && evince %f")
740 ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$"
741 "%(o?)dvips %d -o && evince %f")
742 ("^dvi$"
743 ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
744 "%(o?)xdvi %dS -paper a4r -s 0 %d")
745 ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$"
746 "%(o?)xdvi %dS -paper a4 %d")
747 ("^dvi$"
748 ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
749 "%(o?)xdvi %dS -paper a5r -s 0 %d")
750 ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
751 ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
752 ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
753 ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
754 ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
755 ("^dvi$" "." "%(o?)xdvi %dS %d")
756 ("^pdf$" "." "evince %o")
757 ("^html?$" "." "netscape %o")))
758
88daf8fb
MW
759(setq TeX-view-program-selection
760 '(((output-dvi style-pstricks) "dvips and gv")
761 (output-dvi "xdvi")
762 (output-pdf "Evince")
763 (output-html "xdg-open")))
764
b615028c
MW
765(setq TeX-open-quote "\""
766 TeX-close-quote "\"")
767
ad21c20c
MW
768(setq reftex-use-external-file-finders t
769 reftex-auto-recenter-toc t)
770
771(setq reftex-label-alist
772 '(("theorem" ?T "th:" "~\\ref{%s}" t ("theorems?" "th\\.") -2)
773 ("axiom" ?A "ax:" "~\\ref{%s}" t ("axioms?" "ax\\.") -2)
774 ("definition" ?D "def:" "~\\ref{%s}" t ("definitions?" "def\\.") -2)
775 ("proposition" ?P "prop:" "~\\ref{%s}" t
776 ("propositions?" "prop\\.") -2)
4458f45a 777 ("lemma" ?L "lem:" "~\\ref{%s}" t ("lemmas?" "lem\\.") -2)
ad21c20c
MW
778 ("example" ?X "eg:" "~\\ref{%s}" t ("examples?") -2)
779 ("exercise" ?E "ex:" "~\\ref{%s}" t ("exercises?" "ex\\.") -2)
780 ("enumerate" ?i "i:" "~\\ref{%s}" item ("items?"))))
781(setq reftex-section-prefixes
782 '((0 . "part:")
783 (1 . "ch:")
784 (t . "sec:")))
55f80fae 785
cfabf52c
MW
786(setq bibtex-field-delimiters 'double-quotes
787 bibtex-entry-format '(realign opts-or-alts required-fields
788 numerical-fields last-comma delimiters
789 unify-case)
790 bibtex-include-OPTkey nil)
791
6132bc01
MW
792;;;--------------------------------------------------------------------------
793;;; SLIME setup.
c70671f3 794
ea8a749b
MW
795(trap
796 (if (not mdw-fast-startup)
797 (progn
798 (require 'slime-autoloads)
799 (slime-setup '(slime-autodoc slime-c-p-c)))))
800
c70671f3
MW
801(let ((stuff '((cmucl ("cmucl"))
802 (sbcl ("sbcl") :coding-system utf-8-unix)
803 (clisp ("clisp") :coding-system utf-8-unix))))
804 (or (boundp 'slime-lisp-implementations)
805 (setq slime-lisp-implementations nil))
806 (while stuff
807 (let* ((head (car stuff))
808 (found (assq (car head) slime-lisp-implementations)))
809 (setq stuff (cdr stuff))
810 (if found
811 (rplacd found (cdr head))
812 (setq slime-lisp-implementations
813 (cons head slime-lisp-implementations))))))
814(setq slime-default-lisp 'sbcl)
815
6132bc01
MW
816;;;--------------------------------------------------------------------------
817;;; Blogging.
362f6ac4
MW
818
819(setq weblogger-config-alist
820 '(("vox"
821 ("user" . "mdw")
822 ("server-url" . "http://vox.distorted.org.uk/admin/mt-xmlrpc.cgi")
823 ("weblog" . "1"))))
824
6132bc01
MW
825;;;--------------------------------------------------------------------------
826;;; Shell mode.
f617db13 827
6132bc01 828;; Make the shell mode aware of my prompt.
f617db13 829
ac4ae7cd 830(setq shell-prompt-pattern "^[^]#$%>»}\n]*\\([]#$%»}]\\|>>?\\) *")
f617db13 831(setq comint-password-prompt-regexp
ab9e097f 832 (concat "\\(\\([Ee]nter \\|[Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
c70b4880 833 "[Pp]assword\\|[Pp]ass ?phrase\\(\\| [-a-zA-Z0-9._]+\\)\\):")
423716a6
MW
834 comint-file-name-chars "~/A-Za-z0-9+@:_.$#%,={}-"
835 shell-file-name-chars comint-file-name-chars)
f617db13 836
6132bc01 837;; Notice passwords, and make C-a work right.
f617db13
MW
838
839(add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
21409787 840(add-hook 'shell-mode-hook #'ansi-color-for-comint-mode-on)
0805d57c 841(setq shell-font-lock-keywords nil)
f617db13
MW
842
843(add-hook 'term-mode-hook #'mdw-term-mode-setup)
844
6132bc01
MW
845;;;--------------------------------------------------------------------------
846;;; Finishing touches.
f617db13
MW
847
848(trap (select-window mdw-init-window))
849(provide 'emacs-init)
850
f617db13 851;;;----- That's all, folks --------------------------------------------------