1 ;; 10-pkgs.el --- Various XE Package Settings
3 ;; Copyright (C) 2007 - 2020 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 11 Apr 2021 14:10:05 (steve)>
9 ;; Download: <https://downloads.sxemacs.org/SYinits>
10 ;; HTMLised: <https://www.sxemacs.org/SYinits/10-pkgs.html>
11 ;; Git Repo: git clone https://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, although I do
51 ;; have overlay.el from there. It just makes my life a tad easier.
55 ;; The HTML version of this file was created with Hrvoje Niksic's
56 ;; htmlize.el which is part of the XEmacs "text-modes" package.
64 ;:*======================
65 ;:* MusicPD (Not an XEmacs package)
69 "Start playing music from a randomly chosen playlist."
72 (mpd-send "load Full-sorted.playlist")
77 (defun 2001-mpd-play ()
78 "Start playing 2001 audio book."
81 (mpd-send "load 2001_A_Space_Odyssey.playlist")
87 (unless (or (string= (getenv "KDE_FULL_SESSION") "true")
88 (string= (getenv "SAWFISH_IS_RUNNING") "true"))
89 (push (cons 'override-redirect t) mpd-dock-frame-plist))
90 (push (cons 'left 1780) mpd-dock-frame-plist)
91 (push (cons 'top 5) mpd-dock-frame-plist)
92 (push (cons 'internal-border-width 4) mpd-dock-frame-plist)
93 (push (cons 'border-width 1) mpd-dock-frame-plist)
94 (push (cons 'border-color "red") mpd-dock-frame-plist)
96 ;:*======================
97 ;:* View-process (`top' for emacs)
98 (require 'view-process-mode)
99 (setq View-process-host-names-and-system-types
100 '(("bastard.steveyoungs.com"
102 View-process-field-name-descriptions-linux
103 View-process-kill-signals-linux))))
104 (setq View-process-status-command-switches-system-v "auxw")
105 (setq View-process-ps-header-window-offset 3)
106 (add-hook 'View-process-header-mode-hook
108 (set-specifier horizontal-scrollbar-visible-p nil (current-buffer))
109 (set-specifier vertical-scrollbar-visible-p nil (current-buffer))))
111 ;:*=====================
113 (autoload 'whitespace-mode "whitespace-mode" nil t)
114 (autoload 'whitespace-incremental-mode "whitespace-mode" nil t)
116 ;:*======================
119 (add-hook 'find-file-hooks 'fume-setup-buffer)
120 (add-hook 'Manual-mode-hook 'turn-on-fume-mode)
122 fume-display-in-modeline-p t
123 fume-menu-path '("View"))
125 ;:*======================
126 ;:* recent-files.el --- Maintain menu of recently opened files.
127 (when (featurep 'menubar)
128 (require 'recent-files)
129 (setq recent-files-non-permanent-submenu t
130 recent-files-menu-path '("File")
131 recent-files-add-menu-before "Insert File..."
132 recent-files-save-file
133 (expand-file-name ".recent-files.el" user-init-directory)
134 recent-files-dont-include
135 '(#r"\.config/sxemacs/\(howm\|diary\).*$"
138 #r"\.\(newsrc*\|bbdb\)$"
140 (recent-files-initialize))
142 ;:*======================
144 ;; Handle automatic (de)compresion of [bg]zip files
148 ;:*======================
149 ;:* iswitchb (keybindings in 90-keys.el)
150 ;: A really cool package to switch buffers
152 (setq iswitchb-default-method 'samewindow)
153 (iswitchb-default-keybindings)
155 ;:*======================
157 ;: move all backups in one directory
158 (require 'backup-dir)
159 (setq bkup-backup-directory-info
160 '((t "~/.autosave/" ok-create full-path)))
161 (setq version-control 'preserve-prefer-numbered)
162 (setq-default delete-old-versions t)
164 ;:*======================
165 ;:* Load minibuffer history, but only if mule or file-coding is available
166 (when (featurep '(or mule file-coding))
168 (setq savehist-file (expand-file-name "history" user-init-directory))
169 (setq savehist-coding-system
170 (coding-system-name (find-coding-system 'utf-8)))
173 ;:*======================
174 ;:* Kyle Jones' redo package.
178 (require 'scroll-in-place)
180 ;:*======================
182 ;: Non-nil when Pending Delete mode is enabled. In Pending Delete mode, typed
183 ;: text replaces the selected region. Normally, you shouldn't modify this
184 ;: variable by hand, but use the function `pending-delete-mode' instead. However,
185 ;: you can customize the default value from the options menu (auto delete
187 (require 'pending-del)
188 (turn-on-pending-delete nil)
190 ;:*======================
191 ;:* comment-region (keybindings in 90-keys.el)
192 ;: Comment or uncomment each line in the region.
193 ;: Comments are terminated on each line, even for syntax in which newline does
194 ;: not end the comment. Blank lines do not get comments.
195 (require 'newcomment)
198 ;:*======================
199 ;:* parens that mark sexpressions
201 (paren-set-mode 'paren)
203 ;:*======================
204 ;:* easy editing of crontab files
205 (require 'crontab-edit "crontab.elc")
206 (setq crontab-delete-blank-lines nil)
207 (setq crontab-filename (expand-file-name ".crontab" (user-home-directory)))
208 (setq crontab-directory
209 (paths-construct-path '("spool" "cron" "crontabs") "/var"))
211 ;:*======================
212 ;:* a major mode for editing X resource database files
213 (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
215 ;:*======================
219 ;:*======================
222 (setq-default filladapt-mode t)
223 (setq filladapt-fill-column-tolerance 5)
224 (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
226 ;:*======================
228 ;;; FIXME: Speedbar Tooltips
229 ;;; snap:///${XPKGS}/speedbar/speedbar.el
231 speedbar-query-confirmation-method 'none-but-delete
232 speedbar-show-unknown-files t
233 speedbar-tag-hierarchy-method '(speedbar-prefix-group-tag-hierarchy
234 speedbar-trim-words-tag-hierarchy
235 speedbar-simple-group-tag-hierarchy
236 speedbar-sort-tag-hierarchy)
237 ;; speedbar-track-mouse-flag t
238 ;; speedbar-use-tool-tips-flag t
239 speedbar-visiting-tag-hook 'speedbar-recenter-to-top)
241 (when (featurep 'menubar)
242 (add-menu-button '("Tools")
243 ["Speedbar" speedbar-frame-mode
245 :selected (and (boundp 'speedbar-frame)
246 (frame-live-p speedbar-frame)
247 (frame-visible-p speedbar-frame))]
251 (require 'sb-texinfo)
252 (eval-after-load "speedbar" '(load-library "sb-texinfo"))
253 (eval-after-load "speedbar" '(load-library "sb-html"))
254 (autoload 'w3-speedbar-buttons "sb-w3"
255 "W3 specific speedbar button generator.")
257 ;;; Speedbar frame props
258 ;; 'name' (so I can use matched windows in Sawfish)
259 (setq speedbar-frame-plist
260 (plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
262 (setq speedbar-frame-plist
263 (plist-put speedbar-frame-plist 'scrollbar-height 0))
264 (setq speedbar-frame-plist
265 (plist-put speedbar-frame-plist 'scrollbar-width 0))
266 ;; A little wider than default
267 (setq speedbar-frame-plist
268 (plist-put speedbar-frame-plist 'width 25))
270 ;; FIXME: see... PKGFix
271 ;; Try to load the speedbar on the right of the current frame
272 (defalias 'dframe-reposition-frame-xemacs 'dframe-reposition-frame-emacs)
273 (setq speedbar-default-position 'right)
275 ;; Speedbar only does the repositioning thing if the frame has to be
276 ;; created. If you have only closed the speedbar frame with 'q'
277 ;; instead of deleting it with 'Q' then the frame remains live. As
278 ;; there is no perceptible speed difference of coming back from
279 ;; either a closed or deleted speedbar frame the following will
280 ;; force a delete-frame even if you are only closing it.
281 (defun sy-speedbar-kill ()
282 (when (frame-live-p speedbar-frame)
283 (delete-frame speedbar-frame)))
285 (add-hook 'speedbar-before-delete-hook #'sy-speedbar-kill)
288 ;:*======================
290 ;; Trying to get compilation buffers to recognise ANSI colour
291 ;; sequences because GCC. Doesn't seem to work. Probably have to
292 ;; stick to `GCC_COLORS= make'
293 (defun sy/comint-hooks ()
294 (ansi-color-for-comint-mode-on)
297 (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
298 (add-hook 'comint-mode-hook #'sy/comint-hooks)
299 (add-hook 'compilation-mode-hook #'sy/comint-hooks)
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 4)
307 ;:*======================
310 compilation-always-signal-completion t
311 mode-compile-make-program "GCC_COLORS= make"
312 compilation-read-command t
313 compilation-window-height 10
314 compile-command "GCC_COLORS= make")
316 ;:*======================
319 ;; #'vc-load-vc-hooks brings in vc-xemacs which adds this hook. I
320 ;; would never need it.
321 (remove-hook 'find-file-hooks 'vc-xemacs-hg-find-file-hook)
323 ;; I pretty much only use git now so there's no point in VC trying to
324 ;; handle any other type.
325 vc-handled-backends '(GIT)
326 vc-follow-symlinks t)
328 ;:*======================
329 ;:* Ediff & Diff-mode
332 (setq ediff-use-toolbar-p t
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 ; :*======================
351 eshell-directory-name
352 (file-name-as-directory
353 (expand-file-name "eshell" user-init-directory))
354 eshell-ask-to-save-history 'always
355 eshell-save-history-on-exit t
356 eshell-banner-message (concat "Welcome to Eshell on "
359 (shell-command-to-string "uname -rs")
363 eshell-hist-ignoredups t
364 eshell-modules-list '(eshell-alias
381 (defun sy-eshell-bol-maybe (&optional prompt)
382 "*Move point to beginning of command or bol if there already.
383 If at bol, move point to beginning of command.
384 Optional arg, PROMPT is a regexp of your eshell prompt."
386 (let* ((prompt (or prompt "^.+ [$%] "))
387 (lbpos (point-at-bol))
388 (prspos (save-excursion
390 (search-forward-regexp prompt (point-at-eol) t)))
395 ((= cpos (or prspos 0))
400 (eval-when-compile (defvar eshell-mode-map))
401 (defun sy-eshell-bol-maybe-key ()
402 (define-key eshell-mode-map [(control ?a)] 'sy-eshell-bol-maybe))
404 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe)
405 (add-hook 'eshell-mode-hook #'sy-eshell-bol-maybe-key t)
406 (add-hook 'eshell-output-filter-functions #'eshell-handle-ansi-color)
408 (defun sy-esh-cdl (&optional type)
409 "Eshell function to find current kernel's build or source dir.
411 Non-nil TYPE means find the current kernel's build directory, otherwise
412 find the source directory."
413 (let* ((base "/lib/modules/")
414 (ver (substring (shell-command-to-string "uname -r") 0 -1))
415 (dir (file-name-as-directory
423 "Change directory to current kernel source directory.
425 Convenience function to use with Eshell."
430 "Change directory to current kernel build directory.
432 Convenience function to use with Eshell."
436 ; :*======================
437 ; :* FFAP -- Find File At Point (keybindings in 90-keys.el)
439 ;; Make sure ffap does NOT get in my way...
440 (setq ffap-bindings nil)
442 ffap-machine-p-known 'accept
443 ffap-machine-p-unknown 'accept
444 ffap-machine-p-local 'accept)
447 ;:*======================
449 (require 'auto-insert-tkld)
451 (setq auto-insert-alist '(("\\.texi\\(nfo\\)?$" . "TeXinfo")
454 ("\\.h$" . "C Header")
455 ("\\.el$" . "Emacs Lisp")
456 ("[Mm]akefile" . "Makefile")
458 ("\\.pl$" . "Perl")))
460 (setq auto-insert-type-alist '(("TeXinfo" . "texinfo-insert.texi")
462 ("C Header" . "h-insert.h")
463 ("C++" . "c++-insert.cc")
464 ("Emacs Lisp" . "elisp-insert.el")
465 ("Makefile" . "makefile.inc")
466 ("Perl" . "perl-insert.pl")
467 ("Sh" . "sh-insert.sh")))
469 (add-to-list 'auto-insert-path '"~/documents/Templates/")
471 ;; Don't auto-insert into AucTeX style .els
472 (defadvice TeX-auto-store (around no-auto-insert activate)
473 "Ensure auto-insert is deactivated"
474 (let ((auto-insert-automatically nil))
476 (message "Auto-Insert initialised!")
478 ;:*=======================
483 ;:*======================
485 (defvar sxell-initialised-flag)
486 (defvar sxell-download-directory)
487 (when (and (featurep '(and sxemacs postgresql))
488 (fboundp 'ffi-defun))
490 (setq sxell-initialised-flag t
491 sxell-download-directory
492 (file-name-as-directory (expand-file-name "download/SXEmacs"
493 (user-home-directory)))))
494 ;:*======================
498 (defun sy-epa-export-key ()
499 "Wrapper for `epa-export-keys' to export ASCII armoured keys."
502 (call-interactively #'epa-export-keys)))
504 ;:*=======================
505 ;:* Howm thing. (this needs mule, but that is default so no biggie)
509 howm-directory (file-name-as-directory
510 (expand-file-name "howm" user-init-directory))
511 howm-keyword-file (expand-file-name "howm-keys" user-init-directory)
512 howm-history-file (expand-file-name "howm-history" user-init-directory))
514 ;; howm has the unfortunate name that ends in `wm' which is what
515 ;; winmgr-mode uses, so nuke winmgr-mode from auto-mode-alist
516 (remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
518 ;; Another problem with howm... it fucks up window configuration
520 (defadvice howm-keyword-search (before howm-save-kw (&rest args) activate)
521 "Save window configuration before viewing howm buffers."
522 (window-configuration-to-register ?h))
524 (defadvice howm-list-grep-fixed (before howm-save-win1 (&rest args) activate)
525 "Save window configuration before viewing howm buffers."
526 (window-configuration-to-register ?h))
528 (defadvice howm-list-grep (before howm-save-win (&rest args) activate)
529 "Save window configuration before viewing howm buffers."
530 (window-configuration-to-register ?h))
532 (defadvice howm-list-todo (before howm-save-win (&rest args) activate)
533 "Save window configuration before viewing howm buffers."
534 (window-configuration-to-register ?h))
536 (defadvice howm-list-active-todo (before howm-save-win (&rest args) activate)
537 "Save window configuration before viewing howm buffers."
538 (window-configuration-to-register ?h))
540 (defadvice riffle-kill-buffer (after howm-restore-win (&rest args) activate)
541 "Restore the original window configuration."
542 (jump-to-register ?h))
544 ;; howm fucks up font-lock'ing like you wouldn't believe, adding a
545 ;; call to `turn-on-font-lock' here at least restores a certain level
547 (defun turn-on-howm-mode ()
551 (defun turn-off-howm-mode ()
555 ;; Turn it on where I need it
556 (add-hook 'lisp-interaction-mode-hook #'turn-on-howm-mode)
557 (add-hook 'text-mode-hook #'turn-on-howm-mode)
558 (add-hook 'latex-mode-hook #'turn-on-howm-mode)
559 (add-hook 'c-mode-hook #'turn-on-howm-mode)
560 (add-hook 'sh-mode-hook #'turn-on-howm-mode)
561 ;; You gotta be fooking kidding me, this prevents lisp-initd.el from
562 ;; compiling the generated .el (moved to init.el)
563 ;; (add-hook 'emacs-lisp-mode-hook #'turn-on-howm-mode)
565 ;; Turn it off where I don't
566 ;; I actually would love to have howm in all of these modes, but I
567 ;; cannot get the font-locking working properly with it on
568 (add-hook 'html-mode-hook #'turn-off-howm-mode)
569 (add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
570 (add-hook 'message-mode-hook #'turn-off-howm-mode)
571 (add-hook 'change-log-mode-hook #'turn-off-howm-mode)
573 ;:*=====================
575 ;; save/load snapshot of application to/from text
577 ;; (1) M-x snap-record on application, e.g. Gnus.
578 ;; (2) Yank (C-y) on any buffer, e.g. *scratch* or ~/memo.txt.
579 ;; (3) M-x snap-play on yanked text ==> snapshot (1) is restored.
581 ;; I have #'snap-record bound to `H-s r' (90-keys.el)
585 (setq snap-abbreviate-environment-variables
586 '("EMCHAT" "JAVA_HOME" "EL" "XPKGS" "MPKGS" "PKGS" "QTDIR"
587 "BLDS" "SXESITE" "SXEWD" "SYdrive" "SYdrop" "HOME"))
589 (defadvice snap-abbreviate-file-name (around env-var (raw-path) activate)
591 (let ((path (expand-file-name raw-path))
592 (rules (mapcar #'(lambda (var)
593 (let ((val (getenv var)))
595 (cons (concat "^" (regexp-quote val))
596 (format "${%s}" var)))))
597 snap-abbreviate-environment-variables)))
599 (when (and r (string-match (car r) path))
600 (setq ad-return-value
601 (replace-regexp-in-string (car r) (cdr r) path))))
605 (eval-after-load "bookmark"
607 (ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
608 (ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
611 (setq ffap-url-regexp snap-ffap-url-regexp)
612 (setq ffap-url-fetcher snap-ffap-url-fetcher)
614 ;:*=======================
615 ;:* ElDoc (handy thingy dingy for lisp programming)
616 ;; displays function args and var doc strings in echo area
617 ;(setq eldoc-use-idle-timer-p nil)
618 ;(autoload #'turn-on-eldoc-mode "eldoc" nil t)
619 ;(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode)
620 ;(add-hook 'lisp-interaction-mode-hook #'turn-on-eldoc-mode)
622 ;:*=======================
626 ;; You can't follow xrefs via keyboard, so...
627 ;; See 90-keys.el for the bindings
628 (defun sy:Manual-follow-xref-kbd ()
629 "Invoke `manual-entry' on the cross-reference at point."
631 (let* ((ext (extent-at (point)))
632 (data (and ext (extent-property ext 'man))))
633 (if (eq (car-safe data) 'Manual-follow-xref)
635 (error 'search-failed "no manual cross-reference there."))
636 (or (manual-entry (extent-string ext))
637 ;; Couldn't find it, try other sections.
638 (and (string-match "[ \t]*([^)]+)\\'" (extent-string ext))
640 (message "No entries found for %s; checking other sections..."
643 (substring (extent-string ext) 0 (match-beginning 0))
646 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*
647 (message "packages loaded")