;; 11-pkgs-sy.el --- Various XE Package Settings -*- Emacs-Lisp -*- ;; Copyright (C) 2007 - 2013 Steve Youngs ;; Author: Steve Youngs ;; Maintainer: Steve Youngs ;; Created: <2007-12-02> ;; Time-stamp: ;; Download: ;; HTMLised: ;; Git Repo: git clone http://git.sxemacs.org/syinit ;; Keywords: init, compile ;; This file is part of SYinit ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions ;; are met: ;; ;; 1. Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; 2. Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; 3. Neither the name of the author nor the names of any contributors ;; may be used to endorse or promote products derived from this ;; software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; Commentary: ;; ;; Lots of settings for various XEmacs packages that I use. Plus a ;; few other packages. ;; ;; I want to point out that I DO NOT blindly install the "sumo" ;; packages. I only install what I need and use. And I absolutely ;; DO NOT have the "fsf-compat" package installed. ;;; Credits: ;; ;; The HTML version of this file was created with Hrvoje Niksic's ;; htmlize.el which is part of the XEmacs "text-modes" package. ;; ;;; Todo: ;; ;; ;;; Code: ;:*====================== ;:* MusicPD (Not an XEmacs package) (require 'mpd) (defun sy-mpd-play () "Start playing music from a randomly chosen playlist." (interactive) (mpd-send "clear") (mpd-send "load Full-sorted.playlist") (mpd-send "random 1") (mpd-send "repeat 1") (mpd-playpause)) (defun 2001-mpd-play () "Start playing 2001 audio book." (interactive) (mpd-send "clear") (mpd-send "load 2001_A_Space_Odyssey.playlist") (mpd-send "random 0") (mpd-send "repeat 0") (mpd-playpause)) ;; Audio keybindings (global-set-key [XF86AudioPlay] #'mpd-playpause) (global-set-key [XF86AudioStop] #'mpd-stop) (global-set-key [XF86AudioNext] #'mpd-next-track) (global-set-key [XF86AudioPrev] #'mpd-previous-track) (global-set-key [XF86AudioRaiseVolume] #'mpd-volume-up) (global-set-key [XF86AudioLowerVolume] #'mpd-volume-down) (global-set-key [XF86AudioMute] #'mpd-volume-mute/unmute) ;; Mpd frame props (unless (or (string= (getenv "KDE_FULL_SESSION") "true") (string= (getenv "SAWFISH_IS_RUNNING") "true")) (push (cons 'override-redirect t) mpd-dock-frame-plist)) (push (cons 'left 1780) mpd-dock-frame-plist) (push (cons 'top 5) mpd-dock-frame-plist) (push (cons 'internal-border-width 4) mpd-dock-frame-plist) (push (cons 'border-width 1) mpd-dock-frame-plist) (push (cons 'border-color "red") mpd-dock-frame-plist) ;:*====================== ;; pcl-cvs - a GNU Emacs front-end to CVS ;; Does anyone use CVS anymore? ;(autoload 'cvs-update "pcl-cvs" nil t) ;(setq ; cvs-reuse-cvs-buffer 'always ; cvs-add-default-message "Initial version" ; cvs-allow-dir-commit t) ;:*====================== ;:* View-process (`top' for emacs) (require 'view-process-mode) (setq View-process-host-names-and-system-types '(("bastard.steveyoungs.com" ("linux" nil "bsd" View-process-field-name-descriptions-linux View-process-kill-signals-linux)))) (setq View-process-status-command-switches-system-v "auxw") (setq View-process-ps-header-window-offset 3) (add-hook 'View-process-header-mode-hook (lambda () (set-specifier horizontal-scrollbar-visible-p nil (current-buffer)) (set-specifier vertical-scrollbar-visible-p nil (current-buffer)))) ;:*===================== ;:* whitespace-mode (autoload 'whitespace-mode "whitespace-mode" "Toggle whitespace mode. With arg, turn whitespace mode on iff arg is positive. In whitespace mode the different whitespaces (tab, blank return) are highlighted with different faces. The faces are: `whitespace-blank-face', `whitespace-tab-face' and `whitespace-return-face'." t) (autoload 'whitespace-incremental-mode "whitespace-mode" "Toggle whitespace incremental mode. With arg, turn whitespace incremental mode on iff arg is positive. In whitespace incremental mode the different whitespaces (tab and blank) are highlighted with different faces. The faces are: `whitespace-blank-face' and `whitespace-tab-face'. Use the command `whitespace-show-faces' to show their values. In this mode only these tabs and blanks are highlighted, which are in the region from (point) - (window-heigh) to (point) + (window-heigh)." t) ;:*====================== ;:* func-menu (add-hook 'find-file-hooks 'fume-setup-buffer) (add-hook 'Manual-mode-hook 'turn-on-fume-mode) (define-key global-map "\C-cl" 'fume-list-functions) (define-key global-map "\C-cg" 'fume-prompt-function-goto) (define-key global-map '(control button3) 'mouse-function-menu) (setq fume-display-in-modeline-p t fume-menubar-menu-location "File") ;:*====================== ;:* font-lock (remove-hook 'font-lock-mode-hook 'turn-on-fast-lock) (require 'font-lock) ;:*====================== ;:* recent-files.el --- Maintain menu of recently opened files. (when (featurep 'menubar) (require 'recent-files) (setq recent-files-non-permanent-submenu t) (recent-files-initialize)) ;:*====================== ;:* jka-compr ;; Handle automatic (de)compresion of [bg]zip files (require 'jka-compr) (jka-compr-install) ;:*====================== ;:* iswitchb ;: A really cool package to switch buffers (require 'iswitchb) (setq iswitchb-default-method 'samewindow) (iswitchb-default-keybindings) (add-hook 'iswitchb-define-mode-map-hook '(lambda () (define-key iswitchb-mode-map " " 'iswitchb-next-match) (define-key iswitchb-mode-map [(control ?\ )] 'iswitchb-prev-match) (define-key iswitchb-mode-map "\C-a" 'iswitchb-toggle-ignore))) ;:*====================== ;:* backup ;: move all backups in one directory (require 'backup-dir) (setq bkup-backup-directory-info '((t "~/.autosave/" ok-create full-path))) (setq version-control 'preserve-prefer-numbered) (setq-default delete-old-versions t) ;:*====================== ;:* Load minibuffer history, but only if mule or file-coding is available (when (featurep '(or mule file-coding)) (require 'savehist) (setq savehist-file (expand-file-name "history" user-init-directory)) (setq savehist-coding-system (coding-system-name (find-coding-system 'iso-8859-1))) (savehist-mode 1)) ;:*====================== ;:* Kyle Jones' redo package. (when running-xemacs (require 'redo) (global-set-key "\C-^" 'redo) ; for tty-s... (global-set-key [(control ?6)] 'redo) ; ...and for X (global-set-key "\M-_" 'redo)) ; universal (require 'scroll-in-place) ;:*====================== ;:* pending-del ;: Non-nil when Pending Delete mode is enabled. In Pending Delete mode, typed ;: text replaces the selected region. Normally, you shouldn't modify this ;: variable by hand, but use the function `pending-delete-mode' instead. However, ;: you can customize the default value from the options menu (auto delete ;: selection). (require 'pending-del) (turn-on-pending-delete nil) ;:*====================== ;:* comment-region ;: Comment or uncomment each line in the region. ;: Comments are terminated on each line, even for syntax in which newline does ;: not end the comment. Blank lines do not get comments. (require 'newcomment) (global-set-key '(control f12) 'comment-or-uncomment-region) (global-set-key '(meta f12) 'uncomment-or-uncomment-region) ;:*====================== ;:* parens that mark sexpressions (require 'paren) (paren-set-mode 'paren) ;:*====================== ;:* easy editing of crontab files (require 'crontab-edit "crontab.elc") (setq crontab-delete-blank-lines nil) (setq crontab-filename (expand-file-name ".crontab" (user-home-directory))) (setq crontab-directory (paths-construct-path '("spool" "cron" "crontabs") "/var")) ;:*====================== ;:* a major mode for editing X resource database files (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t) ;:*====================== ;:* Footnote package (require 'footnote) ;:*====================== ;:* Filladapt-Mode (require 'filladapt) (setq-default filladapt-mode t) (setq filladapt-fill-column-tolerance 5) (add-hook 'c-mode-hook 'turn-off-filladapt-mode) ;:*====================== ;:* Speedbar (setq speedbar-query-confirmation-method 'none-but-delete speedbar-show-unknown-files t speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy speedbar-trim-words-tag-hierarchy speedbar-simple-group-tag-hierarchy speedbar-sort-tag-hierarchy) speedbar-track-mouse-flag t speedbar-use-tool-tips-flag t speedbar-visiting-tag-hook 'speedbar-recenter-to-top) (when (featurep 'menubar) (add-menu-button '("Tools") ["Speedbar" speedbar-frame-mode :style toggle :selected (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame) (frame-visible-p speedbar-frame))] "--")) (global-set-key [(f4)] 'speedbar-get-focus) (require 'sb-info) (require 'sb-texinfo) (eval-after-load "speedbar" '(load-library "sb-texinfo")) (eval-after-load "speedbar" '(load-library "sb-html")) (autoload 'w3-speedbar-buttons "sb-w3" "W3 specific speedbar button generator.") ;; Speedbar frame props (so I can use matched windows in Sawfish) (setq speedbar-frame-plist (plist-put speedbar-frame-plist 'name "Speedbar::Frame")) ;:*====================== ;:* Shell-mode (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) (add-hook 'shell-mode-hook 'turn-on-font-lock) ;:*======================= ;:* Shell-script (setq sh-basic-offset 4) ;:*====================== ;:* Compile-Mode (setq compilation-always-signal-completion t mode-compile-make-program "make" compilation-read-command t compilation-window-height 10 compile-command "make") ;:*====================== ;:* Balloon Help (now in calendar settings) ;:*====================== ;:* Version Control (vc-load-vc-hooks) (setq vc-handled-backends '(Arch SVN GIT CVS MCVS RCS) vc-follow-symlinks t) ;:*====================== ;:* Ediff & Diff-mode (require 'ediff) (require 'diff-mode) (setq ediff-use-toolbar-p nil ; was t but plays havoc with xwem ediff-custom-diff-options "-u" ediff-window-setup-function 'ediff-setup-windows-plain) (setq diff-switches "-u") ;:*===================== ;:* Tramp (require 'tramp) (setq tramp-default-method "ssh" tramp-auto-save-directory "~/.autosave/" tramp-remote-path '("/usr/lib/pkgusr" "/usr/bin" "/bin" "/usr/X11R6/bin")) ; :*====================== ; :* Eshell ;(require 'pcmpl-arch) (setq eshell-ask-to-save-history 'always eshell-save-history-on-exit t eshell-banner-message (concat "Welcome to Eshell on " (system-name) ", running " (shell-command-to-string "uname -rs") "In: " emacs-version "\n\n") eshell-hist-ignoredups t eshell-modules-list '(eshell-alias eshell-banner eshell-basic eshell-cmpl eshell-dirs eshell-glob eshell-hist eshell-ls eshell-pred eshell-prompt ;eshell-rebind eshell-script ;eshell-smart eshell-term eshell-unix eshell-xtra)) (defun sy-eshell-bol-maybe (&optional prompt) "*Move point to beginning of command or bol if there already. If at bol, move point to beginning of command. Optional arg, PROMPT is a regexp of your eshell prompt." (interactive) (let* ((prompt (or prompt "^.+ [$%] ")) (lbpos (point-at-bol)) (prspos (save-excursion (goto-char lbpos) (search-forward-regexp prompt (point-at-eol) t))) (cpos (point))) (goto-char (cond ((null prspos) lbpos) ((= cpos (or prspos 0)) lbpos) (prspos) (t lbpos))))) (defun sy-eshell-bol-maybe-key () (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe)) (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe) (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t) (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color) (defun sy-esh-cdl (&optional type) "Eshell function to find current kernel's build or source dir. Non-nil TYPE means find the current kernel's build directory, otherwise find the source directory." (let* ((base "/lib/modules/") (ver (substring (shell-command-to-string "uname -r") 0 -1)) (dir (file-name-as-directory (concat base ver "/" (if type "build" "source"))))) (cd dir))) (defun cdls () "Change directory to current kernel source directory. Convenience function to use with Eshell." (interactive) (sy-esh-cdl)) (defun cdlb () "Change directory to current kernel build directory. Convenience function to use with Eshell." (interactive) (sy-esh-cdl 'build)) ; :*====================== ; :* FFAP -- Find File At Point (require 'ffap) (setq ffap-bindings (nconc '((global-set-key '(shift button3) 'ffap-at-mouse) (global-set-key '(control shift button3) 'ffap-menu) (global-set-key "\C-x\C-f" 'find-file-at-point) (global-set-key "\C-x4f" 'ffap-other-window) (global-set-key "\C-x5f" 'ffap-other-frame))) ffap-machine-p-known 'accept ffap-machine-p-unknown 'accept ffap-machine-p-local 'accept) (ffap-bindings) (add-hook 'mouse-track-click-hook 'ffap-mouse-track-click) ;:*====================== ;:* Auto-Insert (require 'auto-insert-tkld) (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo") ("\\.c$" . "C") ("\\.cc$" . "C++") ("\\.h$" . "C Header") ("\\.el$" . "Emacs Lisp") ("[Mm]akefile" . "Makefile") ("\\.sh$" . "Sh") ("\\.pl$" . "Perl"))) (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi") ("C" . "c-insert.c") ("C Header" . "h-insert.h") ("C++" . "c++-insert.cc") ("Emacs Lisp" . "elisp-insert.el") ("Makefile" . "makefile.inc") ("Perl" . "perl-insert.pl") ("Sh" . "sh-insert.sh"))) (add-to-list 'auto-insert-path '"~/etc/SXEmacs/templates/") ;; Don't auto-insert into AucTeX style .els (defadvice TeX-auto-store (around no-auto-insert activate) "Ensure auto-insert is deactivated" (let ((auto-insert-automatically nil)) ad-do-it)) (message "Auto-Insert initialised!") ;:*====================== ;:* XEtla ; I don't think anyone uses tla anymore ;(require 'xetla) ;(setq ; xetla-show-internal-buffers-on-menu nil ; xetla-switch-to-buffer-mode 'single-window ; xetla-use-arrow-keys-for-navigation t) ;(defun sy-xetla-reload () ; "Reload XEtla." ; (interactive) ; (call-interactively 'xetla-reload) ; (require 'xetla-browse) ; (setq ; xetla-show-internal-buffers-on-menu nil ; xetla-switch-to-buffer-mode 'single-window ; xetla-use-arrow-keys-for-navigation t)) ;:*======================= ;:* My git shit (require 'sy-git) ;:*====================== ;:* Emacs Lisp List (defvar sxell-initialised-flag) (defvar sxell-download-directory) (when (and (featurep '(and sxemacs postgresql)) (fboundp 'ffi-defun)) (require 'sxell) (setq sxell-initialised-flag t sxell-download-directory (file-name-as-directory (expand-file-name "download/SXEmacs" (user-home-directory))))) ;:*====================== ;:* EasyPG (require 'epa-setup) (defun sy-epa-export-key () "Wrapper for `epa-export-keys' to export ASCII armoured keys." (interactive) (let ((epa-armor t)) (call-interactively #'epa-export-keys))) (define-key epa-key-list-mode-map [?O] #'sy-epa-export-key) ;:*======================= ;:* Howm thing. (this needs mule, but that is default so no biggie) (require 'howm) ;; howm has the unfortunate name that ends in `wm' which is what ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'") ;; The howm people are stupid, they bind C-h to scroll-down ;; Get rid of it and replace with DEL and BACKSPACE (define-key howm-menu-mode-map "\C-h" nil) (define-key howm-menu-mode-map [delete] #'scroll-down) (define-key howm-menu-mode-map [backspace] #'scroll-down) (define-key riffle-summary-mode-map "\C-h" nil) (define-key riffle-summary-mode-map [delete] #'scroll-other-window-down) (define-key riffle-summary-mode-map [backspace] #'scroll-other-window-down) (define-key riffle-contents-mode-map "\C-h" nil) (define-key riffle-contents-mode-map [delete] #'scroll-down) (define-key riffle-contents-mode-map [backspace] #'scroll-down) ;; Add a binding to show the active todo list (global-set-key [(control ?c) ?t] #'howm-list-active-todo) ;; Another problem with howm... it fucks up window configuration (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate) "Save window configuration before viewing howm buffers." (window-configuration-to-register ?h)) (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate) "Save window configuration before viewing howm buffers." (window-configuration-to-register ?h)) (defadvice howm-list-grep (before howm-save-win (&rest args) activate) "Save window configuration before viewing howm buffers." (window-configuration-to-register ?h)) (defadvice howm-list-todo (before howm-save-win (&rest args) activate) "Save window configuration before viewing howm buffers." (window-configuration-to-register ?h)) (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate) "Save window configuration before viewing howm buffers." (window-configuration-to-register ?h)) (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate) "Restore the original window configuration." (jump-to-register ?h)) (setq howm-directory "~/.howm") ;; howm fucks up font-lock'ing like you wouldn't believe, adding a ;; call to `turn-on-font-lock' here at least restores a certain level ;; of normalcy. (defun turn-on-howm-mode () (turn-on-font-lock) (howm-mode 1)) (defun turn-off-howm-mode () (howm-mode 0)) ;; Turn it on where I need it (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode) ;; You gotta be fooking kidding me, this prevents lisp-initd.el from ;; compiling the generated .el ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode) (add-hook 'text-mode-hook #'turn-on-howm-mode) (add-hook 'latex-mode-hook #'turn-on-howm-mode) (add-hook 'c-mode-hook #'turn-on-howm-mode) (add-hook 'sh-mode-hook #'turn-on-howm-mode) ;; Turn it off where I don't (add-hook 'emchat-log-mode-hook #'turn-off-howm-mode) (add-hook 'html-mode-hook #'turn-off-howm-mode) (add-hook 'texinfo-mode-hook #'turn-off-howm-mode) ;;; Various other howm problem fixes ;; I'm having a big problem with howm/font-lock/message-mode playing ;; nicely together. This gives me font-locking in message-mode, plus ;; howm functionality, but no howm font-locking. I can live without ;; howm font-lock in one buffer. (add-hook 'message-mode-hook #'(lambda () (font-lock-mode) (font-lock-mode))) ;; XEtla/howm probs ;(add-hook 'xetla-changelog-mode-hook #'turn-on-font-lock) ;(add-hook 'xetla-log-edit-mode-hook #'turn-on-font-lock) ;; ChangeLogs (add-hook 'change-log-mode-hook #'font-lock-mode) ;;:*===================== ;;:* snap! ;; save/load snapshot of application to/from text ;; Usage: ;; ;; (1) M-x snap-record on application, e.g. Wanderlust. ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt. ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored. (require 'snap) ;;;; env var trickery. (setq snap-abbreviate-environment-variables '("HOME" "JAVA_HOME" "module_path")) (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate) ad-do-it (let ((path (expand-file-name raw-path)) (rules (mapcar #'(lambda (var) (let ((val (getenv var))) (and val (cons (concat "^" (regexp-quote val)) (format "${%s}" var))))) snap-abbreviate-environment-variables))) (mapc #'(lambda (r) (when (and r (string-match (car r) path)) (setq ad-return-value (replace-regexp-in-string (car r) (cdr r) path)))) (reverse rules)))) ;; Bookmark extras (eval-after-load "bookmark" (progn (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap) (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap))) ;; ffap extras (setq ffap-url-regexp snap-ffap-url-regexp) (setq ffap-url-fetcher snap-ffap-url-fetcher) ;:*======================= ;:* ElDoc (handy thingy dingy for lisp programming) ;; displays function args and var doc strings in echo area ;(setq eldoc-use-idle-timer-p nil) ;(autoload #'turn-on-eldoc-mode "eldoc" nil t) ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode) ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode) ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::* (message "packages loaded")