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