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