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