1 ;; 11-pkgs-sy.el --- Various XE Package Settings -*- Emacs-Lisp -*-
3 ;; Copyright (C) 2007 - 2012 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 Jun 29, 2012 19:25:52 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 1568) mpd-dock-frame-plist)
97 (push (cons 'top 360) mpd-dock-frame-plist)
98 (push (cons 'internal-border-width 4) mpd-dock-frame-plist)
99 (push (cons 'border-width 1) mpd-dock-frame-plist)
100 (push (cons 'border-color "red") mpd-dock-frame-plist)
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 (global-set-key '(control f12) 'comment-region)
234 (global-set-key '(meta f12) 'uncomment-region)
236 ;:*======================
237 ;:* parens that mark sexpressions
239 (paren-set-mode 'paren)
241 ;:*======================
242 ;:* easy editing of crontab files
243 (require 'crontab-edit "crontab.elc")
244 (setq crontab-delete-blank-lines nil)
245 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
246 (setq crontab-directory
247 (paths-construct-path '("spool" "cron" "crontabs") "/var"))
249 ;:*======================
250 ;:* a major mode for editing X resource database files
251 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
253 ;:*======================
257 ;:*======================
260 (setq-default filladapt-mode t)
261 (setq filladapt-fill-column-tolerance 5)
262 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
264 ;:*======================
267 speedbar-query-confirmation-method 'none-but-delete
268 speedbar-show-unknown-files t
269 speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
270 speedbar-trim-words-tag-hierarchy
271 speedbar-simple-group-tag-hierarchy
272 speedbar-sort-tag-hierarchy)
273 speedbar-track-mouse-flag t
274 speedbar-use-tool-tips-flag t
275 speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
277 (when (featurep 'menubar)
278 (add-menu-button '("Tools")
279 ["Speedbar" speedbar-frame-mode
281 :selected (and (boundp 'speedbar-frame)
282 (frame-live-p speedbar-frame)
283 (frame-visible-p speedbar-frame))]
285 (global-set-key [(f4)] 'speedbar-get-focus)
287 (require 'sb-texinfo)
288 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
289 (eval-after-load "speedbar" '(load-library "sb-html"))
290 (autoload 'w3-speedbar-buttons "sb-w3"
291 "W3 specific speedbar button generator.")
293 ;; Speedbar frame props (so I can use matched windows in Sawfish)
294 (setq speedbar-frame-plist
295 (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
296 ;:*======================
298 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
299 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
300 (add-hook 'shell-mode-hook 'turn-on-font-lock)
302 ;:*=======================
304 (setq sh-basic-offset 8)
306 ;:*======================
309 compilation-always-signal-completion t
310 mode-compile-make-program "make"
311 compilation-read-command t
312 compilation-window-height 10
313 compile-command "make")
315 ;:*======================
316 ;:* Balloon Help (now in calendar settings)
318 ;:*======================
322 vc-handled-backends '(Arch SVN GIT CVS MCVS RCS)
323 vc-follow-symlinks t)
325 ;:*======================
326 ;:* Ediff & Diff-mode
329 (setq ediff-use-toolbar-p nil ; was t but plays havoc with xwem
330 ediff-custom-diff-options "-u"
331 ediff-window-setup-function 'ediff-setup-windows-plain)
332 (setq diff-switches "-u")
334 ;:*=====================
337 (setq tramp-default-method "ssh"
338 tramp-auto-save-directory "~/.autosave/"
345 ; :*======================
347 ;(require 'pcmpl-arch)
349 eshell-ask-to-save-history 'always
350 eshell-save-history-on-exit t
351 eshell-banner-message (concat "Welcome to Eshell on "
354 (shell-command-to-string "uname -rs")
358 eshell-hist-ignoredups t
359 eshell-modules-list '(eshell-alias
376 (defun sy-eshell-bol-maybe (&optional prompt)
377 "*Move point to beginning of command or bol if there already.
378 If at bol, move point to beginning of command.
379 Optional arg, PROMPT is a regexp of your eshell prompt."
381 (let* ((prompt (or prompt "^.+ [$%] "))
382 (lbpos (point-at-bol))
383 (prspos (save-excursion
385 (search-forward-regexp prompt (point-at-eol) t)))
390 ((= cpos (or prspos 0))
395 (defun sy-eshell-bol-maybe-key ()
396 (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
398 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe)
399 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t)
400 (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color)
402 (defun sy-esh-cdl (&optional type)
403 "Eshell function to find current kernel's build or source dir.
405 Non-nil TYPE means find the current kernel's build directory, otherwise
406 find the source directory."
407 (let* ((base "/lib/modules/")
408 (ver (substring (shell-command-to-string "uname -r") 0 -1))
409 (dir (file-name-as-directory
417 "Change directory to current kernel source directory.
419 Convenience function to use with Eshell."
424 "Change directory to current kernel build directory.
426 Convenience function to use with Eshell."
430 ; :*======================
431 ; :* FFAP -- Find File At Point
437 '((global-set-key '(shift button3) 'ffap-at-mouse)
438 (global-set-key '(control shift button3) 'ffap-menu)
439 (global-set-key "\C-x\C-f" 'find-file-at-point)
440 (global-set-key "\C-x4f" 'ffap-other-window)
441 (global-set-key "\C-x5f" 'ffap-other-frame)))
442 ffap-machine-p-known 'accept
443 ffap-machine-p-unknown 'accept
444 ffap-machine-p-local 'accept)
447 (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click)
449 ;:*======================
451 (require 'auto-insert-tkld)
453 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
456 ("\\.h$" . "C Header")
457 ("\\.el$" . "Emacs Lisp")
458 ("[Mm]akefile" . "Makefile")
460 ("\\.pl$" . "Perl")))
462 (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi")
464 ("C Header" . "h-insert.h")
465 ("C++" . "c++-insert.cc")
466 ("Emacs Lisp" . "elisp-insert.el")
467 ("Makefile" . "makefile.inc")
468 ("Perl" . "perl-insert.pl")
469 ("Sh" . "sh-insert.sh")))
471 (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/")
473 ;; Don't auto-insert into AucTeX style .els
474 (defadvice TeX-auto-store (around no-auto-insert activate)
475 "Ensure auto-insert is deactivated"
476 (let ((auto-insert-automatically nil))
478 (message "Auto-Insert initialised!")
479 ;:*======================
481 ; I don't think anyone uses tla anymore
484 ; xetla-show-internal-buffers-on-menu nil
485 ; xetla-switch-to-buffer-mode 'single-window
486 ; xetla-use-arrow-keys-for-navigation t)
487 ;(defun sy-xetla-reload ()
490 ; (call-interactively 'xetla-reload)
491 ; (require 'xetla-browse)
493 ; xetla-show-internal-buffers-on-menu nil
494 ; xetla-switch-to-buffer-mode 'single-window
495 ; xetla-use-arrow-keys-for-navigation t))
497 ;:*=======================
501 ;:*======================
503 (defvar sxell-initialised-flag)
504 (defvar sxell-download-directory)
505 (when (and (featurep '(and sxemacs postgresql))
506 (fboundp 'ffi-defun))
508 (setq sxell-initialised-flag t
509 sxell-download-directory
510 (file-name-as-directory (expand-file-name "download/SXEmacs"
511 (user-home-directory)))))
512 ;:*======================
516 (defun sy-epa-export-key ()
517 "Wrapper for `epa-export-keys' to export ASCII armoured keys."
520 (call-interactively #'epa-export-keys)))
522 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
524 ;:*=======================
525 ;:* Howm thing. (this needs mule, but that is default so no biggie)
528 ;; howm has the unfortunate name that ends in `wm' which is what
529 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
530 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
532 ;; The howm people are stupid, they bind C-h to scroll-down
533 ;; Get rid of it and replace with DEL and BACKSPACE
534 (define-key howm-menu-mode-map "\C-h" nil)
535 (define-key howm-menu-mode-map [delete] #'scroll-down)
536 (define-key howm-menu-mode-map [backspace] #'scroll-down)
537 (define-key riffle-summary-mode-map "\C-h" nil)
538 (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down)
539 (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down)
540 (define-key riffle-contents-mode-map "\C-h" nil)
541 (define-key riffle-contents-mode-map [delete] #'scroll-down)
542 (define-key riffle-contents-mode-map [backspace] #'scroll-down)
544 ;; Add a binding to show the active todo list
545 (global-set-key [(control ?c) ?t] #'howm-list-active-todo)
547 ;; Another problem with howm... it fucks up window configuration
548 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
549 "Save window configuration before viewing howm buffers."
550 (window-configuration-to-register ?h))
552 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
553 "Save window configuration before viewing howm buffers."
554 (window-configuration-to-register ?h))
556 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
557 "Save window configuration before viewing howm buffers."
558 (window-configuration-to-register ?h))
560 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
561 "Save window configuration before viewing howm buffers."
562 (window-configuration-to-register ?h))
564 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
565 "Save window configuration before viewing howm buffers."
566 (window-configuration-to-register ?h))
568 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
569 "Restore the original window configuration."
570 (jump-to-register ?h))
572 (setq howm-directory "~/.howm")
574 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
575 ;; call to `turn-on-font-lock' here at least restores a certain level
577 (defun turn-on-howm-mode ()
581 (defun turn-off-howm-mode ()
584 ;; Turn it on where I need it
585 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
586 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
587 ;; compiling the generated .el
588 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
589 (add-hook 'text-mode-hook #'turn-on-howm-mode)
590 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
591 (add-hook 'c-mode-hook #'turn-on-howm-mode)
592 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
594 ;; Turn it off where I don't
595 (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode)
596 (add-hook 'html-mode-hook #'turn-off-howm-mode)
597 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
599 ;;; Various other howm problem fixes
601 ;; I'm having a big problem with howm/font-lock/message-mode playing
602 ;; nicely together. This gives me font-locking in message-mode, plus
603 ;; howm functionality, but no howm font-locking. I can live without
604 ;; howm font-lock in one buffer.
605 (add-hook 'message-mode-hook #'(lambda ()
609 ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock)
610 ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock)
612 (add-hook 'change-log-mode-hook #'font-lock-mode)
614 ;;:*=====================
616 ;; save/load snapshot of application to/from text
619 ;; (1) M-x snap-record on application, e.g. Wanderlust.
620 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
621 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
624 ;;;; env var trickery.
625 (setq snap-abbreviate-environment-variables
626 '("HOME" "JAVA_HOME" "module_path"))
628 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
630 (let ((path (expand-file-name raw-path))
631 (rules (mapcar #'(lambda (var)
632 (let ((val (getenv var)))
634 (cons (concat "^" (regexp-quote val))
635 (format "${%s}" var)))))
636 snap-abbreviate-environment-variables)))
638 (when (and r (string-match (car r) path))
639 (setq ad-return-value
640 (replace-regexp-in-string (car r) (cdr r) path))))
644 (eval-after-load "bookmark"
646 (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
647 (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
650 (setq ffap-url-regexp snap-ffap-url-regexp)
651 (setq ffap-url-fetcher snap-ffap-url-fetcher)
653 ;:*=======================
654 ;:* ElDoc (handy thingy dingy for lisp programming)
655 ;; displays function args and var doc strings in echo area
656 ;(setq eldoc-use-idle-timer-p nil)
657 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
658 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
659 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
661 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
662 (message "packages loaded")