(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))
(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)
(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)
(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))))
(autoload 'whitespace-mode "whitespace-mode" nil t)
(autoload 'whitespace-incremental-mode "whitespace-mode" nil t)
(require 'func-menu)
(add-hook 'find-file-hooks 'fume-setup-buffer)
(add-hook 'Manual-mode-hook 'turn-on-fume-mode)
(define-key fume-mode-map [(control button3)] #'mouse-function-menu)
(setq
fume-display-in-modeline-p t
fume-menu-path '("View"))
(when (featurep 'menubar)
(require 'recent-files)
(setq recent-files-non-permanent-submenu t
recent-files-menu-path '("File")
recent-files-add-menu-before "Insert File..."
recent-files-save-file
(expand-file-name ".recent-files.el" user-init-directory)
recent-files-dont-include
'(#r"\.config/sxemacs/\(howm\|diary\).*$"
#r"sxemacs/timelog$"
#r"info/dir$"
#r"\.\(newsrc*\|bbdb\)$"
#r"init\.d\.el"))
(recent-files-initialize))
(require 'jka-compr)
(jka-compr-install)
(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)))
(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)
(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 'utf-8)))
(savehist-mode 1))
(when running-xemacs
(require 'redo)
(global-set-key [(control f2)] 'redo))
(require 'scroll-in-place)
(require 'pending-del)
(turn-on-pending-delete nil)
(require 'newcomment)
(global-set-key '(control f12) 'comment-or-uncomment-region)
(global-set-key '(meta f12) 'comment-or-uncomment-region)
(require 'paren)
(paren-set-mode 'paren)
(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"))
(autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t)
(require 'footnote)
(require 'filladapt)
(setq-default filladapt-mode t)
(setq filladapt-fill-column-tolerance 5)
(add-hook 'c-mode-hook 'turn-off-filladapt-mode)
(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-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-image)
(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.")
(setq speedbar-frame-plist
(plist-put speedbar-frame-plist 'name "Speedbar::Frame"))
(setq speedbar-frame-plist
(plist-put speedbar-frame-plist 'scrollbar-height 0))
(setq speedbar-frame-plist
(plist-put speedbar-frame-plist 'scrollbar-width 0))
(setq speedbar-frame-plist
(plist-put speedbar-frame-plist 'width 25))
(defalias 'dframe-reposition-frame-xemacs 'dframe-reposition-frame-emacs)
(setq speedbar-default-position 'right)
(defun sy-speedbar-kill ()
(when (frame-live-p speedbar-frame)
(delete-frame speedbar-frame)))
(add-hook 'speedbar-before-delete-hook #'sy-speedbar-kill)
(defun sy/comint-hooks ()
(ansi-color-for-comint-mode-on)
(fast-lock-mode 1)
(font-lock-mode 1))
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
(add-hook 'comint-mode-hook #'sy/comint-hooks)
(add-hook 'compilation-mode-hook #'sy/comint-hooks)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-hook 'shell-mode-hook 'turn-on-font-lock)
(setq sh-basic-offset 4)
(setq
compilation-always-signal-completion t
mode-compile-make-program "GCC_COLORS= make"
compilation-read-command t
compilation-window-height 10
compile-command "GCC_COLORS= make")
(vc-load-vc-hooks)
(remove-hook 'find-file-hooks 'vc-xemacs-hg-find-file-hook)
(setq
vc-handled-backends '(GIT)
vc-follow-symlinks t)
(require 'ediff)
(require 'diff-mode)
(setq ediff-use-toolbar-p t
ediff-custom-diff-options "-u"
ediff-window-setup-function 'ediff-setup-windows-plain)
(setq diff-switches "-u")
(require 'tramp)
(setq tramp-default-method "ssh"
tramp-auto-save-directory "~/.autosave/"
tramp-remote-path
'("/usr/lib/pkgusr"
"/usr/bin"
"/bin"
"/usr/X11R6/bin"))
(setq
eshell-directory-name
(file-name-as-directory
(expand-file-name "eshell" user-init-directory))
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-script
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)))))
(eval-when-compile (defvar eshell-mode-map))
(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))
(require 'ffap)
(setq ffap-bindings nil)
(global-set-key [f3] #'find-file-at-point)
(global-set-key [(control x) ?4 f3] #'ffap-other-window)
(global-set-key [(control x) ?5 f3] #'ffap-other-frame)
(global-set-key [(shift button3)] #'ffap-at-mouse)
(global-set-key [(control shift button3)] #'ffap-menu)
(setq
ffap-machine-p-known 'accept
ffap-machine-p-unknown 'accept
ffap-machine-p-local 'accept)
(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 '"~/documents/Templates/")
(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!")
(require 'sy-git)
(require 'git)
(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)))))
(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)
(require 'howm)
(setq
howm-directory (file-name-as-directory
(expand-file-name "howm" user-init-directory))
howm-keyword-file (expand-file-name "howm-keys" user-init-directory)
howm-history-file (expand-file-name "howm-history" user-init-directory))
(remove-alist 'auto-mode-alist "\\.[^/]*wm2?\\(?:rc\\)?\\'")
(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)
(global-set-key [(control ?c) ?t] #'howm-list-active-todo)
(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))
(defun turn-on-howm-mode ()
(turn-on-font-lock)
(howm-mode 1))
(defun turn-off-howm-mode ()
(howm-mode 0)
(font-lock-mode))
(add-hook 'lisp-interaction-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)
(add-hook 'html-mode-hook #'turn-off-howm-mode)
(add-hook 'texinfo-mode-hook #'turn-off-howm-mode)
(add-hook 'message-mode-hook #'turn-off-howm-mode)
(add-hook 'change-log-mode-hook #'turn-off-howm-mode)
(require 'snap)
(global-set-key [(hyper ?s) ?r] #'snap-record)
(setq snap-abbreviate-environment-variables
'("EMCHAT" "JAVA_HOME" "EL" "XPKGS" "MPKGS" "PKGS" "QTDIR"
"BLDS" "SXESITE" "SXEWD" "SYdrive" "SYdrop" "HOME"))
(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))))
(eval-after-load "bookmark"
(progn
(ad-enable-advice 'bookmark-buffer-file-name 'around 'with-snap)
(ad-enable-advice 'bookmark-jump-noselect 'around 'with-snap)))
(setq ffap-url-regexp snap-ffap-url-regexp)
(setq ffap-url-fetcher snap-ffap-url-fetcher)
(require 'man)
(defun sy:Manual-follow-xref-kbd ()
"Invoke `manual-entry' on the cross-reference at point."
(interactive)
(let* ((ext (extent-at (point)))
(data (and ext (extent-property ext 'man))))
(if (eq (car-safe data) 'Manual-follow-xref)
(eval data)
(error 'search-failed "no manual cross-reference there."))
(or (manual-entry (extent-string ext))
(and (string-match "[ \t]*([^)]+)\\'" (extent-string ext))
(progn
(message "No entries found for %s; checking other sections..."
(extent-string ext))
(manual-entry
(substring (extent-string ext) 0 (match-beginning 0))
nil t))))))
(define-key Manual-mode-map [(control return)] #'sy:Manual-follow-xref-kbd)
(define-key Manual-mode-map [button1] #'Manual-follow-xref)
(message "packages loaded")
Copyright © 2020 Steve Youngs
Verbatim copying and distribution is permitted in any medium,
providing this notice is preserved.
Last modified: Sat Apr 18 21:42:24 AEST 2020