1 ;; 11-pkgs-sy.el --- Various XE Package Settings -*- Emacs-Lisp -*-
3 ;; Copyright (C) 2007 - 2013 Steve Youngs
5 ;; Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;; Created: <2007-12-02>
8 ;; Time-stamp: <Friday Aug 16, 2013 13:27:27 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
14 ;; This file is part of SYinit
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;; notice, this list of conditions and the following disclaimer.
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.
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.
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.
45 ;; Lots of settings for various XEmacs packages that I use. Plus a
46 ;; few other packages.
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.
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.
63 ;:*======================
64 ;:* MusicPD (Not an XEmacs package)
68 "Start playing music from a randomly chosen playlist."
71 (mpd-send "load Full-sorted.playlist")
76 (defun 2001-mpd-play ()
77 "Start playing 2001 audio book."
80 (mpd-send "load 2001_A_Space_Odyssey.playlist")
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)
95 (push (cons 'override-redirect t) mpd-dock-frame-plist)
96 (push (cons 'left 1780) mpd-dock-frame-plist)
97 (push (cons 'top 5) 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)
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)
108 ; cvs-reuse-cvs-buffer 'always
109 ; cvs-add-default-message "Initial version"
110 ; cvs-allow-dir-commit t)
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"
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
124 (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
125 (set-specifier vertical-scrollbar-visible-p nil (current-buffer))))
127 ;:*=====================
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'."
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)."
149 ;:*======================
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)
157 fume-display-in-modeline-p t
158 fume-menubar-menu-location "File")
160 ;:*======================
162 (remove-hook 'font-lock-mode-hook 'turn-on-fast-lock)
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))
172 ;:*======================
174 ;; Handle automatic (de)compresion of [bg]zip files
178 ;:*======================
180 ;: A really cool package to switch buffers
182 (setq iswitchb-default-method 'samewindow)
183 (iswitchb-default-keybindings)
185 'iswitchb-define-mode-map-hook
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)))
191 ;:*======================
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)
200 ;:*======================
201 ;:* Load minibuffer history, but only if mule or file-coding is available
202 (when (featurep '(or mule file-coding))
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)))
209 ;:*======================
210 ;:* Kyle Jones' redo package.
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)
218 ;:*======================
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
225 (require 'pending-del)
226 (turn-on-pending-delete nil)
228 ;:*======================
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 (require 'newcomment)
234 (global-set-key '(control f12) 'comment-or-uncomment-region)
235 (global-set-key '(meta f12) 'uncomment-or-uncomment-region)
237 ;:*======================
238 ;:* parens that mark sexpressions
240 (paren-set-mode 'paren)
242 ;:*======================
243 ;:* easy editing of crontab files
244 (require 'crontab-edit "crontab.elc")
245 (setq crontab-delete-blank-lines nil)
246 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
247 (setq crontab-directory
248 (paths-construct-path '("spool" "cron" "crontabs") "/var"))
250 ;:*======================
251 ;:* a major mode for editing X resource database files
252 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
254 ;:*======================
258 ;:*======================
261 (setq-default filladapt-mode t)
262 (setq filladapt-fill-column-tolerance 5)
263 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
265 ;:*======================
268 speedbar-query-confirmation-method 'none-but-delete
269 speedbar-show-unknown-files t
270 speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
271 speedbar-trim-words-tag-hierarchy
272 speedbar-simple-group-tag-hierarchy
273 speedbar-sort-tag-hierarchy)
274 speedbar-track-mouse-flag t
275 speedbar-use-tool-tips-flag t
276 speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
278 (when (featurep 'menubar)
279 (add-menu-button '("Tools")
280 ["Speedbar" speedbar-frame-mode
282 :selected (and (boundp 'speedbar-frame)
283 (frame-live-p speedbar-frame)
284 (frame-visible-p speedbar-frame))]
286 (global-set-key [(f4)] 'speedbar-get-focus)
288 (require 'sb-texinfo)
289 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
290 (eval-after-load "speedbar" '(load-library "sb-html"))
291 (autoload 'w3-speedbar-buttons "sb-w3"
292 "W3 specific speedbar button generator.")
294 ;; Speedbar frame props (so I can use matched windows in Sawfish)
295 (setq speedbar-frame-plist
296 (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
297 ;:*======================
299 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
300 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
301 (add-hook 'shell-mode-hook 'turn-on-font-lock)
303 ;:*=======================
305 (setq sh-basic-offset 8)
307 ;:*======================
310 compilation-always-signal-completion t
311 mode-compile-make-program "make"
312 compilation-read-command t
313 compilation-window-height 10
314 compile-command "make")
316 ;:*======================
317 ;:* Balloon Help (now in calendar settings)
319 ;:*======================
323 vc-handled-backends '(Arch SVN GIT CVS MCVS RCS)
324 vc-follow-symlinks t)
326 ;:*======================
327 ;:* Ediff & Diff-mode
330 (setq ediff-use-toolbar-p nil ; was t but plays havoc with xwem
331 ediff-custom-diff-options "-u"
332 ediff-window-setup-function 'ediff-setup-windows-plain)
333 (setq diff-switches "-u")
335 ;:*=====================
338 (setq tramp-default-method "ssh"
339 tramp-auto-save-directory "~/.autosave/"
346 ; :*======================
348 ;(require 'pcmpl-arch)
350 eshell-ask-to-save-history 'always
351 eshell-save-history-on-exit t
352 eshell-banner-message (concat "Welcome to Eshell on "
355 (shell-command-to-string "uname -rs")
359 eshell-hist-ignoredups t
360 eshell-modules-list '(eshell-alias
377 (defun sy-eshell-bol-maybe (&optional prompt)
378 "*Move point to beginning of command or bol if there already.
379 If at bol, move point to beginning of command.
380 Optional arg, PROMPT is a regexp of your eshell prompt."
382 (let* ((prompt (or prompt "^.+ [$%] "))
383 (lbpos (point-at-bol))
384 (prspos (save-excursion
386 (search-forward-regexp prompt (point-at-eol) t)))
391 ((= cpos (or prspos 0))
396 (defun sy-eshell-bol-maybe-key ()
397 (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
399 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe)
400 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t)
401 (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color)
403 (defun sy-esh-cdl (&optional type)
404 "Eshell function to find current kernel's build or source dir.
406 Non-nil TYPE means find the current kernel's build directory, otherwise
407 find the source directory."
408 (let* ((base "/lib/modules/")
409 (ver (substring (shell-command-to-string "uname -r") 0 -1))
410 (dir (file-name-as-directory
418 "Change directory to current kernel source directory.
420 Convenience function to use with Eshell."
425 "Change directory to current kernel build directory.
427 Convenience function to use with Eshell."
431 ; :*======================
432 ; :* FFAP -- Find File At Point
438 '((global-set-key '(shift button3) 'ffap-at-mouse)
439 (global-set-key '(control shift button3) 'ffap-menu)
440 (global-set-key "\C-x\C-f" 'find-file-at-point)
441 (global-set-key "\C-x4f" 'ffap-other-window)
442 (global-set-key "\C-x5f" 'ffap-other-frame)))
443 ffap-machine-p-known 'accept
444 ffap-machine-p-unknown 'accept
445 ffap-machine-p-local 'accept)
448 (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click)
450 ;:*======================
452 (require 'auto-insert-tkld)
454 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
457 ("\\.h$" . "C Header")
458 ("\\.el$" . "Emacs Lisp")
459 ("[Mm]akefile" . "Makefile")
461 ("\\.pl$" . "Perl")))
463 (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi")
465 ("C Header" . "h-insert.h")
466 ("C++" . "c++-insert.cc")
467 ("Emacs Lisp" . "elisp-insert.el")
468 ("Makefile" . "makefile.inc")
469 ("Perl" . "perl-insert.pl")
470 ("Sh" . "sh-insert.sh")))
472 (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/")
474 ;; Don't auto-insert into AucTeX style .els
475 (defadvice TeX-auto-store (around no-auto-insert activate)
476 "Ensure auto-insert is deactivated"
477 (let ((auto-insert-automatically nil))
479 (message "Auto-Insert initialised!")
480 ;:*======================
482 ; I don't think anyone uses tla anymore
485 ; xetla-show-internal-buffers-on-menu nil
486 ; xetla-switch-to-buffer-mode 'single-window
487 ; xetla-use-arrow-keys-for-navigation t)
488 ;(defun sy-xetla-reload ()
491 ; (call-interactively 'xetla-reload)
492 ; (require 'xetla-browse)
494 ; xetla-show-internal-buffers-on-menu nil
495 ; xetla-switch-to-buffer-mode 'single-window
496 ; xetla-use-arrow-keys-for-navigation t))
498 ;:*=======================
502 ;:*======================
504 (defvar sxell-initialised-flag)
505 (defvar sxell-download-directory)
506 (when (and (featurep '(and sxemacs postgresql))
507 (fboundp 'ffi-defun))
509 (setq sxell-initialised-flag t
510 sxell-download-directory
511 (file-name-as-directory (expand-file-name "download/SXEmacs"
512 (user-home-directory)))))
513 ;:*======================
517 (defun sy-epa-export-key ()
518 "Wrapper for `epa-export-keys' to export ASCII armoured keys."
521 (call-interactively #'epa-export-keys)))
523 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
525 ;:*=======================
526 ;:* Howm thing. (this needs mule, but that is default so no biggie)
529 ;; howm has the unfortunate name that ends in `wm' which is what
530 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
531 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
533 ;; The howm people are stupid, they bind C-h to scroll-down
534 ;; Get rid of it and replace with DEL and BACKSPACE
535 (define-key howm-menu-mode-map "\C-h" nil)
536 (define-key howm-menu-mode-map [delete] #'scroll-down)
537 (define-key howm-menu-mode-map [backspace] #'scroll-down)
538 (define-key riffle-summary-mode-map "\C-h" nil)
539 (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down)
540 (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down)
541 (define-key riffle-contents-mode-map "\C-h" nil)
542 (define-key riffle-contents-mode-map [delete] #'scroll-down)
543 (define-key riffle-contents-mode-map [backspace] #'scroll-down)
545 ;; Add a binding to show the active todo list
546 (global-set-key [(control ?c) ?t] #'howm-list-active-todo)
548 ;; Another problem with howm... it fucks up window configuration
549 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
550 "Save window configuration before viewing howm buffers."
551 (window-configuration-to-register ?h))
553 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
554 "Save window configuration before viewing howm buffers."
555 (window-configuration-to-register ?h))
557 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
558 "Save window configuration before viewing howm buffers."
559 (window-configuration-to-register ?h))
561 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
562 "Save window configuration before viewing howm buffers."
563 (window-configuration-to-register ?h))
565 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
566 "Save window configuration before viewing howm buffers."
567 (window-configuration-to-register ?h))
569 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
570 "Restore the original window configuration."
571 (jump-to-register ?h))
573 (setq howm-directory "~/.howm")
575 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
576 ;; call to `turn-on-font-lock' here at least restores a certain level
578 (defun turn-on-howm-mode ()
582 (defun turn-off-howm-mode ()
585 ;; Turn it on where I need it
586 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
587 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
588 ;; compiling the generated .el
589 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
590 (add-hook 'text-mode-hook #'turn-on-howm-mode)
591 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
592 (add-hook 'c-mode-hook #'turn-on-howm-mode)
593 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
595 ;; Turn it off where I don't
596 (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode)
597 (add-hook 'html-mode-hook #'turn-off-howm-mode)
598 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
600 ;;; Various other howm problem fixes
602 ;; I'm having a big problem with howm/font-lock/message-mode playing
603 ;; nicely together. This gives me font-locking in message-mode, plus
604 ;; howm functionality, but no howm font-locking. I can live without
605 ;; howm font-lock in one buffer.
606 (add-hook 'message-mode-hook #'(lambda ()
610 ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock)
611 ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock)
613 (add-hook 'change-log-mode-hook #'font-lock-mode)
615 ;;:*=====================
617 ;; save/load snapshot of application to/from text
620 ;; (1) M-x snap-record on application, e.g. Wanderlust.
621 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
622 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
625 ;;;; env var trickery.
626 (setq snap-abbreviate-environment-variables
627 '("HOME" "JAVA_HOME" "module_path"))
629 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
631 (let ((path (expand-file-name raw-path))
632 (rules (mapcar #'(lambda (var)
633 (let ((val (getenv var)))
635 (cons (concat "^" (regexp-quote val))
636 (format "${%s}" var)))))
637 snap-abbreviate-environment-variables)))
639 (when (and r (string-match (car r) path))
640 (setq ad-return-value
641 (replace-regexp-in-string (car r) (cdr r) path))))
645 (eval-after-load "bookmark"
647 (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
648 (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
651 (setq ffap-url-regexp snap-ffap-url-regexp)
652 (setq ffap-url-fetcher snap-ffap-url-fetcher)
654 ;:*=======================
655 ;:* ElDoc (handy thingy dingy for lisp programming)
656 ;; displays function args and var doc strings in echo area
657 ;(setq eldoc-use-idle-timer-p nil)
658 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
659 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
660 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
662 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
663 (message "packages loaded")