08e0e277fb16e74390a4fd5281093d9622120c65
[syinit] / 11-pkgs-sy.el
1 ;; 11-pkgs-sy.el --- Various XE Package Settings   -*- Emacs-Lisp -*-
2
3 ;; Copyright (C) 2007 - 2012 Steve Youngs
4
5 ;;     Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;;    Created: <2007-12-02>
8 ;; Time-stamp: <Friday Jun 29, 2012 16:36:51 steve>
9 ;;   Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;;   HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/11-pkgs-sy.html>
11 ;;   Git Repo: git clone http://git.sxemacs.org/syinit
12 ;;   Keywords: init, compile
13
14 ;; This file is part of SYinit
15
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
18 ;; are met:
19 ;;
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;;    notice, this list of conditions and the following disclaimer.
22 ;;
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;;    notice, this list of conditions and the following disclaimer in the
25 ;;    documentation and/or other materials provided with the distribution.
26 ;;
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;;    may be used to endorse or promote products derived from this
29 ;;    software without specific prior written permission.
30 ;;
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 ;;; Commentary:
44 ;;
45 ;;   Lots of settings for various XEmacs packages that I use.  Plus a
46 ;;   few other packages.
47 ;;
48 ;;   I want to point out that I DO NOT blindly install the "sumo"
49 ;;   packages.  I only install what I need and use.  And I absolutely
50 ;;   DO NOT have the "fsf-compat" package installed.
51
52 ;;; Credits:
53 ;;
54 ;;   The HTML version of this file was created with Hrvoje Niksic's
55 ;;   htmlize.el which is part of the XEmacs "text-modes" package.
56 ;;
57
58 ;;; Todo:
59 ;;
60 ;;     
61
62 ;;; Code:
63 ;:*======================
64 ;:* MusicPD  (Not an XEmacs package)
65 (require 'mpd)
66
67 (defun sy-mpd-play ()
68   "Start playing music from a randomly chosen playlist."
69   (interactive)
70   (mpd-send "clear")
71   (mpd-send "load Full-sorted.playlist")
72   (mpd-send "random 1")
73   (mpd-send "repeat 1")
74   (mpd-playpause))
75
76 (defun 2001-mpd-play ()
77   "Start playing 2001 audio book."
78   (interactive)
79   (mpd-send "clear")
80   (mpd-send "load 2001_A_Space_Odyssey.playlist")
81   (mpd-send "random 0")
82   (mpd-send "repeat 0")
83   (mpd-playpause))
84
85 ;; Audio keybindings
86 (global-set-key [XF86AudioPlay] #'mpd-playpause)
87 (global-set-key [XF86AudioStop] #'mpd-stop)
88 (global-set-key [XF86AudioNext] #'mpd-next-track)
89 (global-set-key [XF86AudioPrev] #'mpd-previous-track)
90 (global-set-key [XF86AudioRaiseVolume] #'mpd-volume-up)
91 (global-set-key [XF86AudioLowerVolume] #'mpd-volume-down)
92 (global-set-key [XF86AudioMute] #'mpd-volume-mute/unmute)
93
94 ;; Mpd frame props
95 ;(push (cons 'override-redirect t) mpd-dock-frame-plist)
96 (push (cons 'left 1568) mpd-dock-frame-plist)
97 (push (cons 'top 360) mpd-dock-frame-plist)
98 (push (cons 'internal-border-width 4) mpd-dock-frame-plist)
99 (push (cons 'border-width 1) mpd-dock-frame-plist)
100 (push (cons 'border-color "red") mpd-dock-frame-plist)
101
102
103 ;:*======================
104 ;; pcl-cvs - a GNU Emacs front-end to CVS
105 ;; Does anyone use CVS anymore?
106 ;(autoload 'cvs-update "pcl-cvs" nil t)
107 ;(setq
108 ; cvs-reuse-cvs-buffer 'always
109 ; cvs-add-default-message "Initial version"
110 ; cvs-allow-dir-commit t)
111
112 ;:*======================
113 ;:* View-process (`top' for emacs)
114 (require 'view-process-mode)
115 (setq View-process-host-names-and-system-types
116       '(("bastard.steveyoungs.com"
117          ("linux" nil "bsd"
118           View-process-field-name-descriptions-linux
119           View-process-kill-signals-linux))))
120 (setq View-process-status-command-switches-system-v "auxw")
121 (setq View-process-ps-header-window-offset 3)
122 (add-hook 'View-process-header-mode-hook 
123           (lambda ()
124             (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
125             (set-specifier vertical-scrollbar-visible-p nil (current-buffer))))
126
127 ;:*=====================
128 ;:* whitespace-mode
129 (autoload 'whitespace-mode "whitespace-mode"
130   "Toggle whitespace mode.
131      With arg, turn whitespace mode on iff arg is positive.  In
132      whitespace mode the different whitespaces (tab, blank return) are
133      highlighted with different faces. The faces are:
134      `whitespace-blank-face', `whitespace-tab-face' and
135      `whitespace-return-face'."
136   t)
137
138 (autoload 'whitespace-incremental-mode "whitespace-mode"
139   "Toggle whitespace incremental mode.
140      With arg, turn whitespace incremental mode on iff arg is positive.
141      In whitespace incremental mode the different whitespaces (tab and
142      blank) are highlighted with different faces. The faces are:
143      `whitespace-blank-face' and `whitespace-tab-face'.  Use the command
144      `whitespace-show-faces' to show their values.  In this mode only
145      these tabs and blanks are highlighted, which are in the region from
146      (point) - (window-heigh) to (point) + (window-heigh)."
147   t)
148
149 ;:*======================
150 ;:* func-menu
151 (add-hook 'find-file-hooks 'fume-setup-buffer)
152 (add-hook 'Manual-mode-hook 'turn-on-fume-mode)
153 (define-key global-map "\C-cl" 'fume-list-functions)
154 (define-key global-map "\C-cg" 'fume-prompt-function-goto)
155 (define-key global-map '(control button3) 'mouse-function-menu)
156 (setq
157  fume-display-in-modeline-p t
158  fume-menubar-menu-location "File")
159
160 ;:*======================
161 ;:* font-lock
162 (remove-hook 'font-lock-mode-hook 'turn-on-fast-lock)
163 (require 'font-lock)
164
165 ;:*======================
166 ;:* recent-files.el --- Maintain menu of recently opened files.
167 (when (featurep 'menubar)
168   (require 'recent-files)
169   (setq recent-files-non-permanent-submenu t)
170   (recent-files-initialize))
171
172 ;:*======================
173 ;:* jka-compr
174 ;; Handle automatic (de)compresion of [bg]zip files
175 (require 'jka-compr)
176 (jka-compr-install)
177
178 ;:*======================
179 ;:* iswitchb
180 ;: A really cool package to switch buffers
181 (require 'iswitchb)
182 (setq iswitchb-default-method 'samewindow)
183 (iswitchb-default-keybindings)
184 (add-hook
185  'iswitchb-define-mode-map-hook
186  '(lambda ()
187     (define-key iswitchb-mode-map " " 'iswitchb-next-match)
188     (define-key iswitchb-mode-map [(control ?\ )] 'iswitchb-prev-match)
189     (define-key iswitchb-mode-map "\C-a" 'iswitchb-toggle-ignore)))
190
191 ;:*======================
192 ;:* backup
193 ;:  move all backups in one directory
194 (require 'backup-dir)
195 (setq bkup-backup-directory-info
196       '((t "~/.autosave/" ok-create full-path)))
197 (setq version-control 'preserve-prefer-numbered)
198 (setq-default delete-old-versions t)
199
200 ;:*======================
201 ;:* Load minibuffer history, but only if mule or file-coding is available
202 (when (featurep '(or mule file-coding))
203   (require 'savehist)
204   (setq savehist-file (expand-file-name "history" user-init-directory))
205   (setq savehist-coding-system
206         (coding-system-name (find-coding-system 'iso-8859-1)))
207   (savehist-mode 1))
208
209 ;:*======================
210 ;:* Kyle Jones' redo package.
211 (when running-xemacs
212   (require 'redo)
213   (global-set-key "\C-^" 'redo)         ; for tty-s...
214   (global-set-key [(control ?6)] 'redo) ; ...and for X
215   (global-set-key "\M-_" 'redo))        ; universal
216 (require 'scroll-in-place)
217
218 ;:*======================
219 ;:* pending-del
220 ;:  Non-nil when Pending Delete mode is enabled. In Pending Delete mode, typed
221 ;:  text replaces the selected region. Normally, you shouldn't modify this
222 ;:  variable by hand, but use the function `pending-delete-mode' instead. However,
223 ;:  you can customize the default value from the options menu (auto delete
224 ;:  selection).
225 (require 'pending-del)
226 (turn-on-pending-delete nil)
227
228 ;:*======================
229 ;:* comment-region
230 ;:  Comment or uncomment each line in the region.
231 ;:  Comments are terminated on each line, even for syntax in which newline does
232 ;:  not end the comment.  Blank lines do not get comments.
233 (global-set-key '(control f12)  'comment-region)
234 (global-set-key '(meta f12) 'uncomment-region)
235
236 ;:*======================
237 ;:* parens that mark sexpressions
238 (require 'paren)
239 (paren-set-mode 'paren)
240
241 ;:*======================
242 ;:* easy editing of crontab files
243 (require 'crontab-edit "crontab.elc")
244 (setq crontab-delete-blank-lines nil)
245 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
246 (setq crontab-directory
247       (paths-construct-path '("spool" "cron" "crontabs") "/var"))
248
249 ;:*======================
250 ;:* a major mode for editing X resource database files
251 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
252
253 ;:*======================
254 ;:* Footnote package
255 (require 'footnote)
256
257 ;:*======================
258 ;:* Filladapt-Mode
259 (require 'filladapt)
260 (setq-default filladapt-mode t)
261 (setq filladapt-fill-column-tolerance 5)
262 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
263
264 ;:*======================
265 ;:* Speedbar
266 (setq
267  speedbar-query-confirmation-method 'none-but-delete
268  speedbar-show-unknown-files t
269  speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
270                                  speedbar-trim-words-tag-hierarchy
271                                  speedbar-simple-group-tag-hierarchy
272                                  speedbar-sort-tag-hierarchy)
273  speedbar-track-mouse-flag t
274  speedbar-use-tool-tips-flag t
275  speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
276
277 (when (featurep 'menubar)
278   (add-menu-button '("Tools")
279                    ["Speedbar" speedbar-frame-mode
280                     :style toggle
281                     :selected (and (boundp 'speedbar-frame)
282                                    (frame-live-p speedbar-frame)
283                                    (frame-visible-p speedbar-frame))]
284                    "--"))
285 (global-set-key [(f4)] 'speedbar-get-focus)
286 (require 'sb-info)
287 (require 'sb-texinfo)
288 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
289 (eval-after-load "speedbar" '(load-library "sb-html"))
290 (autoload 'w3-speedbar-buttons "sb-w3"
291   "W3 specific speedbar button generator.")
292
293 ;; Speedbar frame props (so I can use matched windows in Sawfish)
294 (setq speedbar-frame-plist
295       (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
296 ;:*======================
297 ;:* Shell-mode
298 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
299 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
300 (add-hook 'shell-mode-hook 'turn-on-font-lock)
301
302 ;:*=======================
303 ;:* Shell-script
304 (setq sh-basic-offset 8)
305
306 ;:*======================
307 ;:* Compile-Mode
308 (setq
309  compilation-always-signal-completion t
310  mode-compile-make-program "make"
311  compilation-read-command t
312  compilation-window-height 10
313  compile-command "make")
314
315 ;:*======================
316 ;:* Balloon Help (now in calendar settings)
317
318 ;:*======================
319 ;:* Version Control
320 (vc-load-vc-hooks)
321 (setq
322  vc-handled-backends '(Arch SVN GIT CVS MCVS RCS)
323  vc-follow-symlinks t)
324
325 ;:*======================
326 ;:* Ediff & Diff-mode
327 (require 'ediff)
328 (require 'diff-mode)
329 (setq ediff-use-toolbar-p nil        ; was t but plays havoc with xwem
330       ediff-custom-diff-options "-u"
331       ediff-window-setup-function 'ediff-setup-windows-plain)
332 (setq diff-switches "-u")
333
334 ;:*=====================
335 ;:* Tramp
336 (require 'tramp)
337 (setq tramp-default-method "ssh"
338       tramp-auto-save-directory "~/.autosave/"
339       tramp-remote-path
340       '("/usr/lib/pkgusr"
341         "/usr/bin"
342         "/bin"
343         "/usr/X11R6/bin"))
344
345 ; :*======================
346 ; :* Eshell
347 ;(require 'pcmpl-arch)
348 (setq 
349  eshell-ask-to-save-history 'always
350  eshell-save-history-on-exit t
351  eshell-banner-message (concat "Welcome to Eshell on "
352                                (system-name)
353                                ", running "
354                                (shell-command-to-string "uname -rs")
355                                "In: "
356                                emacs-version
357                                "\n\n")
358  eshell-hist-ignoredups t
359  eshell-modules-list '(eshell-alias
360                        eshell-banner
361                        eshell-basic
362                        eshell-cmpl
363                        eshell-dirs
364                        eshell-glob
365                        eshell-hist
366                        eshell-ls
367                        eshell-pred
368                        eshell-prompt
369                        ;eshell-rebind 
370                        eshell-script
371                        ;eshell-smart
372                        eshell-term
373                        eshell-unix
374                        eshell-xtra))
375
376 (defun sy-eshell-bol-maybe (&optional prompt)
377   "*Move point to beginning of command or bol if there already.
378  If at bol, move point to beginning of command.
379  Optional arg, PROMPT is a regexp of your eshell prompt."
380   (interactive)
381   (let* ((prompt (or prompt "^.+ [$%] "))
382          (lbpos (point-at-bol))
383          (prspos (save-excursion
384                    (goto-char lbpos)
385                    (search-forward-regexp prompt (point-at-eol) t)))
386          (cpos (point)))
387     (goto-char
388      (cond ((null prspos)
389             lbpos)
390            ((= cpos (or prspos 0))
391             lbpos)
392            (prspos)
393            (t lbpos)))))
394
395 (defun sy-eshell-bol-maybe-key ()
396   (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
397
398 (add-hook 'eshell-mode-hook 'sy-eshell-bol-maybe)
399 (add-hook 'eshell-mode-hook 'sy-eshell-bol-maybe-key t)
400
401 (defun sy-esh-cdl (&optional type)
402   "Eshell function to find current kernel's build or source dir.
403
404  Non-nil TYPE means find the current kernel's build directory, otherwise
405  find the source directory."
406   (let* ((base "/lib/modules/")
407          (ver (substring (shell-command-to-string "uname -r") 0 -1))
408          (dir (file-name-as-directory
409                (concat base ver "/"
410                        (if type
411                            "build"
412                          "source")))))
413     (cd dir)))
414
415 (defun cdls ()
416   "Change directory to current kernel source directory.
417
418  Convenience function to use with Eshell."
419   (interactive)
420   (sy-esh-cdl))
421
422 (defun cdlb ()
423   "Change directory to current kernel build directory.
424
425  Convenience function to use with Eshell."
426   (interactive)
427   (sy-esh-cdl 'build))
428
429 ; :*======================
430 ; :* FFAP -- Find File At Point
431 (require 'ffap)
432
433 (setq
434  ffap-bindings
435  (nconc
436   '((global-set-key '(shift button3) 'ffap-at-mouse)
437     (global-set-key '(control shift button3) 'ffap-menu)
438     (global-set-key "\C-x\C-f" 'find-file-at-point)
439     (global-set-key "\C-x4f"   'ffap-other-window)
440     (global-set-key "\C-x5f"   'ffap-other-frame)))
441  ffap-machine-p-known 'accept
442  ffap-machine-p-unknown 'accept
443  ffap-machine-p-local 'accept)
444
445 (ffap-bindings)
446 (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click)
447
448 ;:*======================
449 ;:* Auto-Insert
450 (require 'auto-insert-tkld)
451
452 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
453                           ("\\.c$"              . "C")
454                           ("\\.cc$"             . "C++")
455                           ("\\.h$"              . "C Header")
456                           ("\\.el$"             . "Emacs Lisp")
457                           ("[Mm]akefile"        . "Makefile")
458                           ("\\.sh$"             . "Sh")
459                           ("\\.pl$"             . "Perl")))
460
461 (setq auto-insert-type-alist '(("TeXinfo"    . "texinfo-insert.texi")
462                                ("C"          . "c-insert.c")
463                                ("C Header"   . "h-insert.h")
464                                ("C++"        . "c++-insert.cc")
465                                ("Emacs Lisp" . "elisp-insert.el")
466                                ("Makefile"   . "makefile.inc")
467                                ("Perl"       . "perl-insert.pl")
468                                ("Sh"         . "sh-insert.sh")))
469
470 (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/")
471
472 ;; Don't auto-insert into AucTeX style .els
473 (defadvice TeX-auto-store (around no-auto-insert activate)
474   "Ensure auto-insert is deactivated"
475   (let ((auto-insert-automatically nil))
476     ad-do-it))
477 (message "Auto-Insert initialised!")
478 ;:*======================
479 ;:* XEtla
480 ; I don't think anyone uses tla anymore
481 ;(require 'xetla)
482 ;(setq
483 ; xetla-show-internal-buffers-on-menu nil
484 ; xetla-switch-to-buffer-mode 'single-window
485 ; xetla-use-arrow-keys-for-navigation t)
486 ;(defun sy-xetla-reload ()
487 ;  "Reload XEtla."
488 ;  (interactive)
489 ;  (call-interactively 'xetla-reload)
490 ;  (require 'xetla-browse)
491 ;  (setq
492 ;   xetla-show-internal-buffers-on-menu nil
493 ;   xetla-switch-to-buffer-mode 'single-window
494 ;   xetla-use-arrow-keys-for-navigation t))
495
496 ;:*=======================
497 ;:* My git shit
498 (require 'sy-git)
499
500 ;:*======================
501 ;:* Emacs Lisp List
502 (defvar sxell-initialised-flag)
503 (defvar sxell-download-directory)
504 (when (and (featurep '(and sxemacs postgresql))
505            (fboundp 'ffi-defun))
506   (require 'sxell)
507   (setq sxell-initialised-flag t
508         sxell-download-directory
509         (file-name-as-directory (expand-file-name "download/SXEmacs"
510                                                   (user-home-directory)))))
511 ;:*======================
512 ;:* EasyPG
513 (require 'epa-setup)
514
515 (defun sy-epa-export-key ()
516   "Wrapper for `epa-export-keys' to export ASCII armoured keys."
517   (interactive)
518   (let ((epa-armor t))
519     (call-interactively #'epa-export-keys)))
520
521 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
522
523 ;:*=======================
524 ;:* Howm thing. (this needs mule, but that is default so no biggie)
525 (require 'howm)
526
527 ;; howm has the unfortunate name that ends in `wm' which is what
528 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
529 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
530
531 ;; The howm people are stupid, they bind C-h to scroll-down
532 ;; Get rid of it and replace with DEL and BACKSPACE
533 (define-key howm-menu-mode-map "\C-h" nil)
534 (define-key howm-menu-mode-map [delete] #'scroll-down)
535 (define-key howm-menu-mode-map [backspace] #'scroll-down)
536 (define-key riffle-summary-mode-map "\C-h" nil)
537 (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down)
538 (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down)
539 (define-key riffle-contents-mode-map "\C-h" nil)
540 (define-key riffle-contents-mode-map [delete] #'scroll-down)
541 (define-key riffle-contents-mode-map [backspace] #'scroll-down)
542
543 ;; Add a binding to show the active todo list
544 (global-set-key [(control ?c) ?t] #'howm-list-active-todo)
545
546 ;; Another problem with howm... it fucks up window configuration
547 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
548   "Save window configuration before viewing howm buffers."
549   (window-configuration-to-register ?h))
550
551 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
552   "Save window configuration before viewing howm buffers."
553   (window-configuration-to-register ?h))
554
555 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
556   "Save window configuration before viewing howm buffers."
557   (window-configuration-to-register ?h))
558
559 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
560   "Save window configuration before viewing howm buffers."
561   (window-configuration-to-register ?h))
562
563 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
564   "Save window configuration before viewing howm buffers."
565   (window-configuration-to-register ?h))
566
567 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
568   "Restore the original window configuration."
569   (jump-to-register ?h))
570
571 (setq howm-directory "~/.howm")
572
573 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
574 ;; call to `turn-on-font-lock' here at least restores a certain level
575 ;; of normalcy.
576 (defun turn-on-howm-mode ()
577   (turn-on-font-lock)
578   (howm-mode 1))
579
580 (defun turn-off-howm-mode ()
581   (howm-mode 0))
582
583 ;; Turn it on where I need it
584 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
585 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
586 ;; compiling the generated .el
587 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
588 (add-hook 'text-mode-hook #'turn-on-howm-mode)
589 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
590 (add-hook 'c-mode-hook #'turn-on-howm-mode)
591 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
592
593 ;; Turn it off where I don't
594 (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode)
595 (add-hook 'html-mode-hook #'turn-off-howm-mode)
596 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
597
598 ;;; Various other howm problem fixes
599
600 ;; I'm having a big problem with howm/font-lock/message-mode playing
601 ;; nicely together.  This gives me font-locking in message-mode, plus
602 ;; howm functionality, but no howm font-locking.  I can live without
603 ;; howm font-lock in one buffer.
604 (add-hook 'message-mode-hook #'(lambda ()
605                                  (font-lock-mode)
606                                  (font-lock-mode)))
607 ;; XEtla/howm probs
608 ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock)
609 ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock)
610 ;; ChangeLogs
611 (add-hook 'change-log-mode-hook #'font-lock-mode)
612
613 ;;:*=====================
614 ;;:* snap!
615 ;;  save/load snapshot of application to/from text
616 ;;  Usage:
617 ;; 
618 ;;  (1) M-x snap-record on application, e.g. Wanderlust.
619 ;;  (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
620 ;;  (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
621 (require 'snap)
622
623 ;;;; env var trickery.
624 (setq snap-abbreviate-environment-variables
625       '("HOME" "JAVA_HOME" "module_path"))
626
627 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
628   ad-do-it
629   (let ((path (expand-file-name raw-path))
630         (rules (mapcar #'(lambda (var)
631                            (let ((val (getenv var)))
632                              (and val
633                                   (cons (concat "^" (regexp-quote val))
634                                         (format "${%s}" var)))))
635                        snap-abbreviate-environment-variables)))
636     (mapc #'(lambda (r)
637               (when (and r (string-match (car r) path))
638                 (setq ad-return-value
639                       (replace-regexp-in-string (car r) (cdr r) path))))
640           (reverse rules))))
641
642 ;; Bookmark extras
643 (eval-after-load "bookmark"
644   (progn
645     (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
646     (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
647
648 ;; ffap extras 
649 (setq ffap-url-regexp snap-ffap-url-regexp)
650 (setq ffap-url-fetcher snap-ffap-url-fetcher)
651
652 ;:*=======================
653 ;:* ElDoc (handy thingy dingy for lisp programming)
654 ;;  displays function args and var doc strings in echo area
655 ;(setq eldoc-use-idle-timer-p nil)
656 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
657 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
658 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
659
660 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
661 (message "packages loaded")