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