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: <Monday Mar 10, 2014 13:51:18 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 (unless (or (string= (getenv "KDE_FULL_SESSION") "true")
96 (string= (getenv "SAWFISH_IS_RUNNING") "true"))
97 (push (cons 'override-redirect t) mpd-dock-frame-plist))
98 (push (cons 'left 1780) mpd-dock-frame-plist)
99 (push (cons 'top 5) mpd-dock-frame-plist)
100 (push (cons 'internal-border-width 4) mpd-dock-frame-plist)
101 (push (cons 'border-width 1) mpd-dock-frame-plist)
102 (push (cons 'border-color "red") mpd-dock-frame-plist)
105 ;:*======================
106 ;; pcl-cvs - a GNU Emacs front-end to CVS
107 ;; Does anyone use CVS anymore?
108 ;(autoload 'cvs-update "pcl-cvs" nil t)
110 ; cvs-reuse-cvs-buffer 'always
111 ; cvs-add-default-message "Initial version"
112 ; cvs-allow-dir-commit t)
114 ;:*======================
115 ;:* View-process (`top' for emacs)
116 (require 'view-process-mode)
117 (setq View-process-host-names-and-system-types
118 '(("bastard.steveyoungs.com"
120 View-process-field-name-descriptions-linux
121 View-process-kill-signals-linux))))
122 (setq View-process-status-command-switches-system-v "auxw")
123 (setq View-process-ps-header-window-offset 3)
124 (add-hook 'View-process-header-mode-hook
126 (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
127 (set-specifier vertical-scrollbar-visible-p nil (current-buffer))))
129 ;:*=====================
131 (autoload 'whitespace-mode "whitespace-mode"
132 "Toggle whitespace mode.
133 With arg, turn whitespace mode on iff arg is positive. In
134 whitespace mode the different whitespaces (tab, blank return) are
135 highlighted with different faces. The faces are:
136 `whitespace-blank-face', `whitespace-tab-face' and
137 `whitespace-return-face'."
140 (autoload 'whitespace-incremental-mode "whitespace-mode"
141 "Toggle whitespace incremental mode.
142 With arg, turn whitespace incremental mode on iff arg is positive.
143 In whitespace incremental mode the different whitespaces (tab and
144 blank) are highlighted with different faces. The faces are:
145 `whitespace-blank-face' and `whitespace-tab-face'. Use the command
146 `whitespace-show-faces' to show their values. In this mode only
147 these tabs and blanks are highlighted, which are in the region from
148 (point) - (window-heigh) to (point) + (window-heigh)."
151 ;:*======================
153 (add-hook 'find-file-hooks 'fume-setup-buffer)
154 (add-hook 'Manual-mode-hook 'turn-on-fume-mode)
155 (define-key global-map "\C-cl" 'fume-list-functions)
156 (define-key global-map "\C-cg" 'fume-prompt-function-goto)
157 (define-key global-map '(control button3) 'mouse-function-menu)
159 fume-display-in-modeline-p t
160 fume-menubar-menu-location "File")
162 ;:*======================
164 (remove-hook 'font-lock-mode-hook 'turn-on-fast-lock)
167 ;:*======================
168 ;:* recent-files.el --- Maintain menu of recently opened files.
169 (when (featurep 'menubar)
170 (require 'recent-files)
171 (setq recent-files-non-permanent-submenu t)
172 (recent-files-initialize))
174 ;:*======================
176 ;; Handle automatic (de)compresion of [bg]zip files
180 ;:*======================
182 ;: A really cool package to switch buffers
184 (setq iswitchb-default-method 'samewindow)
185 (iswitchb-default-keybindings)
187 'iswitchb-define-mode-map-hook
189 (define-key iswitchb-mode-map " " 'iswitchb-next-match)
190 (define-key iswitchb-mode-map [(control ?\ )] 'iswitchb-prev-match)
191 (define-key iswitchb-mode-map "\C-a" 'iswitchb-toggle-ignore)))
193 ;:*======================
195 ;: move all backups in one directory
196 (require 'backup-dir)
197 (setq bkup-backup-directory-info
198 '((t "~/.autosave/" ok-create full-path)))
199 (setq version-control 'preserve-prefer-numbered)
200 (setq-default delete-old-versions t)
202 ;:*======================
203 ;:* Load minibuffer history, but only if mule or file-coding is available
204 (when (featurep '(or mule file-coding))
206 (setq savehist-file (expand-file-name "history" user-init-directory))
207 (setq savehist-coding-system
208 (coding-system-name (find-coding-system 'iso-8859-1)))
211 ;:*======================
212 ;:* Kyle Jones' redo package.
215 (global-set-key "\C-^" 'redo) ; for tty-s...
216 (global-set-key [(control ?6)] 'redo) ; ...and for X
217 (global-set-key "\M-_" 'redo)) ; universal
218 (require 'scroll-in-place)
220 ;:*======================
222 ;: Non-nil when Pending Delete mode is enabled. In Pending Delete mode, typed
223 ;: text replaces the selected region. Normally, you shouldn't modify this
224 ;: variable by hand, but use the function `pending-delete-mode' instead. However,
225 ;: you can customize the default value from the options menu (auto delete
227 (require 'pending-del)
228 (turn-on-pending-delete nil)
230 ;:*======================
232 ;: Comment or uncomment each line in the region.
233 ;: Comments are terminated on each line, even for syntax in which newline does
234 ;: not end the comment. Blank lines do not get comments.
235 (require 'newcomment)
236 (global-set-key '(control f12) 'comment-or-uncomment-region)
237 (global-set-key '(meta f12) 'uncomment-or-uncomment-region)
239 ;:*======================
240 ;:* parens that mark sexpressions
242 (paren-set-mode 'paren)
244 ;:*======================
245 ;:* easy editing of crontab files
246 (require 'crontab-edit "crontab.elc")
247 (setq crontab-delete-blank-lines nil)
248 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
249 (setq crontab-directory
250 (paths-construct-path '("spool" "cron" "crontabs") "/var"))
252 ;:*======================
253 ;:* a major mode for editing X resource database files
254 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
256 ;:*======================
260 ;:*======================
263 (setq-default filladapt-mode t)
264 (setq filladapt-fill-column-tolerance 5)
265 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
267 ;:*======================
270 speedbar-query-confirmation-method 'none-but-delete
271 speedbar-show-unknown-files t
272 speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
273 speedbar-trim-words-tag-hierarchy
274 speedbar-simple-group-tag-hierarchy
275 speedbar-sort-tag-hierarchy)
276 speedbar-track-mouse-flag t
277 speedbar-use-tool-tips-flag t
278 speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
280 (when (featurep 'menubar)
281 (add-menu-button '("Tools")
282 ["Speedbar" speedbar-frame-mode
284 :selected (and (boundp 'speedbar-frame)
285 (frame-live-p speedbar-frame)
286 (frame-visible-p speedbar-frame))]
288 (global-set-key [(f4)] 'speedbar-get-focus)
290 (require 'sb-texinfo)
291 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
292 (eval-after-load "speedbar" '(load-library "sb-html"))
293 (autoload 'w3-speedbar-buttons "sb-w3"
294 "W3 specific speedbar button generator.")
296 ;; Speedbar frame props (so I can use matched windows in Sawfish)
297 (setq speedbar-frame-plist
298 (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
299 ;:*======================
301 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
302 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
303 (add-hook 'shell-mode-hook 'turn-on-font-lock)
305 ;:*=======================
307 (setq sh-basic-offset 4)
309 ;:*======================
312 compilation-always-signal-completion t
313 mode-compile-make-program "make"
314 compilation-read-command t
315 compilation-window-height 10
316 compile-command "make")
318 ;:*======================
319 ;:* Balloon Help (now in calendar settings)
321 ;:*======================
325 vc-handled-backends '(Arch SVN GIT CVS MCVS RCS)
326 vc-follow-symlinks t)
328 ;:*======================
329 ;:* Ediff & Diff-mode
332 (setq ediff-use-toolbar-p nil ; was t but plays havoc with xwem
333 ediff-custom-diff-options "-u"
334 ediff-window-setup-function 'ediff-setup-windows-plain)
335 (setq diff-switches "-u")
337 ;:*=====================
340 (setq tramp-default-method "ssh"
341 tramp-auto-save-directory "~/.autosave/"
348 ; :*======================
350 ;(require 'pcmpl-arch)
352 eshell-ask-to-save-history 'always
353 eshell-save-history-on-exit t
354 eshell-banner-message (concat "Welcome to Eshell on "
357 (shell-command-to-string "uname -rs")
361 eshell-hist-ignoredups t
362 eshell-modules-list '(eshell-alias
379 (defun sy-eshell-bol-maybe (&optional prompt)
380 "*Move point to beginning of command or bol if there already.
381 If at bol, move point to beginning of command.
382 Optional arg, PROMPT is a regexp of your eshell prompt."
384 (let* ((prompt (or prompt "^.+ [$%] "))
385 (lbpos (point-at-bol))
386 (prspos (save-excursion
388 (search-forward-regexp prompt (point-at-eol) t)))
393 ((= cpos (or prspos 0))
398 (defun sy-eshell-bol-maybe-key ()
399 (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
401 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe)
402 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t)
403 (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color)
405 (defun sy-esh-cdl (&optional type)
406 "Eshell function to find current kernel's build or source dir.
408 Non-nil TYPE means find the current kernel's build directory, otherwise
409 find the source directory."
410 (let* ((base "/lib/modules/")
411 (ver (substring (shell-command-to-string "uname -r") 0 -1))
412 (dir (file-name-as-directory
420 "Change directory to current kernel source directory.
422 Convenience function to use with Eshell."
427 "Change directory to current kernel build directory.
429 Convenience function to use with Eshell."
433 ; :*======================
434 ; :* FFAP -- Find File At Point
440 '((global-set-key '(shift button3) 'ffap-at-mouse)
441 (global-set-key '(control shift button3) 'ffap-menu)
442 (global-set-key "\C-x\C-f" 'find-file-at-point)
443 (global-set-key "\C-x4f" 'ffap-other-window)
444 (global-set-key "\C-x5f" 'ffap-other-frame)))
445 ffap-machine-p-known 'accept
446 ffap-machine-p-unknown 'accept
447 ffap-machine-p-local 'accept)
450 (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click)
452 ;:*======================
454 (require 'auto-insert-tkld)
456 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
459 ("\\.h$" . "C Header")
460 ("\\.el$" . "Emacs Lisp")
461 ("[Mm]akefile" . "Makefile")
463 ("\\.pl$" . "Perl")))
465 (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi")
467 ("C Header" . "h-insert.h")
468 ("C++" . "c++-insert.cc")
469 ("Emacs Lisp" . "elisp-insert.el")
470 ("Makefile" . "makefile.inc")
471 ("Perl" . "perl-insert.pl")
472 ("Sh" . "sh-insert.sh")))
474 (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/")
476 ;; Don't auto-insert into AucTeX style .els
477 (defadvice TeX-auto-store (around no-auto-insert activate)
478 "Ensure auto-insert is deactivated"
479 (let ((auto-insert-automatically nil))
481 (message "Auto-Insert initialised!")
482 ;:*======================
484 ; I don't think anyone uses tla anymore
487 ; xetla-show-internal-buffers-on-menu nil
488 ; xetla-switch-to-buffer-mode 'single-window
489 ; xetla-use-arrow-keys-for-navigation t)
490 ;(defun sy-xetla-reload ()
493 ; (call-interactively 'xetla-reload)
494 ; (require 'xetla-browse)
496 ; xetla-show-internal-buffers-on-menu nil
497 ; xetla-switch-to-buffer-mode 'single-window
498 ; xetla-use-arrow-keys-for-navigation t))
500 ;:*=======================
504 ;:*======================
506 (defvar sxell-initialised-flag)
507 (defvar sxell-download-directory)
508 (when (and (featurep '(and sxemacs postgresql))
509 (fboundp 'ffi-defun))
511 (setq sxell-initialised-flag t
512 sxell-download-directory
513 (file-name-as-directory (expand-file-name "download/SXEmacs"
514 (user-home-directory)))))
515 ;:*======================
519 (defun sy-epa-export-key ()
520 "Wrapper for `epa-export-keys' to export ASCII armoured keys."
523 (call-interactively #'epa-export-keys)))
525 (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key)
527 ;:*=======================
528 ;:* Howm thing. (this needs mule, but that is default so no biggie)
531 ;; howm has the unfortunate name that ends in `wm' which is what
532 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
533 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
535 ;; The howm people are stupid, they bind C-h to scroll-down
536 ;; Get rid of it and replace with DEL and BACKSPACE
537 (define-key howm-menu-mode-map "\C-h" nil)
538 (define-key howm-menu-mode-map [delete] #'scroll-down)
539 (define-key howm-menu-mode-map [backspace] #'scroll-down)
540 (define-key riffle-summary-mode-map "\C-h" nil)
541 (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down)
542 (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down)
543 (define-key riffle-contents-mode-map "\C-h" nil)
544 (define-key riffle-contents-mode-map [delete] #'scroll-down)
545 (define-key riffle-contents-mode-map [backspace] #'scroll-down)
547 ;; Add a binding to show the active todo list
548 (global-set-key [(control ?c) ?t] #'howm-list-active-todo)
550 ;; Another problem with howm... it fucks up window configuration
551 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
552 "Save window configuration before viewing howm buffers."
553 (window-configuration-to-register ?h))
555 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
556 "Save window configuration before viewing howm buffers."
557 (window-configuration-to-register ?h))
559 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
560 "Save window configuration before viewing howm buffers."
561 (window-configuration-to-register ?h))
563 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
564 "Save window configuration before viewing howm buffers."
565 (window-configuration-to-register ?h))
567 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
568 "Save window configuration before viewing howm buffers."
569 (window-configuration-to-register ?h))
571 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
572 "Restore the original window configuration."
573 (jump-to-register ?h))
575 (setq howm-directory "~/.howm")
577 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
578 ;; call to `turn-on-font-lock' here at least restores a certain level
580 (defun turn-on-howm-mode ()
584 (defun turn-off-howm-mode ()
587 ;; Turn it on where I need it
588 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
589 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
590 ;; compiling the generated .el
591 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
592 (add-hook 'text-mode-hook #'turn-on-howm-mode)
593 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
594 (add-hook 'c-mode-hook #'turn-on-howm-mode)
595 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
597 ;; Turn it off where I don't
598 (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode)
599 (add-hook 'html-mode-hook #'turn-off-howm-mode)
600 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
602 ;;; Various other howm problem fixes
604 ;; I'm having a big problem with howm/font-lock/message-mode playing
605 ;; nicely together. This gives me font-locking in message-mode, plus
606 ;; howm functionality, but no howm font-locking. I can live without
607 ;; howm font-lock in one buffer.
608 (add-hook 'message-mode-hook #'(lambda ()
612 ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock)
613 ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock)
615 (add-hook 'change-log-mode-hook #'font-lock-mode)
617 ;;:*=====================
619 ;; save/load snapshot of application to/from text
622 ;; (1) M-x snap-record on application, e.g. Wanderlust.
623 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
624 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
627 ;;;; env var trickery.
628 (setq snap-abbreviate-environment-variables
629 '("HOME" "JAVA_HOME" "module_path"))
631 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
633 (let ((path (expand-file-name raw-path))
634 (rules (mapcar #'(lambda (var)
635 (let ((val (getenv var)))
637 (cons (concat "^" (regexp-quote val))
638 (format "${%s}" var)))))
639 snap-abbreviate-environment-variables)))
641 (when (and r (string-match (car r) path))
642 (setq ad-return-value
643 (replace-regexp-in-string (car r) (cdr r) path))))
647 (eval-after-load "bookmark"
649 (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
650 (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
653 (setq ffap-url-regexp snap-ffap-url-regexp)
654 (setq ffap-url-fetcher snap-ffap-url-fetcher)
656 ;:*=======================
657 ;:* ElDoc (handy thingy dingy for lisp programming)
658 ;; displays function args and var doc strings in echo area
659 ;(setq eldoc-use-idle-timer-p nil)
660 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
661 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
662 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
664 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
665 (message "packages loaded")