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