chiark / gitweb /
emacs, dot-emacs: Support for assembler programming.
[profile] / emacs
1 ;;; -*-emacs-lisp-*-
2 ;;;
3 ;;; $Id: .emacs,v 1.11 1997/01/01 18:47:09 mdw Exp $
4 ;;;
5 ;;; Emacs configuration file
6 ;;;
7 ;;; (c) 1996-1999 Mark Wooding
8 ;;;
9
10 ;;;----- Licensing notice ---------------------------------------------------
11 ;;;
12 ;;; This program is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
16 ;;;
17 ;;; This program is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with this program; if not, write to the Free Software
24 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
25
26 (setq load-path (nconc load-path (list "~/lib/emacs")))
27 (require 'dot-emacs)
28
29 ;;;----- Some random initialisation -----------------------------------------
30
31 (setq mdw-init-window (selected-window))
32
33 ;; --- Load some other bits of code ---
34
35 (setq load-path (cons "~/lib/emacs" load-path))
36
37 (maybe-autoload 'cc-mode "cc-mode" nil t)
38 (maybe-autoload 'rexx-mode "rexx-mode" nil t)
39 (maybe-autoload 'cvs-update "pcl-cvs" nil t)
40 (maybe-autoload 'debian-changelog-mode "debian-changelog-mode" nil t)
41 (maybe-autoload 'git-status "git" nil t)
42 (and (library-exists-p "vc-git")
43      (not (memq 'GIT vc-handled-backends))
44      (setq vc-handled-backends (cons 'GIT vc-handled-backends)))
45 (and (library-exists-p "quilt")
46      (load "quilt"))
47
48 (trap
49   (or (fboundp 'make-regexp)
50       (load "make-regexp")))
51
52 (trap (require 'tex-site))
53
54 ;; --- Skeleton stuff ---
55
56 (trap (require 'skel-init))
57
58 ;; --- Window system-dependent things ---
59
60 (require 'paren)
61 (trap (show-paren-mode t))
62 (or window-system (menu-bar-mode -1))
63
64 ;; --- Temporary directory handling ---
65
66 (defun mdw-check-dir-exists (dir)
67   (and dir
68        (file-directory-p dir)
69        dir))
70 (setq tmpdir (or (mdw-check-dir-exists (getenv "TMPDIR"))
71                  (mdw-check-dir-exists (format "/tmp/%s" (user-login-name)))
72                  "/tmp"))
73
74 ;; --- Emacs server behaviour ---
75
76 (and window-system
77      (trap (gnuserv-start)
78            (setq server-temp-file-regexp (concat "^" tmpdir "\\|/draft$"))))
79
80 ;; --- Control backup behaviour ---
81
82 (setq backup-by-copying nil)
83 (setq backup-by-copying-when-linked t)
84 (setq backup-by-copying-when-mismatch t)
85
86 ;; --- Calculator fiddling ---
87
88 (setq calc-settings-file "~/.emacs-calc")
89 (load calc-settings-file)
90
91 ;; ---- Some mail and news configuration ---
92
93 (setq mail-from-style 'parens)
94 (setq mail-signature t)
95 (setq mail-yank-prefix "> ")
96 (setq mail-archive-file-name "~/Mail/sent")
97
98 (setq rmail-display-summary t)
99 (setq rmail-file-name "~/Mail/rmail")
100
101 ;; --- GNUS configuration ---
102
103 (setq gnus-select-method '(nntp "tux.nsict.org"))
104 (setq gnus-read-active-file 'some)
105 (setq gnus-inhibit-startup-message t)
106 (setq gnus-large-newsgroup 500)
107
108 ;; --- Internationalization twiddling ---
109
110 (trap
111   (standard-display-european 1)
112   (let ((im (current-input-mode)))
113     (apply #'set-input-mode
114            (nconc (list (nth 0 im) (nth 1 im) 0) (nthcdr 3 im))))
115   (set-language-environment "Latin-1"))
116
117 ;; --- Don't disable any commands ---
118
119 (mapatoms #'(lambda (sym) (put sym 'disabled nil)))
120
121 ;; --- Split a wide window ---
122
123 (mdw-divvy-window)
124
125 ;; --- Other goodies ---
126
127 (trap (resize-minibuffer-mode 1))       ;Make minibuffer grow dynamically
128 (auto-compression-mode 1)               ;Enable automatic compression
129 (setq dabbrev-case-replace nil)         ;Retain case when completing
130 (setq next-line-add-newlines nil)       ;Don't add weird newlines
131 (setq split-height-threshold 45)        ;Reuse windows where sensible
132 (setq dired-deletion-confirmer          ;Make deletion easier in dired
133       (symbol-function 'y-or-n-p))
134 (setq dired-listing-switches "-alF")    ;Do `ls -F' things in dired windows
135 (setq case-fold-file-names nil)         ;Don't translate file names (grr...)
136 (setq scroll-step 5)                    ;Don't scroll too much at a time
137 (setq-default fill-column 77)           ;I use rather narrow windows
138 (setq-default comment-column 40)        ;Set a standard comment column
139 (setq-default truncate-partial-width-windows nil)
140 (setq diff-switches "-u"                ;I like reading unified diffs
141       cvs-diff-flags (list diff-switches))
142 (setq echo-keystrokes 10)               ;Long delay before keystrokes echo
143 (setq ange-ftp-ftp-program-name "pftp") ;Use passive FTP
144 (setq find-ls-option                    ;Build file lists efficiently
145       '("-print0 | xargs -0r ls -ld" . "ld"))
146 (setq Info-fontify-maximum-menu-size 60000)
147 (setq ispell-dictionary "british"
148       flyspell-default-dictionary "british"
149       ispell-silently-savep t)
150 (trap
151   (require 'uniquify)
152   (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
153   (setq uniquify-after-kill-buffer-p t))
154 (transient-mark-mode t)
155 (trap
156   (tooltip-mode 0)
157   (tool-bar-mode 0))
158 (trap (global-auto-revert-mode t))
159 (setq psgml-html-build-new-buffer nil)
160
161 (setq cltl2-root-url (mdw-config 'cltl-url))
162 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))
163
164 ;;;----- W3 and URL fetching stuff ------------------------------------------
165
166 (let ((proxy (mdw-config 'http-proxy)))
167   (setq url-proxy-services
168         `(("http" . ,proxy)
169           ("ftp" . ,proxy)
170           ("gopher" . ,proxy))))
171 (setq url-cookie-untrusted-urls '("."))
172
173 (setq browse-url-browser-function (mdw-good-url-browser)
174       browse-url-mozilla-program "firefox")
175
176 (setq w3m-default-display-inline-images t)
177
178 (setq w3-do-incremental-display t
179       w3-use-menus '(file edit view go bookmark options
180                      buffers style search emacs nil help)
181       w3-display-inline-image t
182       w3-keybinding 'info)
183
184 ;;;----- Calendar configuration ---------------------------------------------
185
186 ;; --- Trivial stuff for the sunrise/sunset calculations ---
187
188 (setq calendar-latitude 52.2)
189 (setq calendar-longitude 0.1)
190 (setq calendar-location-name "Cambridge, UK")
191
192 ;; --- Date format fiddling ---
193
194 (setq european-calendar-style t)
195
196 (setq diary-date-forms '((day "[-/]" month "[^-/0-9]")
197                          (day " *" monthname "[ \t]*\\(\^M\\|\n\\)")
198                          (backup day " *" monthname "\\W+\\<[^*0-9]")
199                          (day "[-/]" month "[-/]" year "[^0-9]")
200                          (day " *" monthname " *" year "[^0-9]")
201                          (year "[-/]" month "[-/]" day "[^0-9]")
202                          (dayname "\\W")))
203
204 ;; --- Fancy diary handling ---
205
206 (add-hook 'diary-display-hook 'fancy-diary-display)
207 (setq diary-list-include-blanks t)
208 (add-hook 'list-diary-entries-hook 'sort-diary-entries t)
209 (add-hook 'list-diary-entries-hook 'include-other-diary-files)
210 (add-hook 'mark-diary-entries-hook 'mark-included-diary-files)
211
212 ;; --- Appointment management ---
213
214 (add-hook 'diary-hook 'appt-make-list)
215 (setq appt-issue-message t)
216 (setq appt-display-interval 3)
217 (setq appt-message-warning-time 10)
218
219 ;; --- Cosmetic stuff ---
220
221 (setq display-time-24hr-format t)
222 (display-time)
223 (trap
224   (if window-system
225       (let ((view-diary-entries-initially t))
226         (calendar))))
227
228 (defvar mdw-black-background t)
229
230 ;; --- Define more mode hooks for MailCrypt ---
231
232 (setq mdw-mc-modes
233       '((mdwmail-mode (encrypt . mdwmail-mc-encrypt)
234                       (sign . mdwmail-mc-sign))))
235
236 ;; --- Load the MailCrypt support ---
237
238 (trap
239   (and (string-match "linux" (symbol-name system-type))
240        (progn (require 'mailcrypt-init)
241               (require 'mailcrypt)
242               (setq mc-default-scheme 'mc-scheme-gpg)
243               (setq mc-pgp-user-id "mdw-nsict-pgp")
244               (setq mc-gpg-user-id "mdw-nsict-gpg")
245               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
246               (setq mc-pgp-always-sign t)
247               (setq mc-gpg-always-sign t)
248               (setq mc-always-replace 'never)
249               (setq mc-passwd-timeout 3600)
250               (setq mc-temp-directory tmpdir)
251               (setq mc-modes-alist (append mc-modes-alist mdw-mc-modes))
252               (define-key mc-write-mode-map "\C-c/S" 'mc-sign-region)
253               (define-key mc-write-mode-map "\C-c/E" 'mc-encrypt-region)
254               (add-hook 'text-mode-hook 'mc-install-write-mode))))
255
256 ;;;----- Other common declarations ------------------------------------------
257
258 ;; --- Default frame size ---
259
260 (setq default-frame-alist
261       (mdw-uniquify-alist
262        '((width . 78)
263          (height . 33)
264          (vertical-scroll-bars . right))
265        (and window-system
266             '((cursor-type . bar)
267               (cursor-blink . t)))
268        '((cursor-color . "red"))
269        (if mdw-black-background
270            '((background-color . "black")
271              (foreground-color . "white")
272              (background-mode . dark))
273          '((background-mode . light)))
274        (and (eq window-system 'pm)
275             '((font . "-os2-System VIO-medium-r-normal--*-40-*-*-m-*-cp850")
276               (menu-font . "8.Helv")
277               (background-color . "lightgrey")))
278        '((transparency . t))
279        default-frame-alist))
280
281 ;; --- Other frame fiddling ---
282
283 (setq frame-title-format '("" invocation-name "@" system-name ": %b"))
284
285 ;; --- Global keymap changes ---
286
287 (trap
288   (windmove-default-keybindings)
289   (setq windmove-wrap-around t))
290 (trap (iswitchb-mode))
291 (global-set-key [f4] 'query-replace-regexp)
292 (global-set-key [f5] 'goto-line)
293 (global-set-key [f6] 'auto-fill-mode)
294 (global-set-key [f7] 'occur)
295 (global-set-key [f8] 'undo)
296 (global-set-key [f9] 'mdw-divvy-window)
297 (global-set-key [insertchar] 'overwrite-mode)
298 (global-set-key "\C-xm" 'vm-mail)
299 (global-set-key "\C-x\C-n" 'skel-create-file)
300 (global-set-key "\C-x4n" 'skel-create-file-other-window)
301 (global-set-key "\C-x5n" 'skel-create-file-other-frame)
302 (global-set-key [delete] 'delete-char)
303 (global-set-key "\C-[\C-m" 'call-last-kbd-macro)
304 (global-set-key "\M-q" 'mdw-fill-paragraph)
305 (global-set-key "\C-h\C-m" 'manual-entry)
306 (global-set-key [mode-line C-mouse-1] 'mouse-tear-off-window)
307 (global-set-key [vertical-scroll-bar C-down-mouse-1]
308                 'mouse-drag-vertical-line)
309 (global-set-key [vertical-scroll-bar C-mouse-1]
310                 #'(lambda () (interactive)))
311 (global-set-key [mouse-4] 'mdw-wheel-up)
312 (global-set-key [mouse-5] 'mdw-wheel-down)
313
314 ;; --- Recognising types of files ---
315
316 (setq auto-mode-alist
317       (append `(("\\.p[lm]$" . perl-mode)
318                 ("\\.m$" . objc-mode)
319                 ("\\.mxd$" . c-mode)
320                 ("\\.cs" . csharp-mode)
321                 ;; ("/[ch]/" . c-mode)
322                 (,(concat "/\\("
323                           "\\.stgit\\.msg" "\\|"
324                           "\\.git/COMMIT_EDITMSG" "\\|"
325                           "svn-commit\\.tmp" "\\|"
326                           "svk-commit[^/.]*\\.tmp"
327                           "\\)$")
328                  . text-mode)
329                 (,(concat "^" tmpdir "/\\("
330                           "svk-commit[^/.]*\\.tmp" "\\|"
331                           "gitci\\.[^/.]*" "\\|"
332                           "cvs[^/.]\\{6\\}" "\\|"
333                           "quilt_header\.[^/.]\\{6\\}"
334                           "\\)$")
335                  . text-mode)
336                 ("\\.calc?$" . apcalc-mode)
337                 ("/src/linux/.*\\.\\(c\\|h\\|cc\\)$" . linux-c-mode)
338                 ("/\\(s\\|sh\\)/" . arm-assembler-mode)
339                 ("\\.\\(cmd\\|exec\\|rexx\\)$" . rexx-mode)
340                 ("\\.st$" . smalltalk-mode)
341                 ("\\.msgs$" . messages-mode)
342                 ("/all-cmds\\.in$" . cpp-messages-mode)
343                 ("\\.\\(tex\\|dtx\\)$" . latex-mode)
344                 ("\\.gc$" . haskell.-mode)
345                 (,(concat "^" (getenv "HOME") "/News/") . mdwmail-mode)
346                 (,(concat "^" tmpdir "/\\(SLRN\\|snd\\|pico\\)")
347                  . mdwmail-mode))
348               auto-mode-alist))
349
350 (setq interpreter-mode-alist
351       (append `(("runlisp" . lisp-mode))
352               interpreter-mode-alist))
353
354 (setq completion-ignored-extensions
355       (append `(".hc" ".hi") completion-ignored-extensions))
356
357 ;; --- Some common local definitions ---
358
359 (make-variable-buffer-local 'mdw-auto-indent)
360
361 (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config))
362         '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook
363           perl-mode-hook cperl-mode-hook python-mode-hook awk-mode-hook
364           tcl-mode-hook asm-mode-hook
365           TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook
366           tex-mode-hook latex-mode-hook texinfo-mode-hook
367           emacs-lisp-mode-hook scheme-mode-hook
368           lisp-mode-hook lisp-interaction-mode-hook inferior-lisp-mode-hook
369           slime-repl-mode-hook
370           sml-mode-hook haskell-mode-hook
371           smalltalk-mode-hook rexx-mode-hook
372           arm-assembler-mode-hook))
373
374 (global-font-lock-mode t)
375 (defalias 'perl-mode 'cperl-mode)
376
377 ;;;----- SGML hacking -------------------------------------------------------
378
379 (defun mdw-sgml-mode ()
380   (interactive)
381   (sgml-mode)
382   (mdw-standard-fill-prefix "")
383   (make-variable-buffer-local 'sgml-delimiters)
384   (setq sgml-delimiters
385         '("AND" "&" "COM" "--" "CRO" "&#" "DSC" "]" "DSO" "[" "DTGC" "]"
386           "DTGO" "[" "ERO" "&" "ETAGO" ":e" "GRPC" ")" "GRPO" "(" "LIT" "\""
387           "LITA" "'" "MDC" ">" "MDO" "<!" "MINUS" "-" "MSC" "]]" "NESTC" "{"
388           "NET" "}" "OPT" "?" "OR" "|" "PERO" "%" "PIC" ">" "PIO" "<?"
389           "PLUS" "+" "REFC" "." "REP" "*" "RNI" "#" "SEQ" "," "STAGO" ":"
390           "TAGC" "." "VI" "=" "MS-START" "<![" "MS-END" "]]>"
391           "XML-ECOM" "-->" "XML-PIC" "?>" "XML-SCOM" "<!--" "XML-TAGCE" "/>"
392           "NULL" ""))
393   (setq major-mode 'mdw-sgml-mode)
394   (setq mode-name "[mdw] SGML")
395   (run-hooks 'mdw-sgml-mode-hook))
396
397 ;;;----- Rootly editingness -------------------------------------------------
398
399 (eval-after-load "tramp"
400   '(progn
401      (setq tramp-methods
402            (mdw-uniquify-alist
403             `(("become"
404                (tramp-connection-function tramp-open-connection-su)
405                (tramp-remote-sh "/bin/sh")
406                (tramp-login-program "become")
407                (tramp-copy-program nil)
408                (tramp-copy-args nil)
409                (tramp-copy-keep-date-arg nil)
410                (tramp-login-args ("TERM=dumb" "%u")))
411               ("really"
412                (tramp-connection-function tramp-open-connection-su)
413                (tramp-login-program "really")
414                (tramp-login-args ("-u" "%u" "--"
415                                   "env" "TERM=dumb" "/bin/sh"))
416                (tramp-copy-program nil)
417                (tramp-copy-args nil)
418                (tramp-copy-keep-date-arg nil)
419                (tramp-remote-sh "/bin/sh"))
420               ,@tramp-methods)))
421      (setq tramp-multi-connection-function-alist
422            (mdw-uniquify-alist
423             '(("bc" tramp-multi-connect-su "become TERM=dumb %u%n"))
424             '(("r" tramp-multi-connect-su "really -u %u%n"))
425             tramp-multi-connection-function-alist))
426      (setq tramp-default-method "ssh")
427      (setq tramp-default-method-alist
428            `(("\\`localhost\\'" ""
429               ,(cond ((executable-find "become") "become")
430                      ((executable-find "really") "really")
431                      (t "su")))))))
432
433 ;;;----- General fontification ----------------------------------------------
434
435 ;; --- Configure lazy fontification ---
436
437 (and (fboundp 'lazy-lock-mode)
438      (setq font-lock-support-mode 'lazy-lock-mode))
439 ; (setq lazy-lock-defer-contextually t)
440 (setq lazy-lock-defer-time nil)
441 (setq font-lock-maximum-decoration 3)
442 (setq lazy-lock-minimum-size 0)
443 (setq lazy-lock-stealth-time 5)
444 (setq lazy-lock-stealth-lines 100)
445 (setq lazy-lock-stealth-verbose t)
446
447 (add-hook 'after-make-frame-functions 'mdw-do-set-font)
448 (add-hook 'term-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
449 (add-hook 'window-setup-hook (lambda () (mdw-do-set-font (selected-frame))))
450
451 (add-hook 'c-mode-hook 'mdw-fontify-c-and-c++ t)
452 (add-hook 'objc-mode-hook 'mdw-fontify-c-and-c++ t)
453 (add-hook 'c++-mode-hook 'mdw-fontify-c-and-c++ t)
454 (add-hook 'linux-c-mode-hook #'(lambda () (setq c-basic-offset 8)))
455 (add-hook 'asm-mode-hook 'mdw-fontify-asm t)
456
457 (add-hook 'apcalc-mode-hook 'mdw-misc-mode-config t)
458 (add-hook 'apcalc-mode-hook 'mdw-fontify-apcalc t)
459
460 (add-hook 'java-mode-hook 'mdw-fontify-java t)
461
462 (add-hook 'awk-mode-hook 'mdw-fontify-awk t)
463
464 (add-hook 'perl-mode-hook 'mdw-fontify-perl t)
465 (add-hook 'cperl-mode-hook 'mdw-fontify-perl t)
466
467 (setq-default py-indent-offset 2)
468 (add-hook 'python-mode-hook 'mdw-fontify-python t)
469
470 (setq-default tcl-indent-level 2)
471 (add-hook 'tcl-mode-hook 'mdw-fontify-tcl t)
472
473 (add-hook 'rexx-mode-hook 'mdw-fontify-rexx t)
474
475 (setq sml-nested-if-indent t)
476 (setq sml-case-indent nil)
477 (setq sml-indent-level 4)
478 (setq sml-type-of-indent nil)
479 (add-hook 'sml-mode-hook 'mdw-fontify-sml t)
480
481 (add-hook 'haskell-mode-hook 'mdw-fontify-haskell t)
482 (setq-default haskell-indent-offset 2)
483
484 (add-hook 'texinfo-mode-hook 'mdw-fontify-texinfo t)
485 (add-hook 'TeXinfo-mode-hook 'mdw-fontify-texinfo t)
486
487 (setq LaTeX-table-label "tbl:")
488 (setq-default TeX-master nil)
489 ;; (setq TeX-parse-self t)
490 ;; (setq TeX-auto-save t)
491 (setq TeX-auto-untabify nil)
492 (add-hook 'TeX-mode-hook 'mdw-fontify-tex t)
493 (add-hook 'tex-mode-hook 'mdw-fontify-tex t)
494 (add-hook 'LaTeX-mode-hook 'mdw-fontify-tex t)
495 (add-hook 'latex-mode-hook 'mdw-fontify-tex t)
496
497 (add-hook 'sh-mode-hook #'mdw-setup-sh-script-mode)
498
499 (add-hook 'smalltalk-mode-hook 'mdw-fontify-smalltalk t)
500 (add-hook 'smalltalk-mode-hook 'mdw-setup-smalltalk t)
501
502 (add-hook 'emacs-lisp-mode-hook 'mdw-fontify-lispy t)
503 (add-hook 'scheme-mode-hook 'mdw-fontify-lispy t)
504 (add-hook 'lisp-mode-hook 'mdw-fontify-lispy t)
505 (add-hook 'inferior-lisp-mode-hook 'mdw-fontify-lispy t)
506 (add-hook 'lisp-interaction-mode-hook 'mdw-fontify-lispy t)
507 (add-hook 'slime-repl-mode-hook 'mdw-fontify-lispy t)
508 (add-hook 'lisp-mode-hook 'mdw-common-lisp-indent t)
509 (trap
510   (require 'slime)
511   (slime-setup :autodoc t))
512 (trap (require 'xscheme))
513 (setq-default xscheme-process-command-line "scheme -large -emacs")
514 (add-hook 'inferior-lisp-mode-hook
515           #'(lambda ()
516               (local-set-key "\C-m" 'comint-send-and-indent)) t)
517
518 (add-hook 'text-mode-hook 'mdw-text-mode t)
519
520 ;;;----- Shell mode ---------------------------------------------------------
521
522 ;; --- Make the shell mode aware of my prompt ---
523
524 (setq shell-prompt-pattern "^[^]#$%>»}\n]*[]#$%>»}] *")
525 (setq comint-password-prompt-regexp
526       (concat "\\(\\([Oo]ld \\|[Nn]ew \\|[a-zA-Z0-9_]*'s \\|^\\)"
527               "[Pp]assword\\|pass phrase\\):\\s *\\'"))
528
529 ;; --- Notice passwords, and make C-a work right ---
530
531 (add-hook 'shell-mode-hook #'mdw-sh-mode-setup)
532
533 (add-hook 'term-mode-hook #'mdw-term-mode-setup)
534
535 ;;;----- Finishing touches --------------------------------------------------
536
537 (trap (select-window mdw-init-window))
538 (provide 'emacs-init)
539
540 ;;;----- That's all, folks --------------------------------------------------