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