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