1 | ;;; init.lisp |
---|
2 | ;;; $Id: init.lisp,v 1.36 2007-03-04 19:08:11 piso Exp $ |
---|
3 | |
---|
4 | ;;; ~/.j/init.lisp (if it exists) is loaded automatically when j starts up. |
---|
5 | |
---|
6 | (defun java-version () |
---|
7 | (jstatic "getProperty" "java.lang.System" "java.version")) |
---|
8 | |
---|
9 | (defun adjust-appearance () |
---|
10 | (when (member (subseq (java-version) 0 5) |
---|
11 | '("1.4.0" "1.4.1" "1.4.2" "1.5.0" "1.6.0" "1.7.0") |
---|
12 | :test #'string=) |
---|
13 | (set-global-property "adjustAscent" -2) |
---|
14 | (set-global-property "adjustLeading" -2) |
---|
15 | (reset-display))) |
---|
16 | |
---|
17 | ;; Do it now! |
---|
18 | (adjust-appearance) |
---|
19 | |
---|
20 | ;; Turn off the remove-trailing-whitespace preference for files in the |
---|
21 | ;; directory ~/gcl/ansi-tests. |
---|
22 | (defun my-open-file-hook (buf) |
---|
23 | (let ((pathname (buffer-pathname buf))) |
---|
24 | (when (and pathname |
---|
25 | (string= (directory-namestring pathname) |
---|
26 | "/home/peter/gcl/ansi-tests/")) |
---|
27 | (set-buffer-property "removeTrailingWhitespace" nil)))) |
---|
28 | |
---|
29 | (add-hook 'open-file-hook 'my-open-file-hook) |
---|
30 | |
---|
31 | ;; Helper function for MY-BUFFER-ACTIVATED-HOOK. |
---|
32 | (defun sub-p (namestring dirname) |
---|
33 | "Returns T if NAMESTRING is in DIRNAME or one of its subdirectories" |
---|
34 | (let ((dirname-length (length dirname))) |
---|
35 | (and (> (length namestring) dirname-length) |
---|
36 | (string= (subseq namestring 0 dirname-length) dirname)))) |
---|
37 | |
---|
38 | (defun my-buffer-activated-hook (buf) |
---|
39 | (let ((pathname (buffer-pathname buf))) |
---|
40 | ;; PATHNAME might be NIL (not all buffers have associated files). |
---|
41 | (when pathname |
---|
42 | (let ((type (pathname-type pathname))) |
---|
43 | ;; We only care about Lisp and Java buffers. |
---|
44 | (cond ((string= type "el") |
---|
45 | (set-buffer-property |
---|
46 | "tagPath" |
---|
47 | "/home/peter/emacs-21.3/lisp:/home/peter/emacs-21.3/lisp/emacs-lisp")) |
---|
48 | ((member type '("lisp" "lsp" "cl" "java") :test 'string=) |
---|
49 | (let* ((namestring (namestring pathname)) |
---|
50 | (tagpath |
---|
51 | (cond ((sub-p namestring "/home/peter/cmucl/src/") |
---|
52 | "/home/peter/cmucl/src/code:/home/peter/cmucl/src/compiler:/home/peter/cmucl/src/pcl") |
---|
53 | ((sub-p namestring "/home/peter/cl-bench/") |
---|
54 | "/home/peter/cl-bench:/home/peter/cl-bench/files:/home/peter/depot/j/src/org/armedbear/lisp") |
---|
55 | ((sub-p namestring "/home/peter/gcl/ansi-tests/") |
---|
56 | "/home/peter/gcl/ansi-tests:/home/peter/depot/j/src/org/armedbear/lisp") |
---|
57 | ((sub-p namestring "/home/peter/phemlock") |
---|
58 | "/home/peter/phemlock/src/core:/home/peter/phemlock/src/user") |
---|
59 | ((sub-p namestring "/home/peter/sbcl") |
---|
60 | "/home/peter/sbcl/src/code:/home/peter/sbcl/src/compiler") |
---|
61 | (t ; default case: no change |
---|
62 | nil)))) |
---|
63 | ;; If we end up here with a non-NIL TAGPATH, use it to set the |
---|
64 | ;; buffer-specific value of the TAG-PATH preference for the current |
---|
65 | ;; buffer. |
---|
66 | (when tagpath |
---|
67 | (set-buffer-property "tagPath" tagpath))))))))) |
---|
68 | |
---|
69 | ;; Install our hook function. |
---|
70 | (add-hook 'buffer-activated-hook 'my-buffer-activated-hook) |
---|
71 | |
---|
72 | ;; Call ADJUST-APPEARANCE after saving ~/.j/prefs. |
---|
73 | (defun my-after-save-hook (buf) |
---|
74 | (let ((pathname (buffer-pathname buf))) |
---|
75 | (when (equal pathname #p"/home/peter/.j/prefs") |
---|
76 | (adjust-appearance)))) |
---|
77 | |
---|
78 | (add-hook 'after-save-hook 'my-after-save-hook) |
---|
79 | |
---|
80 | (defun reset-incoming-filters () |
---|
81 | (jstatic "resetIncomingFilters" "org.armedbear.j.mail.IncomingFilter")) |
---|
82 | |
---|
83 | (defun add-incoming-filter (mailbox pattern action parameter) |
---|
84 | (jstatic "addIncomingFilter" "org.armedbear.j.mail.IncomingFilter" |
---|
85 | mailbox pattern action parameter)) |
---|
86 | |
---|
87 | (add-hook 'mailbox-mode-hook |
---|
88 | (lambda () |
---|
89 | (reset-incoming-filters) |
---|
90 | (add-incoming-filter "inbox" |
---|
91 | "~C linux-kernel" |
---|
92 | "move" |
---|
93 | "mail/linux-kernel") |
---|
94 | (add-incoming-filter "inbox" |
---|
95 | "~C ix.netcom.com" |
---|
96 | "move" |
---|
97 | "mail/netcom"))) |
---|
98 | |
---|
99 | (defun maybe-load (pathname) |
---|
100 | (when (probe-file pathname) |
---|
101 | (load pathname))) |
---|
102 | |
---|
103 | (maybe-load "/home/peter/.j/key-pressed.lisp") |
---|
104 | (maybe-load "/home/peter/.j/update-check-enabled.lisp") |
---|
105 | |
---|
106 | (maybe-load #+windows "c:/cygwin/home/peter/j/build-abcl.lisp" |
---|
107 | #-windows "/home/peter/j/build-abcl.lisp") |
---|
108 | |
---|
109 | (map-key-for-mode ")" "electricCloseParen" "Lisp Shell") |
---|
110 | |
---|
111 | (map-key-for-mode "[" "insertParentheses" "Lisp") |
---|
112 | (map-key-for-mode "]" "movePastCloseAndReindent" "Lisp") |
---|