Loads more updates -- large assortment of stuffs
[syinit] / 10-pkgs-sy.el
1 ;; 10-pkgs-sy.el --- Various XE Package Settings   -*- Emacs-Lisp -*-
2
3 ;; Copyright (C) 2007 - 2020 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: <Thursday Mar 19, 2020 12:15:35 steve>
9 ;;   Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;;   HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/10-pkgs-sy.html>
11 ;;   Git Repo: git clone https://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, although I do
51 ;;   have overlay.el from there.  It just makes my life a tad easier.
52
53 ;;; Credits:
54 ;;
55 ;;   The HTML version of this file was created with Hrvoje Niksic's
56 ;;   htmlize.el which is part of the XEmacs "text-modes" package.
57 ;;
58
59 ;;; Todo:
60 ;;
61 ;;
62
63 ;;; Code:
64 ;:*======================
65 ;:* MusicPD  (Not an XEmacs package)
66 (require 'mpd)
67
68 (defun sy-mpd-play ()
69   "Start playing music from a randomly chosen playlist."
70   (interactive)
71   (mpd-send "clear")
72   (mpd-send "load Full-sorted.playlist")
73   (mpd-send "random 1")
74   (mpd-send "repeat 1")
75   (mpd-playpause))
76
77 (defun 2001-mpd-play ()
78   "Start playing 2001 audio book."
79   (interactive)
80   (mpd-send "clear")
81   (mpd-send "load 2001_A_Space_Odyssey.playlist")
82   (mpd-send "random 0")
83   (mpd-send "repeat 0")
84   (mpd-playpause))
85
86 ;; Audio keybindings
87 (global-set-key [XF86AudioPlay] #'mpd-playpause)
88 (global-set-key [XF86AudioStop] #'mpd-stop)
89 (global-set-key [XF86AudioNext] #'mpd-next-track)
90 (global-set-key [XF86AudioPrev] #'mpd-previous-track)
91 (global-set-key [XF86AudioRaiseVolume] #'mpd-volume-up)
92 (global-set-key [XF86AudioLowerVolume] #'mpd-volume-down)
93 (global-set-key [XF86AudioMute] #'mpd-volume-mute/unmute)
94
95 ;; Mpd frame props
96 (unless (or (string= (getenv "KDE_FULL_SESSION") "true")
97             (string= (getenv "SAWFISH_IS_RUNNING") "true"))
98   (push (cons 'override-redirect t) mpd-dock-frame-plist))
99 (push (cons 'left 1780) mpd-dock-frame-plist)
100 (push (cons 'top 5) mpd-dock-frame-plist)
101 (push (cons 'internal-border-width 4) mpd-dock-frame-plist)
102 (push (cons 'border-width 1) mpd-dock-frame-plist)
103 (push (cons 'border-color "red") mpd-dock-frame-plist)
104
105 ;:*======================
106 ;:* View-process (`top' for emacs)
107 (require 'view-process-mode)
108 (setq View-process-host-names-and-system-types
109       '(("bastard.steveyoungs.com"
110          ("linux" nil "bsd"
111           View-process-field-name-descriptions-linux
112           View-process-kill-signals-linux))))
113 (setq View-process-status-command-switches-system-v "auxw")
114 (setq View-process-ps-header-window-offset 3)
115 (add-hook 'View-process-header-mode-hook
116           (lambda ()
117             (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
118             (set-specifier vertical-scrollbar-visible-p nil (current-buffer))))
119
120 ;:*=====================
121 ;:* whitespace-mode
122 (autoload 'whitespace-mode "whitespace-mode" nil t)
123 (autoload 'whitespace-incremental-mode "whitespace-mode" nil t)
124
125 ;:*======================
126 ;:* func-menu
127 (require 'func-menu)
128 (add-hook 'find-file-hooks 'fume-setup-buffer)
129 (add-hook 'Manual-mode-hook 'turn-on-fume-mode)
130 (define-key fume-mode-map [(control button3)] #'mouse-function-menu)
131 (setq
132  fume-display-in-modeline-p t
133  fume-menu-path '("View"))
134
135 ;:*======================
136 ;:* recent-files.el --- Maintain menu of recently opened files.
137 (when (featurep 'menubar)
138   (require 'recent-files)
139   (setq recent-files-non-permanent-submenu t
140         recent-files-menu-path '("File")
141         recent-files-add-menu-before "Insert File..."
142         recent-files-save-file
143         (expand-file-name ".recent-files.el" user-init-directory)
144         recent-files-dont-include
145         '(#r"\.config/sxemacs/\(howm\|diary\).*$"
146           #r"sxemacs/timelog$"
147           #r"info/dir$"
148           #r"\.\(newsrc*\|bbdb\)$"
149           #r"init\.d\.el"))
150   (recent-files-initialize))
151
152 ;:*======================
153 ;:* jka-compr
154 ;; Handle automatic (de)compresion of [bg]zip files
155 (require 'jka-compr)
156 (jka-compr-install)
157
158 ;:*======================
159 ;:* iswitchb
160 ;: A really cool package to switch buffers
161 (require 'iswitchb)
162 (setq iswitchb-default-method 'samewindow)
163 (iswitchb-default-keybindings)
164 (add-hook
165  'iswitchb-define-mode-map-hook
166  '(lambda ()
167     (define-key iswitchb-mode-map " " 'iswitchb-next-match)
168     (define-key iswitchb-mode-map [(control ?\ )] 'iswitchb-prev-match)
169     (define-key iswitchb-mode-map "\C-a" 'iswitchb-toggle-ignore)))
170
171 ;:*======================
172 ;:* backup
173 ;:  move all backups in one directory
174 (require 'backup-dir)
175 (setq bkup-backup-directory-info
176       '((t "~/.autosave/" ok-create full-path)))
177 (setq version-control 'preserve-prefer-numbered)
178 (setq-default delete-old-versions t)
179
180 ;:*======================
181 ;:* Load minibuffer history, but only if mule or file-coding is available
182 (when (featurep '(or mule file-coding))
183   (require 'savehist)
184   (setq savehist-file (expand-file-name "history" user-init-directory))
185   (setq savehist-coding-system
186         (coding-system-name (find-coding-system 'iso-8859-1)))
187   (savehist-mode 1))
188
189 ;:*======================
190 ;:* Kyle Jones' redo package.
191 (when running-xemacs
192   (require 'redo)
193   (global-set-key [(control f2)] 'redo))
194
195 (require 'scroll-in-place)
196
197 ;:*======================
198 ;:* pending-del
199 ;:  Non-nil when Pending Delete mode is enabled. In Pending Delete mode, typed
200 ;:  text replaces the selected region. Normally, you shouldn't modify this
201 ;:  variable by hand, but use the function `pending-delete-mode' instead. However,
202 ;:  you can customize the default value from the options menu (auto delete
203 ;:  selection).
204 (require 'pending-del)
205 (turn-on-pending-delete nil)
206
207 ;:*======================
208 ;:* comment-region
209 ;:  Comment or uncomment each line in the region.
210 ;:  Comments are terminated on each line, even for syntax in which newline does
211 ;:  not end the comment.  Blank lines do not get comments.
212 (require 'newcomment)
213 (global-set-key '(control f12)  'comment-or-uncomment-region)
214 (global-set-key '(meta f12) 'comment-or-uncomment-region)
215
216 ;;; FIXME: <<< SXEInits
217 ;:*======================
218 ;:* parens that mark sexpressions
219 (require 'paren)
220 (paren-set-mode 'paren)
221
222 ;:*======================
223 ;:* easy editing of crontab files
224 (require 'crontab-edit "crontab.elc")
225 (setq crontab-delete-blank-lines nil)
226 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
227 (setq crontab-directory
228       (paths-construct-path '("spool" "cron" "crontabs") "/var"))
229
230 ;:*======================
231 ;:* a major mode for editing X resource database files
232 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
233
234 ;:*======================
235 ;:* Footnote package
236 (require 'footnote)
237
238 ;:*======================
239 ;:* Filladapt-Mode
240 (require 'filladapt)
241 (setq-default filladapt-mode t)
242 (setq filladapt-fill-column-tolerance 5)
243 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
244
245 ;:*======================
246 ;:* Speedbar
247 ;;; FIXME: <<< Speedbar Tooltips
248 ;;; >>> ~/programming/SXEmacs/packages/xemacs-packages/speedbar/speedbar.el
249 (setq
250  speedbar-query-confirmation-method 'none-but-delete
251  speedbar-show-unknown-files t
252  speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
253                                  speedbar-trim-words-tag-hierarchy
254                                  speedbar-simple-group-tag-hierarchy
255                                  speedbar-sort-tag-hierarchy)
256  ;; speedbar-track-mouse-flag t
257  ;; speedbar-use-tool-tips-flag t
258  speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
259
260 (when (featurep 'menubar)
261   (add-menu-button '("Tools")
262                    ["Speedbar" speedbar-frame-mode
263                     :style toggle
264                     :selected (and (boundp 'speedbar-frame)
265                                    (frame-live-p speedbar-frame)
266                                    (frame-visible-p speedbar-frame))]
267                    "--"))
268 (global-set-key [(f4)] 'speedbar-get-focus)
269 (require 'sb-image)
270 (require 'sb-info)
271 (require 'sb-texinfo)
272 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
273 (eval-after-load "speedbar" '(load-library "sb-html"))
274 (autoload 'w3-speedbar-buttons "sb-w3"
275   "W3 specific speedbar button generator.")
276
277 ;;; Speedbar frame props
278 ;;  'name' (so I can use matched windows in Sawfish)
279 (setq speedbar-frame-plist
280       (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
281 ;; No scrollbars
282 (setq speedbar-frame-plist
283       (plist-put speedbar-frame-plist 'scrollbar-height 0))
284 (setq speedbar-frame-plist
285       (plist-put speedbar-frame-plist 'scrollbar-width 0))
286 ;; A little wider than default
287 (setq speedbar-frame-plist
288       (plist-put speedbar-frame-plist 'width 25))
289
290 ;; FIXME: see... <<< PKGFix
291 ;; Try to load the speedbar on the right of the current frame
292 (defalias 'dframe-reposition-frame-xemacs 'dframe-reposition-frame-emacs)
293 (setq speedbar-default-position 'right)
294
295 ;; Speedbar only does the repositioning thing if the frame has to be
296 ;; created.  If you have only closed the speedbar frame with 'q'
297 ;; instead of deleting it with 'Q' then the frame remains live.  As
298 ;; there is no perceptible speed difference of coming back from
299 ;; either a closed or deleted speedbar frame the following will
300 ;; force a delete-frame even if you are only closing it.
301 (defun sy-speedbar-kill ()
302   (when (frame-live-p speedbar-frame)
303     (delete-frame speedbar-frame)))
304
305 (add-hook 'speedbar-before-delete-hook #'sy-speedbar-kill)
306
307
308 ;:*======================
309 ;:* Shell-mode
310 ;; Trying to get compilation buffers to recognise ANSI colour
311 ;; sequences because GCC.  Doesn't seem to work.  Probably have to
312 ;; stick to `GCC_COLORS= make'
313 (defun sy/comint-hooks ()
314   (ansi-color-for-comint-mode-on)
315   (fast-lock-mode 1)
316   (font-lock-mode 1))
317 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
318 (add-hook 'comint-mode-hook #'sy/comint-hooks)
319 (add-hook 'compilation-mode-hook #'sy/comint-hooks)
320 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
321 (add-hook 'shell-mode-hook 'turn-on-font-lock)
322
323 ;:*=======================
324 ;:* Shell-script
325 (setq sh-basic-offset 4)
326
327 ;:*======================
328 ;:* Compile-Mode
329 (setq
330  compilation-always-signal-completion t
331  mode-compile-make-program "GCC_COLORS= make"
332  compilation-read-command t
333  compilation-window-height 10
334  compile-command "GCC_COLORS= make")
335
336 ;:*======================
337 ;:* Version Control
338 (vc-load-vc-hooks)
339 ;; #'vc-load-vc-hooks brings in vc-xemacs which adds this hook. I
340 ;; would never need it.
341 (remove-hook 'find-file-hooks 'vc-xemacs-hg-find-file-hook)
342 (setq
343  ;; I pretty much only use git now so there's no point in VC trying to
344  ;; handle any other type.
345  vc-handled-backends '(GIT)
346  vc-follow-symlinks t)
347
348 ;:*======================
349 ;:* Ediff & Diff-mode
350 (require 'ediff)
351 (require 'diff-mode)
352 (setq ediff-use-toolbar-p t
353       ediff-custom-diff-options "-u"
354       ediff-window-setup-function 'ediff-setup-windows-plain)
355 (setq diff-switches "-u")
356
357 ;:*=====================
358 ;:* Tramp
359 (require 'tramp)
360 (setq tramp-default-method "ssh"
361       tramp-auto-save-directory "~/.autosave/"
362       tramp-remote-path
363       '("/usr/lib/pkgusr"
364         "/usr/bin"
365         "/bin"
366         "/usr/X11R6/bin"))
367
368 ; :*======================
369 ; :* Eshell
370 (setq
371  eshell-directory-name
372  (file-name-as-directory
373   (expand-file-name "eshell" user-init-directory))
374  eshell-ask-to-save-history 'always
375  eshell-save-history-on-exit t
376  eshell-banner-message (concat "Welcome to Eshell on "
377                                (system-name)
378                                ", running "
379                                (shell-command-to-string "uname -rs")
380                                "In: "
381                                emacs-version
382                                "\n\n")
383  eshell-hist-ignoredups t
384  eshell-modules-list '(eshell-alias
385                        eshell-banner
386                        eshell-basic
387                        eshell-cmpl
388                        eshell-dirs
389                        eshell-glob
390                        eshell-hist
391                        eshell-ls
392                        eshell-pred
393                        eshell-prompt
394                        ;eshell-rebind
395                        eshell-script
396                        ;eshell-smart
397                        eshell-term
398                        eshell-unix
399                        eshell-xtra))
400
401 (defun sy-eshell-bol-maybe (&optional prompt)
402   "*Move point to beginning of command or bol if there already.
403  If at bol, move point to beginning of command.
404  Optional arg, PROMPT is a regexp of your eshell prompt."
405   (interactive)
406   (let* ((prompt (or prompt "^.+ [$%] "))
407          (lbpos (point-at-bol))
408          (prspos (save-excursion
409                    (goto-char lbpos)
410                    (search-forward-regexp prompt (point-at-eol) t)))
411          (cpos (point)))
412     (goto-char
413      (cond ((null prspos)
414             lbpos)
415            ((= cpos (or prspos 0))
416             lbpos)
417            (prspos)
418            (t lbpos)))))
419
420 (defun sy-eshell-bol-maybe-key ()
421   (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
422
423 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe)
424 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t)
425 (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color)
426
427 (defun sy-esh-cdl (&optional type)
428   "Eshell function to find current kernel's build or source dir.
429
430  Non-nil TYPE means find the current kernel's build directory, otherwise
431  find the source directory."
432   (let* ((base "/lib/modules/")
433          (ver (substring (shell-command-to-string "uname -r") 0 -1))
434          (dir (file-name-as-directory
435                (concat base ver "/"
436                        (if type
437                            "build"
438                          "source")))))
439     (cd dir)))
440
441 (defun cdls ()
442   "Change directory to current kernel source directory.
443
444  Convenience function to use with Eshell."
445   (interactive)
446   (sy-esh-cdl))
447
448 (defun cdlb ()
449   "Change directory to current kernel build directory.
450
451  Convenience function to use with Eshell."
452   (interactive)
453   (sy-esh-cdl 'build))
454
455 ; :*======================
456 ; :* FFAP -- Find File At Point
457 (require 'ffap)
458
459 ;; Make sure ffap does NOT get in my way...
460 (setq ffap-bindings nil)
461
462 (global-set-key [f3] #'find-file-at-point)
463 (global-set-key [(control x) ?4 f3] #'ffap-other-window)
464 (global-set-key [(control x) ?5 f3] #'ffap-other-frame)
465 (global-set-key [(shift button3)] #'ffap-at-mouse)
466 (global-set-key [(control shift button3)] #'ffap-menu)
467
468 (setq
469  ffap-machine-p-known 'accept
470  ffap-machine-p-unknown 'accept
471  ffap-machine-p-local 'accept)
472
473
474 ;:*======================
475 ;:* Auto-Insert
476 (require 'auto-insert-tkld)
477
478 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
479                           ("\\.c$"              . "C")
480                           ("\\.cc$"             . "C++")
481                           ("\\.h$"              . "C Header")
482                           ("\\.el$"             . "Emacs Lisp")
483                           ("[Mm]akefile"        . "Makefile")
484                           ("\\.sh$"             . "Sh")
485                           ("\\.pl$"             . "Perl")))
486
487 (setq auto-insert-type-alist '(("TeXinfo"    . "texinfo-insert.texi")
488                                ("C"          . "c-insert.c")
489                                ("C Header"   . "h-insert.h")
490                                ("C++"        . "c++-insert.cc")
491                                ("Emacs Lisp" . "elisp-insert.el")
492                                ("Makefile"   . "makefile.inc")
493                                ("Perl"       . "perl-insert.pl")
494                                ("Sh"         . "sh-insert.sh")))
495
496 (add-to-list 'auto-insert-path '"~/documents/Templates/")
497
498 ;; Don't auto-insert into AucTeX style .els
499 (defadvice TeX-auto-store (around no-auto-insert activate)
500   "Ensure auto-insert is deactivated"
501   (let ((auto-insert-automatically nil))
502     ad-do-it))
503 (message "Auto-Insert initialised!")
504
505 ;:*=======================
506 ;:* My git shit
507 (require 'sy-git)
508 (require 'git)
509
510 ;:*======================
511 ;:* Emacs Lisp List
512 (defvar sxell-initialised-flag)
513 (defvar sxell-download-directory)
514 (when (and (featurep '(and sxemacs postgresql))
515            (fboundp 'ffi-defun))
516   (require 'sxell)
517   (setq sxell-initialised-flag t
518         sxell-download-directory
519         (file-name-as-directory (expand-file-name "download/SXEmacs"
520                                                   (user-home-directory)))))
521 ;:*======================
522 ;:* EasyPG
523 (require 'epa-setup)
524
525 (defun sy-epa-export-key ()
526   "Wrapper for `epa-export-keys' to export ASCII armoured keys."
527   (interactive)
528   (let ((epa-armor t))
529     (call-interactively #'epa-export-keys)))
530
531 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
532
533 ;:*=======================
534 ;:* Howm thing. (this needs mule, but that is default so no biggie)
535 (require 'howm)
536
537 (setq
538  howm-directory (file-name-as-directory
539                  (expand-file-name "howm" user-init-directory))
540  howm-keyword-file (expand-file-name "howm-keys" user-init-directory)
541  howm-history-file (expand-file-name "howm-history" user-init-directory))
542
543 ;; howm has the unfortunate name that ends in `wm' which is what
544 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
545 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
546
547 ;; The howm people are stupid, they bind C-h to scroll-down
548 ;; Get rid of it and replace with DEL and BACKSPACE
549 (define-key howm-menu-mode-map "\C-h" nil)
550 (define-key howm-menu-mode-map [delete] #'scroll-down)
551 (define-key howm-menu-mode-map [backspace] #'scroll-down)
552 (define-key riffle-summary-mode-map "\C-h" nil)
553 (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down)
554 (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down)
555 (define-key riffle-contents-mode-map "\C-h" nil)
556 (define-key riffle-contents-mode-map [delete] #'scroll-down)
557 (define-key riffle-contents-mode-map [backspace] #'scroll-down)
558
559 ;; Add a binding to show the active todo list
560 (global-set-key [(control ?c) ?t] #'howm-list-active-todo)
561
562 ;; Another problem with howm... it fucks up window configuration
563 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
564  "Save window configuration before viewing howm buffers."
565  (window-configuration-to-register ?h))
566
567 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
568  "Save window configuration before viewing howm buffers."
569  (window-configuration-to-register ?h))
570
571 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
572  "Save window configuration before viewing howm buffers."
573  (window-configuration-to-register ?h))
574
575 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
576  "Save window configuration before viewing howm buffers."
577  (window-configuration-to-register ?h))
578
579 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
580  "Save window configuration before viewing howm buffers."
581  (window-configuration-to-register ?h))
582
583 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
584   "Restore the original window configuration."
585   (jump-to-register ?h))
586
587 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
588 ;; call to `turn-on-font-lock' here at least restores a certain level
589 ;; of normalcy.
590 (defun turn-on-howm-mode ()
591   (turn-on-font-lock)
592   (howm-mode 1))
593
594 (defun turn-off-howm-mode ()
595   (howm-mode 0))
596
597 ;; Turn it on where I need it
598 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
599 (add-hook 'text-mode-hook #'turn-on-howm-mode)
600 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
601 (add-hook 'c-mode-hook #'turn-on-howm-mode)
602 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
603 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
604 ;; compiling the generated .el (moved to init.el)
605 ;;;;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
606
607 ;; Turn it off where I don't
608 (add-hook 'html-mode-hook #'turn-off-howm-mode)
609 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
610
611 ;; Various other howm problem fixes
612
613 ;; I'm having a big problem with howm/font-lock/message-mode playing
614 ;; nicely together.  This gives me font-locking in message-mode, plus
615 ;; howm functionality, but no howm font-locking.  I can live without
616 ;; howm font-lock in one buffer.
617 (add-hook 'message-mode-hook #'(lambda ()
618                                  (font-lock-mode)
619                                  (font-lock-mode)))
620 ;; ChangeLogs
621 (add-hook 'change-log-mode-hook #'font-lock-mode)
622
623 ;:*=====================
624 ;:* snap!
625 ;; save/load snapshot of application to/from text
626 ;; Usage:
627
628 ;; (1) M-x snap-record on application, e.g. Wanderlust.
629 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
630 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
631 (require 'snap)
632 (global-set-key [(hyper ?s) ?r] #'snap-record)
633
634 ;; env var trickery.
635 (setq snap-abbreviate-environment-variables
636       '("EMCHAT" "JAVA_HOME" "LISP" "PKGS" "QTDIR"
637         "SXEBLD" "SXESITE" "SXEWD" "SYdrive" "SYdrop" "HOME"))
638
639 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
640   ad-do-it
641   (let ((path (expand-file-name raw-path))
642         (rules (mapcar #'(lambda (var)
643                            (let ((val (getenv var)))
644                              (and val
645                                   (cons (concat "^" (regexp-quote val))
646                                         (format "${%s}" var)))))
647                        snap-abbreviate-environment-variables)))
648     (mapc #'(lambda (r)
649               (when (and r (string-match (car r) path))
650                 (setq ad-return-value
651                       (replace-regexp-in-string (car r) (cdr r) path))))
652           (reverse rules))))
653
654 ;; Bookmark extras
655 (eval-after-load "bookmark"
656   (progn
657     (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
658     (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
659
660 ;; ffap extras
661 (setq ffap-url-regexp snap-ffap-url-regexp)
662 (setq ffap-url-fetcher snap-ffap-url-fetcher)
663
664 ;:*=======================
665 ;:* ElDoc (handy thingy dingy for lisp programming)
666 ;;  displays function args and var doc strings in echo area
667 ;(setq eldoc-use-idle-timer-p nil)
668 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
669 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
670 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
671
672 ;:*=======================
673 ;:* Man pages
674 (require 'man)
675
676 ;; You can't follow xrefs via keyboard, so...
677 (defun sy:Manual-follow-xref-kbd ()
678   "Invoke `manual-entry' on the cross-reference at point."
679   (interactive)
680   (let* ((ext (extent-at (point)))
681          (data (and ext (extent-property ext 'man))))
682     (if (eq (car-safe data) 'Manual-follow-xref)
683         (eval data)
684       (error 'search-failed "no manual cross-reference there."))
685     (or (manual-entry (extent-string ext))
686         ;; Couldn't find it, try other sections.
687         (and (string-match "[ \t]*([^)]+)\\'" (extent-string ext))
688              (progn
689                (message "No entries found for %s; checking other sections..."
690                         (extent-string ext))
691                (manual-entry
692                 (substring (extent-string ext) 0 (match-beginning 0))
693                 nil t))))))
694
695 (define-key Manual-mode-map [(control return)] #'sy:Manual-follow-xref-kbd)
696 (define-key Manual-mode-map [button1] #'Manual-follow-xref)
697
698 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
699 (message "packages loaded")