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: <Sunday Jun 10, 2012 10:58:25 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)
401 (defun sy-esh-cdl (&optional type)
402 "Eshell function to find current kernel's build or source dir.
404 Non-nil TYPE means find the current kernel's build directory, otherwise
405 find the source directory."
406 (let* ((base "/lib/modules/")
407 (ver (substring (shell-command-to-string "uname -r") 0 -1))
408 (dir (file-name-as-directory
416 "Change directory to current kernel source directory.
418 Convenience function to use with Eshell."
423 "Change directory to current kernel build directory.
425 Convenience function to use with Eshell."
429 ; :*======================
430 ; :* FFAP -- Find File At Point
436 '((global-set-key '(shift button3) 'ffap-at-mouse)
437 (global-set-key '(control shift button3) 'ffap-menu)
438 (global-set-key "\C-x\C-f" 'find-file-at-point)
439 (global-set-key "\C-x4f" 'ffap-other-window)
440 (global-set-key "\C-x5f" 'ffap-other-frame)))
441 ffap-machine-p-known 'accept
442 ffap-machine-p-unknown 'accept
443 ffap-machine-p-local 'accept)
446 (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click)
448 ;:*======================
450 (require 'auto-insert-tkld)
452 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
455 ("\\.h$" . "C Header")
456 ("\\.el$" . "Emacs Lisp")
457 ("[Mm]akefile" . "Makefile")
459 ("\\.pl$" . "Perl")))
461 (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi")
463 ("C Header" . "h-insert.h")
464 ("C++" . "c++-insert.cc")
465 ("Emacs Lisp" . "elisp-insert.el")
466 ("Makefile" . "makefile.inc")
467 ("Perl" . "perl-insert.pl")
468 ("Sh" . "sh-insert.sh")))
470 (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/")
472 ;; Don't auto-insert into AucTeX style .els
473 (defadvice TeX-auto-store (around no-auto-insert activate)
474 "Ensure auto-insert is deactivated"
475 (let ((auto-insert-automatically nil))
477 (message "Auto-Insert initialised!")
478 ;:*======================
480 ; I don't think anyone uses tla anymore
483 ; xetla-show-internal-buffers-on-menu nil
484 ; xetla-switch-to-buffer-mode 'single-window
485 ; xetla-use-arrow-keys-for-navigation t)
486 ;(defun sy-xetla-reload ()
489 ; (call-interactively 'xetla-reload)
490 ; (require 'xetla-browse)
492 ; xetla-show-internal-buffers-on-menu nil
493 ; xetla-switch-to-buffer-mode 'single-window
494 ; xetla-use-arrow-keys-for-navigation t))
496 ;:*=======================
500 ;:*======================
502 (defvar sxell-initialised-flag)
503 (defvar sxell-download-directory)
504 (when (and (featurep '(and sxemacs postgresql))
505 (fboundp 'ffi-defun))
507 (setq sxell-initialised-flag t
508 sxell-download-directory
509 (file-name-as-directory (expand-file-name "download/SXEmacs"
510 (user-home-directory)))))
511 ;:*======================
515 (defun sy-epa-export-key ()
516 "Wrapper for `epa-export-keys' to export ASCII armoured keys."
519 (call-interactively #'epa-export-keys)))
521 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
523 ;:*=======================
524 ;:* Howm thing. (this needs mule, but that is default so no biggie)
527 ;; howm has the unfortunate name that ends in `wm' which is what
528 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
529 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
531 ;; The howm people are stupid, they bind C-h to scroll-down in the howm
532 ;; menu. Get rid of it and replace with DEL
533 (define-key howm-menu-mode-map "\C-h" nil)
534 (define-key howm-menu-mode-map [delete] 'scroll-down)
536 ;; Another problem with howm... it fucks up window configuration
537 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
538 "Save window configuration before viewing howm buffers."
539 (window-configuration-to-register ?h))
541 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
542 "Save window configuration before viewing howm buffers."
543 (window-configuration-to-register ?h))
545 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
546 "Save window configuration before viewing howm buffers."
547 (window-configuration-to-register ?h))
549 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
550 "Restore the original window configuration."
551 (jump-to-register ?h))
553 (setq howm-directory "~/.howm")
555 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
556 ;; call to `turn-on-font-lock' here at least restores a certain level
558 (defun turn-on-howm-mode ()
562 (defun turn-off-howm-mode ()
565 ;; Turn it on where I need it
566 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
567 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
568 ;; compiling the generated .el
569 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
570 (add-hook 'text-mode-hook #'turn-on-howm-mode)
571 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
572 (add-hook 'c-mode-hook #'turn-on-howm-mode)
573 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
575 ;; Turn it off where I don't
576 (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode)
577 (add-hook 'html-mode-hook #'turn-off-howm-mode)
578 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
580 ;;; Various other howm problem fixes
582 ;; I'm having a big problem with howm/font-lock/message-mode playing
583 ;; nicely together. This gives me font-locking in message-mode, plus
584 ;; howm functionality, but no howm font-locking. I can live without
585 ;; howm font-lock in one buffer.
586 (add-hook 'message-mode-hook #'(lambda ()
590 ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock)
591 ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock)
593 (add-hook 'change-log-mode-hook #'font-lock-mode)
595 ;;:*=====================
597 ;; save/load snapshot of application to/from text
600 ;; (1) M-x snap-record on application, e.g. Wanderlust.
601 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
602 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
605 ;;;; env var trickery.
606 (setq snap-abbreviate-environment-variables
607 '("HOME" "JAVA_HOME" "module_path"))
609 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
611 (let ((path (expand-file-name raw-path))
612 (rules (mapcar #'(lambda (var)
613 (let ((val (getenv var)))
615 (cons (concat "^" (regexp-quote val))
616 (format "${%s}" var)))))
617 snap-abbreviate-environment-variables)))
619 (when (and r (string-match (car r) path))
620 (setq ad-return-value
621 (replace-regexp-in-string (car r) (cdr r) path))))
625 (eval-after-load "bookmark"
627 (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
628 (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
631 (setq ffap-url-regexp snap-ffap-url-regexp)
632 (setq ffap-url-fetcher snap-ffap-url-fetcher)
634 ;:*=======================
635 ;:* ElDoc (handy thingy dingy for lisp programming)
636 ;; displays function args and var doc strings in echo area
637 ;(setq eldoc-use-idle-timer-p nil)
638 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
639 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
640 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
642 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
643 (message "packages loaded")