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