1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <!-- Created by htmlize-1.34 in css mode. -->
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <title>12-misc.el</title>
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8 <meta name="author" content="Steve Youngs" />
9 <meta name="owner" content="steve@sxemacs.org" />
10 <style type="text/css">
14 background-color: #000000;
17 /* font-lock-comment-face */
21 /* font-lock-doc-string-face */
25 /* font-lock-function-name-face */
30 /* font-lock-keyword-face */
34 /* font-lock-reference-face */
38 /* font-lock-string-face */
42 /* font-lock-type-face */
46 /* font-lock-variable-name-face */
52 background-color: inherit;
55 text-decoration: underline;
59 background-color: #FD00FD;
60 text-decoration: underline;
63 background-color: #000000;
64 text-decoration: none;
71 <span class="comment">;; 12-misc --- Miscellaneous Settings
73 <span class="comment">;; Copyright (C) 2007 - 2020 Steve Youngs
75 <span class="comment">;; Author: Steve Youngs <<a href="mailto:steve@sxemacs.org">steve@sxemacs.org</a>>
76 ;; Maintainer: Steve Youngs <<a href="mailto:steve@sxemacs.org">steve@sxemacs.org</a>>
77 ;; Created: <2007-12-02>
78 ;; Time-stamp: <Saturday Apr 18, 2020 21:07:03 steve>
79 ;; Download: <<a href="https://downloads.sxemacs.org/SYinits">https://downloads.sxemacs.org/SYinits</a>>
80 ;; HTMLised: <<a href="https://www.sxemacs.org/SYinits/12-misc.html">https://www.sxemacs.org/SYinits/12-misc.html</a>>
81 ;; Git Repo: git clone https://git.sxemacs.org/syinit
82 ;; Keywords: init, compile
84 <span class="comment">;; This file is part of SYinit
86 <span class="comment">;; Redistribution and use in source and binary forms, with or without
87 ;; modification, are permitted provided that the following conditions
90 ;; 1. Redistributions of source code must retain the above copyright
91 ;; notice, this list of conditions and the following disclaimer.
93 ;; 2. Redistributions in binary form must reproduce the above copyright
94 ;; notice, this list of conditions and the following disclaimer in the
95 ;; documentation and/or other materials provided with the distribution.
97 ;; 3. Neither the name of the author nor the names of any contributors
98 ;; may be used to endorse or promote products derived from this
99 ;; software without specific prior written permission.
101 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
102 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
103 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
105 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
106 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
107 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
108 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
109 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
110 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
111 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113 <span class="comment">;;; Commentary:
115 ;; For stuff that just doesn't seem to fit anywhere else.
118 <span class="comment">;;; Credits:
120 ;; The HTML version of this file was created with Hrvoje Niksic's
121 ;; htmlize.el which is part of the XEmacs "text-modes" package.
124 <span class="comment">;;; Todo:
128 ;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
129 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Why type 'y e s RET' or 'n o RET' when 'y' or 'n' will do.
130 </span>(fset 'yes-or-no-p 'y-or-n-p)
132 (setq x-allow-sendevents t)
134 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
135 ;: Enable the command `</span><span class="comment"><span class="reference">narrow-to-region</span></span><span class="comment">' ("C-x n n")
136 ;(setq narrow-to-region t)
137 </span>(put 'narrow-to-region 'disabled nil)
139 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
140 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Enable `</span><span class="comment"><span class="reference">erase-buffer</span></span><span class="comment">'
141 </span>(put 'erase-buffer 'disabled nil)
143 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
144 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Put the mouse selection in the kill buffer
145 ;: Jan Vroonhof <<a href="mailto:vroonhof@frege.math.ethz.ch">vroonhof@frege.math.ethz.ch</a>>
146 </span>(<span class="keyword">defun</span> <span class="function-name">mouse-track-drag-copy-to-kill</span> (event count)
147 "<span class="doc-string">Copy the dragged region to the kill ring</span>"
148 (<span class="keyword">let</span> ((region (default-mouse-track-return-dragged-selection event)))
149 (<span class="keyword">when</span> region
150 (copy-region-as-kill (car region)
153 (add-hook 'mouse-track-drag-up-hook 'mouse-track-drag-copy-to-kill)
155 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
156 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Keep the mouse pointer away from the text cursor
157 </span>(<span class="keyword">require</span> '<span class="reference">avoid</span>)
158 (mouse-avoidance-mode 'exile)
160 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
161 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Frame title.
162 </span>(setq frame-title-format
163 (concat "<span class="string">-={%b}=- </span>"
164 (construct-emacs-version-name)
165 "<span class="string"> [</span>"
166 (and-boundp 'sxemacs-codename
168 "<span class="string">]</span>"))
170 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
171 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Additions to the menubar.
172 </span>(<span class="keyword">when</span> (<span class="keyword">featurep</span> '<span class="reference">menubar</span>)
173 (<span class="keyword">require</span> '<span class="reference">big-menubar</span>)
175 <span class="comment">;; Get rid of stuff from big-menubar that I don't like/use
176 </span> (delete-menu-item '("<span class="string">Top</span>"))
177 (delete-menu-item '("<span class="string"><<</span>"))
178 (delete-menu-item '("<span class="string"> | </span>"))
179 (delete-menu-item '("<span class="string">>></span>"))
180 (delete-menu-item '("<span class="string">Bot</span>"))
181 (delete-menu-item '("<span class="string">Motion</span>"))
183 <span class="comment">;; Add back the "Motion" menu, but as a submenu under "Cmds"
184 </span> <span class="comment">;; Motion menu.
186 '("<span class="string">Cmds</span>")
187 '("<span class="string">Motion</span>"
188 ["<span class="string">Goto Mark</span>" exchange-point-and-mark (mark t)]
189 ["<span class="string">Goto Line...</span>" goto-line t]
190 "<span class="string">---</span>"
191 ["<span class="string">End of Balanced Parentheses ( )</span>" forward-list t]
192 ["<span class="string">Beginning of Balanced Parentheses ( )</span>" backward-list t]
193 ["<span class="string">Next Opening Parenthesis (</span>" down-list t]
194 ["<span class="string">Previous Opening Parenthesis (</span>" backward-up-list t]
195 ["<span class="string">Next Closing Parenthesis )</span>" up-list t]
196 "<span class="string">---</span>"
197 ["<span class="string">End of Balanced Expression</span>" forward-sexp t]
198 ["<span class="string">Beginning of Balanced Expression</span>" backward-sexp t]
199 "<span class="string">---</span>"
200 ["<span class="string">End of Function</span>" end-of-defun t]
201 ["<span class="string">Beginning of Function</span>" beginning-of-defun t]
202 "<span class="string">---</span>"
203 ["<span class="string">Next Page</span>" forward-page t]
204 ["<span class="string">Previous Page</span>" backward-page t]
205 "<span class="string">---</span>"
206 ["<span class="string">End of Buffer</span>" end-of-buffer t]
207 ["<span class="string">Beginning of Buffer</span>" beginning-of-buffer t]
208 "<span class="string">---</span>"
209 ["<span class="string">Save Current Position...</span>" point-to-register t]
210 ["<span class="string">Goto Saved Position...</span>" register-to-point t]
211 "<span class="string">---</span>"
212 ["<span class="string">Set Marker...</span>" set-user-marker t]
213 ["<span class="string">Goto Marker...</span>" goto-user-marker t]
214 ["<span class="string">List Markers</span>" list-markers t]
215 "<span class="string">---</span>"
216 ["<span class="string">Set Goal Column</span>" set-goal-column t]
217 ["<span class="string">Cancel Goal Column</span>" (set-goal-column t) goal-column])
218 "<span class="string">Abbrev</span>"))
221 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
222 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> create a Kill-Ring menu
223 </span>(<span class="keyword">when</span> (<span class="keyword">featurep</span> '<span class="reference">menubar</span>)
225 (defvar yank-menu-length 40
226 "<span class="string">*Maximum length of an item in the menu for select-and-yank.</span>")
227 (defun select-and-yank-filter (menu)
228 (<span class="keyword">let*</span> ((count 0))
231 #'(<span class="keyword">lambda</span> (str)
232 (<span class="keyword">if</span> (> (length str) yank-menu-length)
233 (setq str (substring str 0 yank-menu-length)))
234 (<span class="keyword">prog1</span>
240 (list 'insert (list 'current-kill count t)))
242 (setq count (1+ count))))
244 (add-submenu '("<span class="string">Edit</span>") '("<span class="string">Kill-Ring</span>"
245 <span class="reference">:included</span> kill-ring
246 <span class="reference">:filter</span> select-and-yank-filter)))
248 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
249 ;: resize-minibuffer-mode makes the minibuffer automatically
250 ;: resize as necessary when it's too big to hold its contents.
251 ;(autoload 'resize-minibuffer-mode "rsz-minibuf" nil t)
252 ;(resize-minibuffer-mode)
253 ;(setq resize-minibuffer-window-exactly nil)
254 ;(setq minibuffer-max-depth nil)
255 </span>(setq resize-minibuffer-mode t)
256 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
257 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> don't invert colors when grabbing a password
258 ;: (because sometimes it screws up and leaves the frame
259 ;: with dorked up colors).
260 </span>(setq passwd-invert-frame-when-keyboard-grabbed nil)
262 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
263 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> VI-style matching parenthesis
264 ;: From Eric Hendrickson edh @ med.umn.edu
265 </span>(<span class="keyword">defun</span> <span class="function-name">match-paren</span> (arg)
266 "<span class="doc-string">Go to the matching parenthesis if on parenthesis.</span>"
267 (interactive "<span class="string">p</span>")
268 (<span class="keyword">cond</span> ((looking-at "<span class="string">[([{]</span>") (forward-sexp 1) (backward-char))
269 ((looking-at "<span class="string">[])}]</span>") (forward-char) (backward-sexp 1))))
270 (global-set-key '(control f1) 'match-paren)
272 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
273 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Inserting elisp Comments
274 ; by Jonas Luster <mailto:jonas @ nethammer.qad.org>
275 </span>(<span class="keyword">defun</span> <span class="function-name">elispcomment</span> ()
276 <span class="comment">;</span><span class="comment"><span class="reference">:*=====================</span></span><span class="comment">
277 </span> (interactive)
278 (insert "<span class="string">;</span><span class="string"><span class="reference">:*=======================</span></span><span class="string">\n</span>")
279 (insert "<span class="string">;</span><span class="string"><span class="reference">:*</span></span><span class="string"> </span>" (setq str (read-input "<span class="string">Comment: </span>")) "<span class="string">\n</span>")
280 (insert "<span class="string">\n</span>"))
281 (global-set-key '(control f3) 'elispcomment)
283 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
284 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Time-Stamp
285 </span>(<span class="keyword">require</span> '<span class="reference">time-stamp</span>)
286 (add-hook 'write-file-hooks 'time-stamp)
287 (set 'time-stamp-active t)
288 (set 'time-stamp-format "<span class="doc-string">%a %3b %2d, %4y %02H:%02M:%02S %u</span>")
290 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
291 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Image formats
292 </span>(<span class="keyword">require</span> '<span class="reference">image-mode</span>)
293 <span class="comment">;; Needed to load this earlier for some reason that I have long since
294 ;; forgotten, so it is now in 01-vars-sy.el
295 ;;(require 'ffi-wand)
297 <span class="comment">;; If you want to use #'Wand-display whenever you C-x C-f imagefile
298 ;; uncomment this. It's cool and all, but there are definitely times
299 ;; when you don't want to view images with #'Wand-display. Editing
300 ;; XPM files for example. Have you seen xpm-mode? it's awesome.
301 ;(Wand-find-file-enable)
302 ;; But sometimes you do want it so...
303 </span>(global-set-key [(super ?x) (super ?f)] #'Wand-display)
305 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
306 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> ffi-magic
307 ;; Automatic coding-system detection via libmagic
308 </span>(<span class="keyword">require</span> '<span class="reference">ffi-magic</span>)
309 (magic:find-file-magic-alist-enable)
311 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
312 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Dired enhancements.
313 </span>(<span class="keyword">require</span> '<span class="reference">dired</span>)
314 (setq dired-ls-locale "<span class="doc-string">POSIX</span>")
316 <span class="comment">;; Pack and Unpack tarballs
317 </span>(<span class="keyword">require</span> '<span class="reference">dired-tar</span>)
318 (setq dired-tar-compress-with 'xz)
320 <span class="comment">;; FFI/libWand for image files in Dired
321 </span>(<span class="keyword">defun</span> <span class="function-name">sy-dired-wand</span> ()
323 (<span class="keyword">let</span> ((file (dired-get-filename)))
324 (Wand-display file)))
326 (<span class="keyword">define-key</span> <span class="variable-name">dired-mode-map</span> [?b] #'sy-dired-wand)
328 <span class="comment">;; Play audio files directly from dired.
329 </span>(<span class="keyword">defun</span> <span class="function-name">sy-dired-play-audio</span> ()
331 (<span class="keyword">let</span> ((file (dired-get-filename)))
332 (<span class="keyword">when</span> (magic:file-audio-p file)
333 (<span class="keyword">let</span> ((stream (make-media-stream <span class="reference">:file</span> file)))
334 (play-media-stream stream)))))
336 (<span class="keyword">define-key</span> <span class="variable-name">dired-mode-map</span> [(control ?c) ?p] #'sy-dired-play-audio)
338 <span class="comment">;(setq dired-use-ls-dired t)
339 ;(setq dired-listing-switches "-alih")
341 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
342 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Change some modeline indicators
343 </span>(setq pending-delete-modeline-string nil)
344 (setq fume-mode-line-string nil)
345 (setq filladapt-mode-line-string nil)
346 (setq mouse-avoidance-mode-line-string nil)
347 (add-minor-mode 'abbrev-mode "<span class="doc-string"> Ab</span>")
348 (add-hook 'lisp-interaction-mode-hook #'(<span class="keyword">lambda</span> () (setq mode-name "<span class="string">LI</span>")))
350 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
351 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Force efs into passive ftp because of my firewall
352 </span>(setq efs-use-passive-mode t)
354 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
355 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> ibuffer - replacement for buffer-menu
356 </span>(<span class="keyword">require</span> '<span class="reference">ibuffer</span>)
359 ibuffer-default-sorting-mode 'major-mode
360 ibuffer-fontification-level t
361 ibuffer-saved-filter-groups
362 <span class="comment">;; First match wins.
363 </span> '(("<span class="string">My-ibuffer-grps</span>"
364 ("<span class="string">ChangeLog</span>"
365 (mode . change-log-mode))
366 ("<span class="string">Dired</span>"
368 ("<span class="string">Programming</span>"
370 (mode . emacs-lisp-mode)
377 ("<span class="string">Documentation</span>"
380 (mode . hyper-apropos-help-mode)
381 (mode . hyper-apropos-mode)
383 (mode . Manual-mode)))
384 ("<span class="string">Riece</span>"
386 (mode . riece-channel-list-mode)
387 (mode . riece-channel-mode)
388 (mode . riece-command-mode)
389 (mode . riece-dialogue-mode)
390 (mode . riece-others-mode)
391 (mode . riece-user-list-mode)))
392 ("<span class="string">Gnus</span>"
394 (mode . message-mode)
396 (mode . gnus-group-mode)
397 (mode . gnus-summary-mode)
398 (mode . gnus-article-mode)))
399 ("<span class="string">Fundamental</span>"
400 (mode . fundamental-mode))
403 (add-hook 'ibuffer-mode-hooks
404 (<span class="keyword">lambda</span> ()
405 (ibuffer-switch-to-saved-filter-groups "<span class="string">My-ibuffer-grps</span>")
406 (ibuffer-add-to-tmp-hide "<span class="string">\\*scratch\\*</span>")))
408 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
409 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Sawfish mode
410 </span>(<span class="keyword">require</span> '<span class="reference">sawfish</span>)
411 (add-to-list 'auto-mode-alist '("<span class="string">\\.sawfishrc$</span>" . sawfish-mode))
412 (add-to-list 'auto-mode-alist '("<span class="string">\\.jl$</span>" . sawfish-mode))
414 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
415 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> from.el - check whose sent us mail
416 ;; Not that much use anymore now that most of my mail is via IMAP so
417 ;; doesn't go through my local server or spool.
418 </span>(<span class="keyword">require</span> '<span class="reference">from</span>)
420 from-mailspools '("<span class="string">~/mail/INBOX</span>")
421 from-use-other-window nil
422 from-quit-command 'kill-buffer
423 from-highlight-regexp
424 #r"<span class="doc-string">Merge-Req\(?:uest\)?\|P\(?:-Req\|atch\|ull-Req\)\|SXEmacs\|patch</span>")
426 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
427 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> PS-Print
428 </span>(<span class="keyword">require</span> '<span class="reference">ps-print</span>)
429 (<span class="keyword">require</span> '<span class="reference">ps-mule</span>)
430 (<span class="keyword">require</span> '<span class="reference">ps-bdf</span>)
431 (<span class="keyword">require</span> '<span class="reference">lpr</span>)
433 bdf-directory-list '("<span class="string">/usr/share/fonts/bdf</span>")
434 ps-multibyte-buffer 'bdf-font-except-latin
436 printer-name "<span class="doc-string">Duplex_Colour</span>")
438 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
439 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Line and Column numbers.
440 </span>(line-number-mode 1)
441 (column-number-mode 1)
443 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
444 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Setting initial default-directory.
445 </span>(setq default-directory (file-name-as-directory (user-home-directory)))
447 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
448 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Sane ChangeLogs
449 </span>(<span class="keyword">when</span> (<span class="keyword">featurep</span> '<span class="reference">mule</span>)
450 <span class="comment">;; Cater for the majority of the World who don't have names and
451 </span> <span class="comment">;; languages that fit nicely into US-ASCII.
452 </span> (add-to-list 'file-coding-system-alist
453 (cons "<span class="string">ChangeLog\\(.?[[</span><span class="string"><span class="reference">:alnum:</span></span><span class="string">][</span><span class="string"><span class="reference">:punct:</span></span><span class="string">]]+\\)?</span>"
456 <span class="comment">;; Try to have even the oddly named ChangeLogs in change-log-mode
459 '("<span class="string">ChangeLog\\(.?[[</span><span class="string"><span class="reference">:alnum:</span></span><span class="string">][</span><span class="string"><span class="reference">:punct:</span></span><span class="string">]]+\\)?</span>" . change-log-mode))
461 <span class="comment">;; My sy-git.el has nice font-locking for git logs, so use it outside
462 ;; of sy-git-mode as well.
463 </span>(<span class="keyword">defun</span> <span class="function-name">sy-change-log-mode-hook</span> ()
464 (<span class="keyword">save-excursion</span>
465 (<span class="keyword">when</span> (re-search-forward "<span class="string">^commit [0-9a-f]+</span>" 1000 t)
466 (set (make-local-variable 'font-lock-defaults)
467 '(sy-git-log-font-lock-keywords t t)))))
469 (add-hook 'change-log-mode-hook #'sy-change-log-mode-hook)
471 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
472 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Directory Abbrevs
473 ;; Love this. It saves me so much time.
474 </span>(setq directory-abbrev-alist
475 `(("<span class="string">^/instcore</span>" . ,(concat (car emacs-roots)
476 "<span class="string">share/sxemacs-</span>"
477 emacs-program-version))
478 ("<span class="string">^/instpkg</span>" . ,(concat (car emacs-roots)
479 "<span class="string">share/sxemacs</span>"))
480 ("<span class="string">^/prog</span>" . "<span class="string">~/programming</span>")
481 ("<span class="string">^/linux</span>" . "<span class="string">/usr/src/kernel/linux</span>")
482 ("<span class="string">^/src</span>" . "<span class="string">/usr/src</span>")
483 ("<span class="string">^/sxe</span>" . "<span class="string">/home/steve/programming/SXEmacs</span>")
484 ("<span class="string">^/core</span>" . "<span class="string">/home/steve/programming/SXEmacs/core/sxemacs.git</span>")
485 ("<span class="string">^/web</span>" . "<span class="string">/home/steve/programming/SXEmacs/web/website</span>")
486 ("<span class="string">^/init</span>" . ,(expand-file-name "<span class="string">init.d</span>" user-init-directory))
487 ("<span class="string">^/blds</span>" . "<span class="string">/home/steve/programming/SXEmacs/core/BUILDS</span>")
488 ("<span class="string">^/lisp</span>" . "<span class="string">/home/steve/programming/lisp</span>")
489 ("<span class="string">^/pkgs</span>" . "<span class="string">/home/steve/programming/SXEmacs/packages</span>")
490 ("<span class="string">^/xpkgs</span>" . "<span class="string">/home/steve/programming/SXEmacs/packages/xemacs-packages</span>")
491 ("<span class="string">^/mpkgs</span>" . "<span class="string">/home/steve/programming/SXEmacs/packages/mule-packages</span>")))
493 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
494 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> The beginnings of procmail-mode.el.
496 ;; I can't remember who I stole this from, but if it was you, please
497 ;; let me know so I can give you the credit you deserve.
498 </span>(<span class="keyword">defvar</span> <span class="variable-name">procmail-font-lock-keywords</span>)
500 (<span class="keyword">define-derived-mode</span> <span class="function-name">procmail-mode</span> fundamental-mode "<span class="doc-string">Procmail</span>"
501 "<span class="doc-string">Major mode for editing procmail recipes.</span>"
503 (setq comment-start "<span class="string">#</span>")
504 (setq comment-start-skip "<span class="string">#[ \t]*</span>")
506 <span class="comment">;;register keywords
507 </span> (setq procmail-font-lock-keywords
508 (list '("<span class="string">#.*</span>"
509 . font-lock-comment-face)
510 '("<span class="string">^[\t ]*:.*</span>"
511 . font-lock-type-face)
512 '("<span class="string">[A-Za-z_]+=.*</span>"
513 . font-lock-keyword-face)
514 '("<span class="string">^[\t ]*\\*.*</span>"
515 . font-lock-doc-string-face)
516 '("<span class="string">\$[A-Za-z0-9_]+</span>"
517 . font-lock-function-name-face)))
520 (add-to-list 'auto-mode-alist '("<span class="string">\\.procmailrc$</span>" . procmail-mode))
522 <span class="comment">;; And because my ~/.procmailrc has lots of high ASCII to defeat
523 ;; Chinese SPAM I set its coding to binary.
524 </span>(<span class="keyword">when</span> (<span class="keyword">featurep</span> '<span class="reference">mule</span>)
525 (add-to-list 'file-coding-system-alist '("<span class="string">\\.procmailrc$</span>" . binary)))
527 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
528 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Build Reports
530 build-rpt-prompts '(("<span class="string">Status?: </span>"
531 ("<span class="string">Success</span>"
532 "<span class="string">Success (tests fail)</span>"
533 "<span class="string">Failure</span>"
534 "<span class="string">Failure (tests fail)</span>"
535 "<span class="string">OK (with issues)</span>")))
536 build-rpt-use-gnus-group "<span class="doc-string">nnml:sxemacs.builds</span>"
537 build-rpt-use-gnus-p t
538 build-rpt-make-output-files
539 '("<span class="string">/usr/src/sxemacs/make.err</span>"
540 "<span class="string">/usr/src/sxemacs/check.err</span>"
541 "<span class="string">/usr/src/sxemacs/install.err</span>"
544 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
545 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Set the frame geometry
546 </span>(<span class="keyword">unless</span> (getenv "<span class="string">XWEM_RUNNING</span>")
547 (setq default-frame-plist
548 '(name "<span class="string">SXEFrame</span>" width 90))
549 (setq initial-frame-plist '(width 90)))
552 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
553 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> The Beginnings of a Finance package
555 emoney-accounts-directory
556 (file-name-as-directory
557 (expand-file-name "<span class="string">emoney</span>" user-init-directory))
558 emoney-bank-url "<span class="doc-string">https://internetbanking.suncorpbank.com.au/</span>"
559 emoney-date-format "<span class="doc-string">%Y-%m-%d</span>"
560 emoney-default-account "<span class="doc-string">scorp-main.emy</span>"
561 emoney-recalculate-on-quit t
562 emoney-save-after-recalculate t
563 emoney-use-new-frame t)
565 (<span class="keyword">require</span> '<span class="reference">emoney</span>)
567 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
568 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Modeline enhancements.
570 ;; Reorganise the modeline so that the line and column numbers are on
571 ;; the left where you can see them. Also add a bit of colour to the
572 ;; left and right ID extents so they stand out.
573 </span>(<span class="keyword">when</span> (or (< emacs-minor-version 5)
574 (<span class="keyword">featurep</span> '<span class="reference">sxemacs</span>))
575 (setq-default modeline-buffer-identification
576 (list (cons modeline-buffer-id-left-extent
578 (list 'line-number-mode "<span class="string">L%l </span>")
579 (list 'column-number-mode "<span class="string">C%c </span>")
580 (list (cons -3 (list "<span class="string">%p</span>")))
581 "<span class="string">:</span>")))
582 (cons modeline-buffer-id-right-extent "<span class="string">%17b</span>")))
588 (<span class="keyword">if</span> (boundp 'modeline-multibyte-status)
589 "<span class="string">%C</span>" <span class="comment">;modeline-multibyte-status
590 </span> "<span class="string">NoMule</span>")
591 (cons modeline-modified-extent 'modeline-modified)
592 (cons modeline-buffer-id-extent 'modeline-buffer-identification)
593 "<span class="string"> </span>"
595 "<span class="string"> %[(</span>"
596 (cons modeline-minor-mode-extent
597 (list "" 'mode-name 'minor-mode-alist))
598 (cons modeline-narrowed-extent "<span class="string">%n</span>")
600 "<span class="string">)%]----</span>"
601 "<span class="string">-%-</span>"))
603 (set-extent-face modeline-buffer-id-left-extent 'font-lock-warning-face)
604 (set-extent-face modeline-buffer-id-right-extent 'font-lock-comment-face))
606 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
607 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Enable funky completion.
609 ;; This allows you to do things like type "M-x b-c-f RET" and it will
610 ;; expand to `</span><span class="comment"><span class="reference">byte-compile-file</span></span><span class="comment">'.
611 </span>(<span class="keyword">require</span> '<span class="reference">completer</span>)
613 <span class="comment">;</span><span class="comment"><span class="reference">:*======================</span></span><span class="comment">
614 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Misc Stuff that I haven't yet put anywhere permanent
616 ;; I used to have my browse-url setting here, but because of xdg that
617 ;; really isn't necessary anymore.
620 allow-deletion-of-last-visible-frame t
621 bookmark-default-file (expand-file-name "<span class="string">bookmarks</span>" user-init-directory)
623 complex-buffers-menu-p t
624 etalk-process-file "<span class="doc-string">talk</span>"
625 find-function-source-path nil
626 font-menu-ignore-scaled-fonts nil
628 mail-user-agent 'message-user-agent
629 modeline-scrolling-method 'scrollbar
630 progress-feedback-use-echo-area t
631 report-xemacs-bug-no-explanations t
633 lookup-syntax-properties nil)
635 (quietly-read-abbrev-file)
636 (add-hook 'text-mode-hook 'turn-on-auto-fill)
637 <span class="comment">;(customize-set-variable 'gutter-buffers-tab-visible-p nil)
638 </span>(setq gutter-buffers-tab-enabled nil)
639 (customize-set-variable 'user-mail-address "<span class="doc-string">steve@steveyoungs.com</span>")
640 (setq query-user-mail-address nil)
641 (blink-cursor-mode 1)
642 <span class="comment">;; (when (featurep 'mule)
643 ;; (set-language-environment "Latin-1"))
644 </span>(<span class="keyword">unless</span> (gnuserv-running-p)
646 (<span class="keyword">require</span> '<span class="reference">mozmail</span>)
648 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
649 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Info-mode
650 </span>(<span class="keyword">require</span> '<span class="reference">info</span>)
652 (setq toolbar-info-frame-plist
655 (name . "<span class="string">InfoFrame</span>")
656 (menubar-visible-p . nil)
657 (default-toolbar-visible-p . t)
658 <span class="comment">;; I have a idea to put nav buttons in the gutter.
659 </span> (default-gutter-visible-p . t)
660 (top-gutter-height . 24)))
662 (<span class="keyword">unless</span> (fboundp 'Info-search-next)
663 (defun Info-search-next ()
664 "<span class="string">Repeat search starting from point with last regexp used in `</span><span class="string"><span class="reference">Info-search</span></span><span class="string">'.</span>"
666 (Info-search Info-last-search))
667 (define-key Info-mode-map "<span class="string">z</span>" 'Info-search-next))
671 '("<span class="string">/home/steve/.local/share/sxemacs/site-packages/info</span>"
672 "<span class="string">/home/steve/.local/share/sxemacs/xemacs-packages/info</span>"
673 "<span class="string">/usr/share/info</span>"
674 <span class="comment">;; "/usr/share/sxemacs/site-packages/info"
675 </span> <span class="comment">;; "/usr/share/sxemacs/sxemacs-packages/info"
676 </span> "<span class="string">/usr/share/sxemacs/xemacs-packages/info</span>"
677 "<span class="string">/usr/share/sxemacs/mule-packages/info</span>")
678 Info-dir-contents-directory
679 "<span class="doc-string">/home/steve/.local/share/sxemacs/site-packages/info</span>"
680 Info-save-auto-generated-dir 'always
681 Info-button1-follows-hyperlink t)
682 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
683 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> gdb-highlight
684 </span>(add-hook 'gdb-mode-hook #'(<span class="keyword">lambda</span> () (<span class="keyword">require</span> '<span class="reference">gdb-highlight</span>)))
686 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
687 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> etags
688 </span>(<span class="keyword">require</span> '<span class="reference">etags</span>)
689 (<span class="keyword">defun</span> <span class="function-name">sy-find-tag-regex</span> (tagname)
690 "<span class="doc-string">Use `</span><span class="doc-string"><span class="reference">igrep-find</span></span><span class="doc-string">' command to find all occurances of tag with TAGNAME.</span>"
691 (interactive (<span class="keyword">if</span> current-prefix-arg (list (current-word))
692 (list (find-tag-tag "<span class="string">Find tag: </span>"))))
693 (<span class="keyword">let</span> ((dir (file-name-directory tags-file-name)))
694 (igrep-find "<span class="string">grep</span>" tagname (concat dir "<span class="string">/*</span>"))))
696 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
697 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Google
698 </span>(<span class="keyword">require</span> '<span class="reference">google-query</span>)
699 (setq google-query-mirror "<span class="doc-string">https://www.google.com.au</span>"
700 google-query-result-count 100)
701 (global-set-key [(control f9)] 'google-query)
702 (global-set-key [(meta f9)] 'google-query-region)
704 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
705 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> What the fuck does that acronym mean?
706 ;; This requires wtf(6). No idea where you get it from, but it comes
708 ;; (wtf "lol") => LOL: laughing out loud
709 </span>(<span class="keyword">defun</span> <span class="function-name">wtf</span> (acronym)
710 "<span class="doc-string">What the fuck is... ACRONYM</span>"
711 (interactive "<span class="string">sWhat the fuck is: </span>")
712 (<span class="keyword">let*</span> ((wtf (executable-find "<span class="string">wtf</span>"))
713 (term (substring (shell-command-to-string
714 (concat wtf "<span class="string"> </span>" acronym)) 0 -1)))
715 (<span class="keyword">if</span> (interactive-p)
716 (<span class="keyword">if</span> current-prefix-arg
721 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
722 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Interactively append to the latest kill
724 </span>(<span class="keyword">defun</span> <span class="function-name">sy-add-to-kill</span> (start end <span class="type">&optional</span> prepend)
725 "<span class="doc-string">Copy region START END and append it to the latest kill.
727 Or, PREPEND with prefix arg.
729 With this you could select \"THIS \" word, `\\[</span><span class="doc-string"><span class="reference">kill-ring-save</span></span><span class="doc-string">]' to save it
730 to the kill ring, then select this \"WORD \" and do `\\[</span><span class="doc-string"><span class="reference">sy-add-to-kill</span></span><span class="doc-string">]',
731 then select this word \"HERE\", do `\\[</span><span class="doc-string"><span class="reference">sy-add-to-kill</span></span><span class="doc-string">]', then select these
732 words \"DON'T WANT \", do `\\[</span><span class="doc-string"><span class="reference">universal-argument</span></span><span class="doc-string">] \\[</span><span class="doc-string"><span class="reference">sy-add-to-kill</span></span><span class="doc-string">]', and
733 finally do `\\[</span><span class="doc-string"><span class="reference">yank</span></span><span class="doc-string">]' and you'd get...
735 DON'T WANT THIS WORD HERE</span>"
736 (interactive "<span class="string">r\nP</span>")
737 (<span class="keyword">let</span> ((prepend (or prepend
738 current-prefix-arg)))
739 (<span class="keyword">if</span> prepend
740 (kill-append (buffer-substring start end) 'before)
741 (kill-append (buffer-substring start end) nil))))
743 (global-set-key [(meta ?W)] 'sy-add-to-kill)
745 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
746 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> DNS
747 </span>(add-to-list 'auto-mode-alist '("<span class="string">/var/chroot/named/etc/zones/.*$</span>" . dns-mode))
749 (<span class="keyword">defun</span> <span class="function-name">dig-mx</span> (domain)
750 "<span class="doc-string">View MX records for DOMAIN.
752 With a prefix arg, prompt for a server to query.</span>"
753 (interactive "<span class="string">sDomain: </span>")
754 (<span class="keyword">unless</span> (interactive-p)
755 (error 'invalid-operation "<span class="string">`</span><span class="string"><span class="reference">dig-mx</span></span><span class="string">' must be called interactively</span>"))
756 (<span class="keyword">if</span> current-prefix-arg
757 (dig domain "<span class="string">MX</span>" nil nil nil
758 (format "<span class="string">%s</span>" (read-string "<span class="string">Server: </span>" nil nil "<span class="string">localhost</span>")))
759 (dig domain "<span class="string">MX</span>")))
761 (<span class="keyword">defun</span> <span class="function-name">dig-ns</span> (domain)
762 "<span class="doc-string">View NS records for DOMAIN.
764 With a prefix arg, prompt for a server to query.</span>"
765 (interactive "<span class="string">sDomain: </span>")
766 (<span class="keyword">unless</span> (interactive-p)
767 (error 'invalid-operation "<span class="string">`</span><span class="string"><span class="reference">dig-ns</span></span><span class="string">' must be called interactively</span>"))
768 (<span class="keyword">if</span> current-prefix-arg
769 (dig domain "<span class="string">NS</span>" nil nil nil
770 (format "<span class="string">%s</span>" (read-string "<span class="string">Server: </span>" nil nil "<span class="string">localhost</span>")))
771 (dig domain "<span class="string">NS</span>")))
773 (<span class="keyword">defun</span> <span class="function-name">dig-any</span> (domain)
774 "<span class="doc-string">View DNS records for DOMAIN.
776 With a prefix arg, prompt for a server to query.</span>"
777 (interactive "<span class="string">sDomain: </span>")
778 (<span class="keyword">unless</span> (interactive-p)
779 (error 'invalid-operation "<span class="string">`</span><span class="string"><span class="reference">dig-any</span></span><span class="string">' must be called interactively</span>"))
780 (<span class="keyword">if</span> current-prefix-arg
781 (dig domain "<span class="string">ANY</span>" nil nil nil
782 (format "<span class="string">%s</span>" (read-string "<span class="string">Server: </span>" nil nil "<span class="string">localhost</span>")))
783 (dig domain "<span class="string">ANY</span>")))
785 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
786 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Hard disk temperature!
787 ;(or (ignore-errors (require 'hddtemp))
789 ; (load-module "cl-loop")
790 ; (require 'hddtemp)))
792 <span class="comment">;;; get fancy and stick it in the modeline
793 ;(defvar hddtemp-global-mode-string "sda:0°C"
794 ; "Default hddtemp modeline string.")
795 ;(setq global-mode-string (append global-mode-string
796 ; (list hddtemp-global-mode-string)))
798 <span class="comment">;(defun hddtemp-modeline-string ()
799 ; (let* ((disc0 (hddtemp 0))
800 ; (str (format "sda:%s°%s"
801 ; (nth 2 disc0) (nth 3 disc0))))
802 ; (setq hddtemp-global-mode-string str)))
804 <span class="comment">;(start-itimer "hdd-modeline"
807 ; (setq global-mode-string
808 ; (delq hddtemp-global-mode-string global-mode-string))
809 ; (hddtemp-modeline-string)
810 ; (setq global-mode-string
811 ; (append global-mode-string
812 ; (list hddtemp-global-mode-string)))))
815 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
816 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Term
817 ; M-x term usually gives really horrid "staircase" output. This fixes
819 </span>(add-hook 'term-exec-hook
820 #'(<span class="keyword">lambda</span> ()
821 (set-buffer-process-coding-system 'binary 'binary)))
823 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
824 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Phonetic Alphabet
825 </span>(<span class="keyword">defvar</span> <span class="variable-name">phonetics-hash</span>
826 #s(hash-table test equal
827 data ("<span class="string">a</span>" "<span class="string">alpha</span>"
828 "<span class="string">b</span>" "<span class="string">bravo</span>"
829 "<span class="string">c</span>" "<span class="string">charlie</span>"
830 "<span class="string">d</span>" "<span class="string">delta</span>"
831 "<span class="string">e</span>" "<span class="string">echo</span>"
832 "<span class="string">f</span>" "<span class="string">foxtrot</span>"
833 "<span class="string">g</span>" "<span class="string">golf</span>"
834 "<span class="string">h</span>" "<span class="string">hotel</span>"
835 "<span class="string">i</span>" "<span class="string">india</span>"
836 "<span class="string">j</span>" "<span class="string">juliet</span>"
837 "<span class="string">k</span>" "<span class="string">kilo</span>"
838 "<span class="string">l</span>" "<span class="string">lima</span>"
839 "<span class="string">m</span>" "<span class="string">mike</span>"
840 "<span class="string">n</span>" "<span class="string">november</span>"
841 "<span class="string">o</span>" "<span class="string">oscar</span>"
842 "<span class="string">p</span>" "<span class="string">papa</span>"
843 "<span class="string">q</span>" "<span class="string">quebec</span>"
844 "<span class="string">r</span>" "<span class="string">romeo</span>"
845 "<span class="string">s</span>" "<span class="string">sierra</span>"
846 "<span class="string">t</span>" "<span class="string">tango</span>"
847 "<span class="string">u</span>" "<span class="string">uniform</span>"
848 "<span class="string">v</span>" "<span class="string">victor</span>"
849 "<span class="string">w</span>" "<span class="string">whiskey</span>"
850 "<span class="string">x</span>" "<span class="string">x-ray</span>"
851 "<span class="string">y</span>" "<span class="string">yankee</span>"
852 "<span class="string">z</span>" "<span class="string">zulu</span>"
853 "<span class="string"> </span>" "<span class="string">SPC</span>"
854 "<span class="string">0</span>" "<span class="string">zero</span>"
855 "<span class="string">1</span>" "<span class="string">one</span>"
856 "<span class="string">2</span>" "<span class="string">two</span>"
857 "<span class="string">3</span>" "<span class="string">three</span>"
858 "<span class="string">4</span>" "<span class="string">four</span>"
859 "<span class="string">5</span>" "<span class="string">five</span>"
860 "<span class="string">6</span>" "<span class="string">six</span>"
861 "<span class="string">7</span>" "<span class="string">seven</span>"
862 "<span class="string">8</span>" "<span class="string">eight</span>"
863 "<span class="string">9</span>" "<span class="string">niner</span>"))
864 "<span class="doc-string">Hash table of phonetic alphabet.</span>")
866 (<span class="keyword">defun</span> <span class="function-name">phoneticise</span> (string)
867 "<span class="doc-string">Return STRING rewritten using the phonetic alphabet.
869 For example: \"cat\" => \"charlie alpha tango\".
870 With a prefix arg, insert phoneticised string at point.
871 It ignores punctuation.</span>"
872 (interactive "<span class="string">sString to phoneticise: </span>")
873 (<span class="keyword">let</span> ((str (string-to-list (downcase string)))
875 (<span class="keyword">with-temp-buffer</span>
876 (<span class="keyword">while</span> str
877 (insert (or (gethash (char-to-string (car str)) phonetics-hash)
878 (char-to-string (car str))) "<span class="string"> </span>")
879 (setq str (cdr str)))
880 (setq phonetics (buffer-string)))
881 (<span class="keyword">if</span> current-prefix-arg
883 (<span class="keyword">if</span> (interactive-p)
884 (message "<span class="string">%s</span>" phonetics)
887 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
888 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Copy the text without the extents
889 </span>(<span class="keyword">defun</span> <span class="function-name">sy-extent-kill-save</span> ()
890 "<span class="doc-string">Save the extent under point's string to kill ring.</span>"
892 (kill-new (extent-string (extent-at (point)))))
894 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
895 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> PkgUsr tools
896 </span>(<span class="keyword">require</span> '<span class="reference">pkgusr</span>)
898 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
899 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> There's a new sexy rc.d style init in SXEmacs, and this is how I
902 ;; I now have my init files named with a 2 digit numerical prefix.
903 ;; This is so I can control which order `</span><span class="comment"><span class="reference">lisp-initd-compile-and-load</span></span><span class="comment">'
904 ;; will load my stuff. Consequently, finding a particular init file is
905 ;; much harder now because I can never remember what bloody number it
906 ;; has. This takes the remembering out of the equation.
907 </span>(<span class="keyword">defvar</span> <span class="variable-name">sy-init-hash</span> (make-hash-table <span class="reference">:test</span> #'equal <span class="reference">:size</span> 20)
908 "<span class="doc-string">A hash table of my numbered init files.</span>")
910 (<span class="keyword">defvar</span> <span class="variable-name">sy-init-files</span>
911 (directory-files lisp-initd-dir nil "<span class="string">.*\.el$</span>" 'sorted-list t)
912 "<span class="doc-string">List of my init files.</span>")
915 (<span class="keyword">lambda</span> (value)
916 (<span class="keyword">let</span> ((key (substring value 3 -3)))
917 (puthash key value sy-init-hash)))
920 (<span class="keyword">defvar</span> <span class="variable-name">sy-init-hash-vector</span> (hash-keys-to-vector sy-init-hash)
921 "<span class="doc-string">A vector from my init file hash to use for completion.</span>")
923 (<span class="keyword">defvar</span> <span class="variable-name">sy-init-history</span> nil
924 "<span class="doc-string">History for `</span><span class="doc-string"><span class="reference">sy-init-file-other-window</span></span><span class="doc-string">'.</span>")
926 (<span class="keyword">defun</span> <span class="function-name">sy-init-file-other-window</span> (initf <span class="type">&optional</span> codesys)
927 "<span class="doc-string">Basically, `</span><span class="doc-string"><span class="reference">find-file-other-window</span></span><span class="doc-string">', but for my init files.
929 Argument INITF is the \"base\" name of the init file.
930 Optional prefix arg, CODESYS, is to specify a coding system to use.
932 I have this because I've prefixed all of my init files with a 2
933 digit number so I can ensure they get loaded in the right order with
934 `</span><span class="doc-string"><span class="reference">lisp-initd-compile-and-load</span></span><span class="doc-string">'. And I can never remember what init
935 files are assigned what numbers.</span>"
936 (interactive (list (completing-read "<span class="string">Init file: </span>"
937 (mapcar #'list sy-init-hash-vector)
938 nil nil nil sy-init-history)
939 (<span class="keyword">when</span> current-prefix-arg
940 (read-coding-system "<span class="string">Coding System: </span>"))))
941 (<span class="keyword">let*</span> ((lib (gethash initf sy-init-hash))
942 (expanded (expand-file-name lib lisp-initd-dir)))
943 (find-file-other-window expanded codesys)))
945 (global-set-key [(control ?x) ?4 ?i] #'sy-init-file-other-window)
947 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
948 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> "Active" menubar
949 ;; Nifty little thing that hides the menubar and makes it visible when
950 ;; the rat is on the toolbar.
952 ;(require 'active-menu)
955 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
956 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> LiveJournal posting thingy
957 ;; Sadly, this no longer works because I neglected to keep it up to
958 ;; date with LiveJournal API changes. But it was damn cool while it
960 </span>(<span class="keyword">require</span> '<span class="reference">lj</span>)
961 <span class="comment">;(setq lj-cookie-flavour 'chrome)
962 </span>(setq lj-cookie-flavour 'firefox)
963 (setq lj-user-id "<span class="doc-string">bastard_blog</span>")
964 (setq lj-archive-posts t)
965 (setq lj-bcc-address "<span class="doc-string">Steve Youngs <<a href="mailto:steve@localhost">steve@localhost</a>></span>")
966 (setq lj-default-location "<span class="doc-string">Brisbane, Australia</span>")
968 "<span class="doc-string"><hr />
969 <p style=\"color:#FD00FD;font-size:10pt;font-weight:bold;\">
970 Till next time...<br />
971 <i>Steve</i>
973 (add-hook 'lj-before-post-hook #'lj-validate)
974 (add-hook 'lj-after-post-hook #'lj-get-tags)
976 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
977 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Handy kbd macros
979 ;; numpoints -- make numbered list points. Before using, initialise
980 ;; numeric register `n' to zero
981 </span>(number-to-register 0 ?n)
982 (<span class="keyword">defalias</span> '<span class="function-name">numpoints</span>
983 (read-kbd-macro "<span class="string">2*RET 2*SPC C-x r + n C-x r i n C-e ) SPC</span>"))
984 (global-set-key [(control ?c) (control ?n)] #'numpoints)
985 (<span class="keyword">define-key</span> <span class="variable-name">message-mode-map</span> [(hyper ?n)] #'numpoints)
987 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
988 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Do things with environment variables let-bound
990 ;; (with-environment-variables (("VAR" "VALUE") ("VAR2" "VALUE2"))
993 ;(require 'with-environment-variables)
995 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
996 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Play Sudoku
997 </span>(<span class="keyword">require</span> '<span class="reference">sudoku</span>)
998 (setq sudoku-level 'easy)
999 (setq modeline-coding-system "<span class="doc-string">%C</span>")
1001 <span class="comment">;</span><span class="comment"><span class="reference">:*=======================</span></span><span class="comment">
1002 ;</span><span class="comment"><span class="reference">:*</span></span><span class="comment"> Stupid fucking Google Chrome is MIME-illiterate
1003 </span>(<span class="keyword">defun</span> <span class="function-name">sy-browse-url-of-file</span> (<span class="type">&optional</span> file)
1004 "<span class="doc-string">Ask a WWW browser to display FILE.
1006 Display the current buffer's file if FILE is nil or if called
1007 interactively. Turn the filename into a URL with function
1008 `</span><span class="doc-string"><span class="reference">browse-url-file-url</span></span><span class="doc-string">'. Pass the URL to a browser using the
1009 `</span><span class="doc-string"><span class="reference">browse-url</span></span><span class="doc-string">' function then run `</span><span class="doc-string"><span class="reference">browse-url-of-file-hook</span></span><span class="doc-string">'.
1011 This has been reworked a little to cater for Google Chrome not knowing
1012 anything about MIME types.</span>"
1014 (<span class="keyword">let</span> (oldfile)
1016 (setq file (buffer-file-name))
1017 (error "<span class="string">Current buffer has no file</span>"))
1018 (<span class="keyword">unless</span> (string-match "<span class="string">^\\.html?$</span>" (file-name-extension file t))
1020 (rename-file file (concat file "<span class="string">.html</span>"))
1021 (setq file (concat file "<span class="string">.html</span>")))
1022 (<span class="keyword">let</span> ((buf (get-file-buffer file)))
1023 (<span class="keyword">if</span> buf
1024 (<span class="keyword">save-excursion</span>
1026 (<span class="keyword">cond</span> ((not (buffer-modified-p)))
1027 (browse-url-save-file (save-buffer))
1028 (t (message "<span class="string">%s modified since last save</span>" file))))))
1029 (<span class="keyword">unwind-protect</span>
1030 (<span class="keyword">progn</span>
1031 (browse-url (browse-url-file-url file))
1033 (and oldfile (rename-file file oldfile))))
1034 (run-hooks 'browse-url-of-file-hook))
1036 (fset #'browse-url-of-file #'sy-browse-url-of-file)
1038 <span class="comment">;</span><span class="comment"><span class="reference">:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*</span></span><span class="comment">
1039 </span>(message "<span class="doc-string">miscellaneous initialised</span>")
1042 <!-- SXEmacs Logo -->
1044 <a href="https://www.sxemacs.org/" target="_parent">
1045 <img style="padding:0px 5px 0px 0px;border:0;width:88px;height:31px"
1046 src="/Images/cbsx.png"
1047 title="This page was created entirely in SXEmacs"
1048 alt="Created with SXEmacs" />
1050 <!-- End SXEmacs Logo -->
1051 <!-- Valid XHTML 1.0 -->
1052 <a href="http://validator.w3.org/check?uri=https%3a%2f%2fwww.sxemacs.org%2fSYinits%2f12-misc.html" target="_blank">
1053 <img style="padding:0px 5px 0px 10px;border:0;width:88px;height:31px"
1054 src="/Images/valid-xhtml10.png"
1055 title="Valid XHTML 1.0 Transitional!"
1056 alt="Valid XHTML 1.0 Transitional!" />
1059 <!-- End Valid XHTML 1.0 -->
1061 <h6>Copyright © 2020 Steve Youngs<br />
1062 Verbatim copying and distribution is permitted in any medium,
1063 providing this notice is preserved.<br />
1064 <!-- hhmts start -->
1065 Last modified: Sat Apr 18 21:42:42 AEST 2020