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