diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2018-04-11 22:15:05 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2018-04-11 22:15:05 -0700 |
commit | c674c76012b5e634d6126275075bd8fe47b2448a (patch) | |
tree | 7f8eacebe33f688991551f4c772bd21a632d540c /archive | |
parent | 90be94a6cc5f0fbf37ed56ec38b763518d2496d2 (diff) | |
download | dotfiles-c674c76012b5e634d6126275075bd8fe47b2448a.tar.gz |
archive and delete some site-lisp
Diffstat (limited to 'archive')
-rw-r--r-- | archive/.emacs.d/site-lisp/anchored-transpose.el | 211 | ||||
-rw-r--r-- | archive/.emacs.d/site-lisp/boxquote.el | 585 | ||||
-rw-r--r-- | archive/.emacs.d/site-lisp/centered-window-mode.el | 103 | ||||
-rw-r--r-- | archive/.emacs.d/site-lisp/hl-sentence.el | 105 | ||||
-rw-r--r-- | archive/.emacs.d/site-lisp/org-mairix-el.el | 62 | ||||
-rw-r--r-- | archive/.emacs.d/site-lisp/spw-pyblosxom.el | 142 |
6 files changed, 1208 insertions, 0 deletions
diff --git a/archive/.emacs.d/site-lisp/anchored-transpose.el b/archive/.emacs.d/site-lisp/anchored-transpose.el new file mode 100644 index 00000000..33af4f7e --- /dev/null +++ b/archive/.emacs.d/site-lisp/anchored-transpose.el @@ -0,0 +1,211 @@ +;;; anchored-transpose.el --- Transposes a phrase around an anchor phrase + +;; Copyright (C) 2004 Free Software Foundation, Inc. + +;; Author: Rick Bielawski <rbielaws@i1.net> +;; Keywords: tools convenience + +;; This file is free software; you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free +;; Software Foundation; either version 2, or (at your option) any later +;; version. + +;; This file is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +;; more details. + +;;; Commentary: + +;; `anchored-transpose' is an interactive autoload function to transpose +;; portions of a region around an anchor phrase. In other words it swaps +;; two regions. +;; +;; See C-h f anchored-transpose <ret> for a complete description. + +;;; Installing: + +;; 1) Put anchored-transpose.el on your load path. +;; 2) Put the following 2 lines in your .emacs +;; (global-set-key [?\C-x ?t] 'anchored-transpose) +;; (autoload 'anchored-transpose "anchored-transpose" nil t) + +;;; History: + +;; 2004-09-24 RGB Seems useable enough to release. +;; 2004-10-15 RGB Only comments and doc strings were updated. +;; 2004-10-22 RGB Added support for 2 phrase selection. +;; 2004-12-01 RGB Added secondary selection support. +;; 2005-07-21 RGB Updated help text and comments. +;; Added support for A C B D and C A D B selection. +;; Fixed bug affecting multi line selections. +;; 2005-09-28 RGB Allow swapping regions with no anchor text between. +;; 2005-10-17 RGB Fix bug in fuzzy logic which turned off fuzziness. + +;;; Code: + +(defvar anchored-transpose-anchor () + "begin/end when `anchored-transpose' is in progress else nil") + +;;;###autoload +(defun anchored-transpose (beg1 end1 flg1 &optional beg2 end2 flg2) + "Transpose portions of the region around an anchor phrase. + +`this phrase but not that word' can be transposed into +`that word but not this phrase' + +I want this phrase but not that word. + |----------------------------|. .This is the entire phrase. + |-------|. . . . . . .This is the anchor phrase. + +First select the entire phrase and type \\[anchored-transpose]. Then select +the anchor phrase and type \\[anchored-transpose] again. By default the +anchor phrase will automatically include any surrounding whitespace even if +you don't explicitly select it. Also, it won't include certain trailing +punctuation. See `anchored-transpose-do-fuzzy' for details. A prefix arg +prior to either selection means `no fuzzy logic, use selections literally'. + +You can select the anchor phrase first followed by the entire phrase if more +convenient. Typing \\[anchored-transpose] with nothing selected clears any +prior selection. If both primary and secondary selections are active this +command swaps the 2 selections immediately. + +I want this phrase but not that word. + |----------| |---------| Separate phrase selection. + +You can also select the phrases to be swapped separately in any order. +" + (interactive `(,(region-beginning) ,(region-end) + ,current-prefix-arg + ,@anchored-transpose-anchor)) + (setq anchored-transpose-anchor nil deactivate-mark t) + (when (and mouse-secondary-overlay + mark-active + (eq (overlay-buffer mouse-secondary-overlay) + (current-buffer) + ) + (/= (overlay-start mouse-secondary-overlay) + (overlay-end mouse-secondary-overlay) + ) + ) + (setq beg2 (overlay-start mouse-secondary-overlay)) + (setq end2 (overlay-end mouse-secondary-overlay)) + (setq flg2 flg1) + (delete-overlay mouse-secondary-overlay) + ) + (if mark-active + (if end2 ; then both regions are marked. swap them. + (if (and (< beg1 beg2) ;A C B D + (< end1 end2) + (> end1 beg2)) + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg1 beg2 end1 end2 flg1 flg2 flg1 flg2)) + (if (and (> beg1 beg2) ;C A D B + (> end1 end2) + (> end2 beg1)) + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg2 beg1 end2 end1 flg2 flg1 flg2 flg1)) + (if (and (< beg1 beg2) ;A C D B + (> end1 end2)) + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg1 beg2 end2 end1 flg1 flg2 flg2 flg1)) + (if (and (> beg1 beg2) ;C A B D + (< end1 end2)) + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg2 beg1 end1 end2 flg2 flg1 flg1 flg2)) + (if (<= end1 beg2) ;A B C D + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg1 end1 beg2 end2 flg1 flg1 flg2 flg2)) + (if (<= end2 beg1) ;C D A B + (apply 'anchored-transpose-swap + (anchored-transpose-do-fuzzy + beg2 end2 beg1 end1 flg2 flg2 flg1 flg1)) + (error "Regions have invalid overlap"))))))) + ;; 1st of 2 regions. Save it and wait for the other. + (setq anchored-transpose-anchor (list beg1 end1 flg1)) + (message "Select other part (anchor or region)")) + (error "Command requires a marked region"))) + +(defun anchored-transpose-do-fuzzy (r1beg r1end r2beg r2end + lit1 lit2 lit3 lit4) +"Returns the first 4 arguments after adjusting their value if necessary. + +I want this phrase but not that word. + |----------------------------|. .This is the entire phrase. + |-------|. . . . . . .This is the anchor phrase. + R1BEG R1END R2BEG R2END + +R1BEG and R1END define the first region and R2BEG and R2END the second. + +The flags, LIT1 thru LIT4 indicate if fuzzy logic should be applied to the +beginning of R1BEG, the end of R1END, the beginning of R2BEG, the end of R2END +respectively. If any flag is nil then fuzzy logic will be applied. Otherwise +the value passed should be returned LITerally (that is, unchanged). + +See `anchored-transpose-fuzzy-begin' and `anchored-transpose-fuzzy-end' for +specifics on what adjustments these routines will make when LITx is nil." + (list + (if lit1 r1beg + (anchored-transpose-fuzzy-begin r1beg r1end "[\t ]+")) + (if lit2 r1end + (anchored-transpose-fuzzy-end r1beg r1end "\\s +")) + (if lit3 r2beg + (anchored-transpose-fuzzy-begin r2beg r2end "[\t ]+")) + (if lit4 r2end + (anchored-transpose-fuzzy-end r2beg r2end "\\s *[.!?]")))) + +(defun anchored-transpose-fuzzy-end (beg end what) + "Returns END or new value for END based on the regexp WHAT. +BEG and END are buffer positions defining a region. If that region ends +with WHAT then the value for END is adjusted to exclude that matching text. + +NOTE: The regexp is applied differently than `looking-back' applies a regexp. + +Example: if (buffer-string beg end) contains `1234' the regexp `432' matches +it, not `234' as `looking-back' would. Also, your regexp never sees the char +at BEG so the match will always leave at least 1 character to transpose. +The reason for not using looking-back is that it's not greedy enough. +(looking-back \" +\") will only match one space no matter how many exist." + (let ((str (concat + (reverse (append (buffer-substring (1+ beg) end) nil))))) + (if (string-match (concat "\\`" what) str) + (- end (length (match-string 0 str))) + end))) + +(defun anchored-transpose-fuzzy-begin (beg end what) + "Returns BEG or a new value for BEG based on the regexp WHAT. +BEG and END are buffer positions defining a region. If the region begins +with WHAT then BEG is adjusted to exclude the matching text. + +NOTE: Your regexp never sees the last char defined by beg/end. This insures +at least 1 char is always left to transpose." + (let ((str (buffer-substring beg (1- end)))) + (if (string-match (concat "\\`" what) str) + (+ beg (length (match-string 0 str))) + beg))) + +(defun anchored-transpose-swap (r1beg r1end r2beg r2end) + "Swaps region r1beg/r1end with r2beg/r2end. Flags are currently ignored. +Point is left at r1end." + (let ((reg1 (buffer-substring r1beg r1end)) + (reg2 (delete-and-extract-region r2beg r2end))) + (goto-char r2beg) + (insert reg1) + (save-excursion ;; I want to leave point at the end of phrase 2. + (goto-char r1beg) + (delete-region r1beg r1end) + (insert reg2)))) + +(provide 'anchored-transpose) + +;; Because I like it this way. So there! +;;; Local Variables: *** +;;; fill-column:78 *** +;;; emacs-lisp-docstring-fill-column:78 *** +;;; End: *** +;;; anchored-transpose.el ends here. diff --git a/archive/.emacs.d/site-lisp/boxquote.el b/archive/.emacs.d/site-lisp/boxquote.el new file mode 100644 index 00000000..5c77790f --- /dev/null +++ b/archive/.emacs.d/site-lisp/boxquote.el @@ -0,0 +1,585 @@ +;;; boxquote.el --- Quote text with a semi-box. +;; Copyright 1999-2009 by Dave Pearson <davep@davep.org> +;; $Revision: 1.23 $ + +;; boxquote.el is free software distributed under the terms of the GNU +;; General Public Licence, version 2 or (at your option) any later version. +;; For details see the file COPYING. + +;;; Commentary: + +;; boxquote provides a set of functions for using a text quoting style that +;; partially boxes in the left hand side of an area of text, such a marking +;; style might be used to show externally included text or example code. +;; +;; ,---- +;; | The default style looks like this. +;; `---- +;; +;; A number of functions are provided for quoting a region, a buffer, a +;; paragraph and a defun. There are also functions for quoting text while +;; pulling it in, either by inserting the contents of another file or by +;; yanking text into the current buffer. +;; +;; The latest version of boxquote.el can be found at: +;; +;; <URL:http://www.davep.org/emacs/#boxquote.el> + +;;; Thanks: + +;; Kai Grossjohann for inspiring the idea of boxquote. I wrote this code to +;; mimic the "inclusion quoting" style in his Usenet posts. I could have +;; hassled him for his code but it was far more fun to write it myself. +;; +;; Mark Milhollan for providing a patch that helped me get the help quoting +;; functions working with XEmacs. +;; +;; Oliver Much for suggesting the idea of having a `boxquote-kill-ring-save' +;; function. +;; +;; Reiner Steib for suggesting `boxquote-where-is' and the idea of letting +;; `boxquote-describe-key' describe key bindings from other buffers. Also +;; thanks go to Reiner for suggesting `boxquote-insert-buffer'. + +;;; Code: + +;; Things we need: + +(eval-when-compile + (require 'cl)) +(require 'rect) + +;; Attempt to handle older/other emacs. +(eval-and-compile + + ;; If customize isn't available just use defvar instead. + (unless (fboundp 'defgroup) + (defmacro defgroup (&rest rest) nil) + (defmacro defcustom (symbol init docstring &rest rest) + `(defvar ,symbol ,init ,docstring))) + + ;; If `line-beginning-position' isn't available provide one. + (unless (fboundp 'line-beginning-position) + (defun line-beginning-position (&optional n) + "Return the `point' of the beginning of the current line." + (save-excursion + (beginning-of-line n) + (point)))) + + ;; If `line-end-position' isn't available provide one. + (unless (fboundp 'line-end-position) + (defun line-end-position (&optional n) + "Return the `point' of the end of the current line." + (save-excursion + (end-of-line n) + (point))))) + +;; Customize options. + +(defgroup boxquote nil + "Mark regions of text with a half-box." + :group 'editing + :prefix "boxquote-") + +(defcustom boxquote-top-and-tail "----" + "*Text that will be used at the top and tail of the box." + :type 'string + :group 'boxquote) + +(defcustom boxquote-top-corner "," + "*Text used for the top corner of the box." + :type 'string + :group 'boxquote) + +(defcustom boxquote-bottom-corner "`" + "*Text used for the bottom corner of the box." + :type 'string + :group 'boxquote) + +(defcustom boxquote-side "| " + "*Text used for the side of the box." + :type 'string + :group 'boxquote) + +(defcustom boxquote-title-format "[ %s ]" + "*Format string to use when creating a box title." + :type 'string + :group 'boxquote) + +(defcustom boxquote-title-files t + "*Should a `boxquote-insert-file' title the box with the file name?" + :type '(choice + (const :tag "Title the box with the file name" t) + (const :tag "Don't title the box with the file name" nil)) + :group 'boxquote) + +(defcustom boxquote-file-title-function #'file-name-nondirectory + "*Function to apply to a file's name when using it to title a box." + :type 'function + :group 'boxquote) + +(defcustom boxquote-title-buffers t + "*Should a `boxquote-insert-buffer' title the box with the buffer name?" + :type '(choice + (const :tag "Title the box with the buffer name" t) + (const :tag "Don't title the box with the buffer name" nil)) + :group 'boxquote) + +(defcustom boxquote-buffer-title-function #'identity + "*Function to apply to a buffer's name when using it to title a box." + :type 'function + :group 'boxquote) + +(defcustom boxquote-region-hook nil + "*Hooks to perform when on a region prior to boxquoting. + +Note that all forms of boxquoting use `boxquote-region' to create the +boxquote. Because of this any hook you place here will be invoked by any of +the boxquoting functions." + :type 'hook + :group 'boxquote) + +(defcustom boxquote-yank-hook nil + "*Hooks to perform on the yanked text prior to boxquoting." + :type 'hook + :group 'boxquote) + +(defcustom boxquote-insert-file-hook nil + "*Hooks to perform on the text from an inserted file prior to boxquoting." + :type 'hook + :group 'boxquote) + +(defcustom boxquote-kill-ring-save-title #'buffer-name + "*Function for working out the title for a `boxquote-kill-ring-save'. + +The string returned from this function will be used as the title for a +boxquote when the saved text is yanked into a buffer with \\[boxquote-yank]. + +An example of a non-trivial value for this variable might be: + + (lambda () + (if (string= mode-name \"Article\") + (aref gnus-current-headers 4) + (buffer-name))) + +In this case, if you are a `gnus' user, \\[boxquote-kill-ring-save] could be +used to copy text from an article buffer and, when it is yanked into another +buffer using \\[boxquote-yank], the title of the boxquote would be the ID of +the article you'd copied the text from." + :type 'function + :group 'boxquote) + +(defcustom boxquote-describe-function-title-format "C-h f %s RET" + "*Format string to use when formatting a function description box title" + :type 'string + :group 'boxquote) + +(defcustom boxquote-describe-variable-title-format "C-h v %s RET" + "*Format string to use when formatting a variable description box title" + :type 'string + :group 'boxquote) + +(defcustom boxquote-describe-key-title-format "C-h k %s" + "*Format string to use when formatting a key description box title" + :type 'string + :group 'boxquote) + +(defcustom boxquote-where-is-title-format "C-h w %s RET" + "*Format string to use when formatting a `where-is' description box title" + :type 'string + :group 'boxquote) + +(defcustom boxquote-where-is-body-format "%s is on %s" + "*Format string to use when formatting a `where-is' description." + :type 'string + :group 'boxquote) + +;; Main code: + +(defun boxquote-xemacs-p () + "Are we running in XEmacs?" + (and (boundp 'running-xemacs) (symbol-value 'running-xemacs))) + +(defun boxquote-points () + "Find the start and end points of a boxquote. + +If `point' is inside a boxquote then a cons is returned, the `car' is the +start `point' and the `cdr' is the end `point'. NIL is returned if no +boxquote is found." + (save-excursion + (beginning-of-line) + (let* ((re-top (concat "^" (regexp-quote boxquote-top-corner) + (regexp-quote boxquote-top-and-tail))) + (re-left (concat "^" (regexp-quote boxquote-side))) + (re-bottom (concat "^" (regexp-quote boxquote-bottom-corner) + (regexp-quote boxquote-top-and-tail))) + (points + (flet ((find-box-end (re &optional back) + (save-excursion + (when (if back + (search-backward-regexp re nil t) + (search-forward-regexp re nil t)) + (point))))) + (cond ((looking-at re-top) + (cons (point) (find-box-end re-bottom))) + ((looking-at re-left) + (cons (find-box-end re-top t) (find-box-end re-bottom))) + ((looking-at re-bottom) + (cons (find-box-end re-top t) (line-end-position))))))) + (when (and (car points) (cdr points)) + points)))) + +(defun boxquote-quoted-p () + "Is `point' inside a boxquote?" + (not (null (boxquote-points)))) + +(defun boxquote-points-with-check () + "Get the `boxquote-points' and flag an error of no box was found." + (or (boxquote-points) (error "I can't see a box here"))) + +(defun boxquote-title-format-as-regexp () + "Return a regular expression to match the title." + (with-temp-buffer + (insert (regexp-quote boxquote-title-format)) + (setf (point) (point-min)) + (when (search-forward "%s" nil t) + (replace-match ".*" nil t)) + (buffer-string))) + +(defun boxquote-get-title () + "Get the title for the current boxquote." + (multiple-value-bind (prefix-len suffix-len) + (with-temp-buffer + (let ((look-for "%s")) + (insert boxquote-title-format) + (setf (point) (point-min)) + (search-forward look-for) + (list (- (point) (length look-for) 1) (- (point-max) (point))))) + (save-excursion + (save-restriction + (boxquote-narrow-to-boxquote) + (setf (point) (+ (point-min) + (length (concat boxquote-top-corner + boxquote-top-and-tail)))) + (if (looking-at (boxquote-title-format-as-regexp)) + (buffer-substring-no-properties (+ (point) prefix-len) + (- (line-end-position) suffix-len)) + ""))))) + +;;;###autoload +(defun boxquote-title (title) + "Set the title of the current boxquote to TITLE. + +If TITLE is an empty string the title is removed. Note that the title will +be formatted using `boxquote-title-format'." + (interactive (list (read-from-minibuffer "Title: " (boxquote-get-title)))) + (save-excursion + (save-restriction + (boxquote-narrow-to-boxquote) + (setf (point) (+ (point-min) + (length (concat boxquote-top-corner + boxquote-top-and-tail)))) + (unless (eolp) + (kill-line)) + (unless (zerop (length title)) + (insert (format boxquote-title-format title)))))) + +;;;###autoload +(defun boxquote-region (start end) + "Draw a box around the left hand side of a region bounding START and END." + (interactive "r") + (save-excursion + (save-restriction + (flet ((bol-at-p (n) + (setf (point) n) + (bolp)) + (insert-corner (corner pre-break) + (insert (concat (if pre-break "\n" "") + corner boxquote-top-and-tail "\n")))) + (let ((break-start (not (bol-at-p start))) + (break-end (not (bol-at-p end)))) + (narrow-to-region start end) + (run-hooks 'boxquote-region-hook) + (setf (point) (point-min)) + (insert-corner boxquote-top-corner break-start) + (let ((start-point (line-beginning-position))) + (setf (point) (point-max)) + (insert-corner boxquote-bottom-corner break-end) + (string-rectangle start-point + (progn + (setf (point) (point-max)) + (forward-line -2) + (line-beginning-position)) + boxquote-side))))))) + +;;;###autoload +(defun boxquote-buffer () + "Apply `boxquote-region' to a whole buffer." + (interactive) + (boxquote-region (point-min) (point-max))) + +;;;###autoload +(defun boxquote-insert-file (filename) + "Insert the contents of a file, boxed with `boxquote-region'. + +If `boxquote-title-files' is non-nil the boxquote will be given a title that +is the result of applying `boxquote-file-title-function' to FILENAME." + (interactive "fInsert file: ") + (insert (with-temp-buffer + (insert-file-contents filename nil) + (run-hooks 'boxquote-insert-file-hook) + (boxquote-buffer) + (when boxquote-title-files + (boxquote-title (funcall boxquote-file-title-function filename))) + (buffer-string)))) + +;;;###autoload +(defun boxquote-insert-buffer (buffer) + "Insert the contents of a buffer, boxes with `boxquote-region'. + +If `boxquote-title-buffers' is non-nil the boxquote will be given a title that +is the result of applying `boxquote-buffer-title-function' to BUFFER." + (interactive "bInsert Buffer: ") + (boxquote-text + (with-current-buffer buffer + (buffer-substring-no-properties (point-min) (point-max)))) + (when boxquote-title-buffers + (boxquote-title (funcall boxquote-buffer-title-function buffer)))) + +;;;###autoload +(defun boxquote-kill-ring-save () + "Like `kill-ring-save' but remembers a title if possible. + +The title is acquired by calling `boxquote-kill-ring-save-title'. The title +will be used by `boxquote-yank'." + (interactive) + (call-interactively #'kill-ring-save) + (setf (car kill-ring-yank-pointer) + (format "%S" (list + 'boxquote-yank-marker + (funcall boxquote-kill-ring-save-title) + (car kill-ring-yank-pointer))))) + +;;;###autoload +(defun boxquote-yank () + "Do a `yank' and box it in with `boxquote-region'. + +If the yanked entry was placed on the kill ring with +`boxquote-kill-ring-save' the resulting boxquote will be titled with +whatever `boxquote-kill-ring-save-title' returned at the time." + (interactive) + (save-excursion + (insert (with-temp-buffer + (yank) + (setf (point) (point-min)) + (let ((title + (let ((yanked (condition-case nil + (read (current-buffer)) + (error nil)))) + (when (listp yanked) + (when (eq (car yanked) 'boxquote-yank-marker) + (setf (buffer-string) (nth 2 yanked)) + (nth 1 yanked)))))) + (run-hooks 'boxquote-yank-hook) + (boxquote-buffer) + (when title + (boxquote-title title)) + (buffer-string)))))) + +;;;###autoload +(defun boxquote-defun () + "Apply `boxquote-region' the current defun." + (interactive) + (mark-defun) + (boxquote-region (region-beginning) (region-end))) + +;;;###autoload +(defun boxquote-paragraph () + "Apply `boxquote-region' to the current paragraph." + (interactive) + (mark-paragraph) + (boxquote-region (region-beginning) (region-end))) + +;;;###autoload +(defun boxquote-boxquote () + "Apply `boxquote-region' to the current boxquote." + (interactive) + (let ((box (boxquote-points-with-check))) + (boxquote-region (car box) (1+ (cdr box))))) + +(defun boxquote-help-buffer-name (item) + "Return the name of the help buffer associated with ITEM." + (if (boxquote-xemacs-p) + (loop for buffer in (symbol-value 'help-buffer-list) + when (string-match (concat "^*Help:.*`" item "'") buffer) + return buffer) + "*Help*")) + +(defun boxquote-quote-help-buffer (help-call title-format item) + "Perform a help command and boxquote the output. + +HELP-CALL is a function that calls the help command. + +TITLE-FORMAT is the `format' string to use to product the boxquote title. + +ITEM is a function for retrieving the item to get help on." + (let ((one-window-p (one-window-p))) + (boxquote-text + (save-window-excursion + (funcall help-call) + (with-current-buffer (boxquote-help-buffer-name (funcall item)) + (buffer-substring-no-properties (point-min) (point-max))))) + (boxquote-title (format title-format (funcall item))) + (when one-window-p + (delete-other-windows)))) + +;;;###autoload +(defun boxquote-describe-function () + "Call `describe-function' and boxquote the output into the current buffer." + (interactive) + (boxquote-quote-help-buffer + #'(lambda () + (call-interactively #'describe-function)) + boxquote-describe-function-title-format + #'(lambda () + (car (if (boxquote-xemacs-p) + (symbol-value 'function-history) + minibuffer-history))))) + +;;;###autoload +(defun boxquote-describe-variable () + "Call `describe-variable' and boxquote the output into the current buffer." + (interactive) + (boxquote-quote-help-buffer + #'(lambda () + (call-interactively #'describe-variable)) + boxquote-describe-variable-title-format + #'(lambda () + (car (if (boxquote-xemacs-p) + (symbol-value 'variable-history) + minibuffer-history))))) + +;;;###autoload +(defun boxquote-describe-key (key) + "Call `describe-key' and boxquote the output into the current buffer. + +If the call to this command is prefixed with \\[universal-argument] you will also be +prompted for a buffer. The key defintion used will be taken from that buffer." + (interactive "kDescribe key: ") + (let ((from-buffer (if current-prefix-arg + (read-buffer "Buffer: " (current-buffer) t) + (current-buffer)))) + (let ((binding + (with-current-buffer from-buffer + (key-binding key)))) + (if (or (null binding) (integerp binding)) + (message "%s is undefined" (with-current-buffer from-buffer + (key-description key))) + (boxquote-quote-help-buffer + #'(lambda () + (with-current-buffer from-buffer + (describe-key key))) + boxquote-describe-key-title-format + #'(lambda () + (with-current-buffer from-buffer + (key-description key)))))))) + +;;;###autoload +(defun boxquote-shell-command (command) + "Call `shell-command' with COMMAND and boxquote the output." + (interactive (list (read-from-minibuffer "Shell command: " nil nil nil 'shell-command-history))) + (boxquote-text (with-temp-buffer + (shell-command command t) + (buffer-string))) + (boxquote-title command)) + +;;;###autoload +(defun boxquote-where-is (definition) + "Call `where-is' with DEFINITION and boxquote the result." + (interactive "CCommand: ") + (boxquote-text (with-temp-buffer + (where-is definition t) + (format boxquote-where-is-body-format definition (buffer-string)))) + (boxquote-title (format boxquote-where-is-title-format definition))) + +;;;###autoload +(defun boxquote-text (text) + "Insert TEXT, boxquoted." + (interactive "sText: ") + (save-excursion + (unless (bolp) + (insert "\n")) + (insert + (with-temp-buffer + (insert text) + (boxquote-buffer) + (buffer-string))))) + +;;;###autoload +(defun boxquote-narrow-to-boxquote () + "Narrow the buffer to the current boxquote." + (interactive) + (let ((box (boxquote-points-with-check))) + (narrow-to-region (car box) (cdr box)))) + +;;;###autoload +(defun boxquote-narrow-to-boxquote-content () + "Narrow the buffer to the content of the current boxquote." + (interactive) + (let ((box (boxquote-points-with-check))) + (narrow-to-region (save-excursion + (setf (point) (car box)) + (forward-line 1) + (point)) + (save-excursion + (setf (point) (cdr box)) + (line-beginning-position))))) + +;;;###autoload +(defun boxquote-kill () + "Kill the boxquote and its contents." + (interactive) + (let ((box (boxquote-points-with-check))) + (kill-region (car box) (1+ (cdr box))))) + +;;;###autoload +(defun boxquote-fill-paragraph (arg) + "Perform a `fill-paragraph' inside a boxquote." + (interactive "P") + (if (boxquote-quoted-p) + (save-restriction + (boxquote-narrow-to-boxquote-content) + (let ((fill-prefix boxquote-side)) + (fill-paragraph arg))) + (fill-paragraph arg))) + +;;;###autoload +(defun boxquote-unbox-region (start end) + "Remove a box created with `boxquote-region'." + (interactive "r") + (save-excursion + (save-restriction + (narrow-to-region start end) + (setf (point) (point-min)) + (if (looking-at (concat "^" (regexp-quote boxquote-top-corner) + (regexp-quote boxquote-top-and-tail))) + (let ((ends (concat "^[" (regexp-quote boxquote-top-corner) + (regexp-quote boxquote-bottom-corner) + "]" boxquote-top-and-tail)) + (lines (concat "^" (regexp-quote boxquote-side)))) + (loop while (< (point) (point-max)) + if (looking-at ends) do (kill-line t) + if (looking-at lines) do (delete-char 2) + do (forward-line))) + (error "I can't see a box here"))))) + +;;;###autoload +(defun boxquote-unbox () + "Remove the boxquote that contains `point'." + (interactive) + (let ((box (boxquote-points-with-check))) + (boxquote-unbox-region (car box) (1+ (cdr box))))) + +(provide 'boxquote) + +;;; boxquote.el ends here. diff --git a/archive/.emacs.d/site-lisp/centered-window-mode.el b/archive/.emacs.d/site-lisp/centered-window-mode.el new file mode 100644 index 00000000..e5eafac3 --- /dev/null +++ b/archive/.emacs.d/site-lisp/centered-window-mode.el @@ -0,0 +1,103 @@ +;;; centered-window-mode.el --- Center the text when there's only one window +;; +;; Copyright (C) 2014 Anler Hp <http://anler.me> +;; +;; Author: Anler Hp <http://anler.me> +;; Version: 0.0.1 +;; Keywords: faces, windows +;; URL: https://github.com/ikame/centered-window-mode +;; Compatibility: GNU Emacs 23.x, GNU Emacs 24.x +;; +;; This file is NOT part of GNU Emacs. +;; +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 2 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. +;; +;;; Commentary: +;; +;; Enable centered-window-mode and your text is going to be centered when there's +;; only one window in the frame. +;; +;;; Changes Log: +;; +;;; Code: + +(defvar fringe-background nil "The background color used for the fringe") + +(defadvice switch-to-buffer (after cwm/switch-to-buffer activate) + (cwm/window-configuration-change)) + +(defun cwm/setup () + (add-hook 'window-configuration-change-hook + 'cwm/window-configuration-change + nil + t) + (cwm/window-configuration-change)) + +(defun cwm/teardown () + (remove-hook 'window-configuration-change-hook + 'cwm/window-configuration-change + t) + (cwm/window-configuration-change)) + +(defadvice split-window-right (before cwm/reset-on-split activate) + "Disable cwm-mode presentation (if active) before splitting window" + (when fringe-mode + (cwm/reset))) + +(defadvice load-theme (after cwm/set-faces-on-load-theme activate) + "Change the default fringe background whenever the theme changes" + (message "load theme after here") + (cwm/update-fringe-background)) + +(defun cwm/window-configuration-change () + (if (or (> (length (window-list)) 1) + (null centered-window-mode)) + (cwm/reset) + (cwm/center))) + +(defun cwm/center () + (set-window-fringes + nil + (/ (- (frame-pixel-width) + (* 110 (frame-char-width))) + 2))) + +(defun cwm/reset () + (set-window-fringes nil nil)) + +(defun cwm/set-faces () + (custom-set-faces + `(fringe ((t (:background ,fringe-background)))))) + +(defun cwm/update-fringe-background () + (setq fringe-background (cwm/get-fringe-background)) + (cwm/set-faces)) + +(defun cwm/get-fringe-background () + (face-attribute 'default :background)) + +(cwm/update-fringe-background) + +;;;###autoload +(define-minor-mode centered-window-mode + "Minor mode to cwm on the current buffer." + :init-value nil + :lighter " ⌗" + (if centered-window-mode + (cwm/setup) + (cwm/teardown))) + +(provide 'centered-window-mode) + +;;; centered-window-mode.el ends here diff --git a/archive/.emacs.d/site-lisp/hl-sentence.el b/archive/.emacs.d/site-lisp/hl-sentence.el new file mode 100644 index 00000000..2362ff3f --- /dev/null +++ b/archive/.emacs.d/site-lisp/hl-sentence.el @@ -0,0 +1,105 @@ +;;; hl-sentence.el --- highlight a sentence based on customizable face + +;; Copyright (c) 2011 Donald Ephraim Curtis + +;; Author: Donald Ephraim Curtis <dcurtis@milkbox.net> +;; URL: http://github.com/milkypostman/hl-sentence +;; Version: 3 +;; Keywords: highlighting + +;; This file is not part of GNU Emacs. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: +;; +;; Highlight the current sentence using `hl-sentence-face'. +;; +;; To use this package, add the following code to your `emacs-init-file' +;; +;; (require 'hl-sentence) +;; (add-hook 'YOUR-MODE-HOOK 'hl-sentence-mode) +;; (set-face-attribute 'hl-sentence-face nil +;; :foreground "#444") +;; +;; Please send bug reports to +;; https://github.com/milkypostman/hl-sentence/issues +;; +;; This mode started out as a bit of elisp at +;; http://www.emacswiki.org/emacs/SentenceHighlight by Aaron Hawley. + +;;; Code: +(defgroup hl-sentence nil + "Highlight the current sentence." + :group 'convenience) + +;;;###autoload +(defface hl-sentence-face + '((t)) + "The face used to highlight the current sentence." + :group 'hl-sentence) + +(defun hl-sentence-begin-pos () + "Return the point of the beginning of a sentence." + (save-excursion + (unless (= (point) (point-max)) + (forward-char)) + (backward-sentence) + (point))) + +(defun hl-sentence-end-pos () + "Return the point of the end of a sentence." + (save-excursion + (unless (= (point) (point-max)) + (forward-char)) + (backward-sentence) + (forward-sentence) + (point))) + +(defvar hl-sentence-extent nil + "The location of the hl-sentence-mode overlay.") + +;;;###autoload +(define-minor-mode hl-sentence-mode + "Enable highlighting of currentent sentence." + :init-value nil + (progn + (if hl-sentence-mode + (add-hook 'post-command-hook 'hl-sentence-current nil t) + (move-overlay hl-sentence-extent 0 0 (current-buffer)) + (remove-hook 'post-command-hook 'hl-sentence-current t)))) + +(defun hl-sentence-current () + "Highlight current sentence." + (and hl-sentence-mode (> (buffer-size) 0) + (progn + (and (boundp 'hl-sentence-extent) + hl-sentence-extent + (move-overlay hl-sentence-extent + (hl-sentence-begin-pos) + (hl-sentence-end-pos) + (current-buffer)))))) + +(setq hl-sentence-extent (make-overlay 0 0)) +(overlay-put hl-sentence-extent 'face 'hl-sentence-face) + + + +(provide 'hl-sentence) + +;;; hl-sentence.el ends here diff --git a/archive/.emacs.d/site-lisp/org-mairix-el.el b/archive/.emacs.d/site-lisp/org-mairix-el.el new file mode 100644 index 00000000..3f4d4c3d --- /dev/null +++ b/archive/.emacs.d/site-lisp/org-mairix-el.el @@ -0,0 +1,62 @@ +;;; org-mairix-el.el --- create Org links to mairix.el searches + +;; Copyright (C) 2014 Sean Whitton + +;; Author: Sean Whitton <spw@sdf.org> +;; Keywords: mail + +;; This file is free software; you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free +;; Software Foundation; either version 2, or (at your option) any later +;; version. + +;; This file is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +;; more details. + +;;; Commentary: + +;; Leverage existing mairix.el to link to particular mail messages, +;; unlike org-mairix.el which uses Gnus or mutt to view the resultant +;; message + +;;; Code: + +(require 'org) +(require 'mairix) +(require 'f) +(require 's) + +(defvar org-mairix-el-store "~/.org-mairix-el-link") + +(org-add-link-type "mairixel" 'org-mairix-el-open) + +(defun org-mairix-el--get-link () + "Return link from `org-mairix-el-store' file." + (substring (s-trim (f-read org-mairix-el-store)) 0 31)) + +(defun org-mairix-el-open (search) + "Function to open a mairix link SEARCH." + (mairix-search (concat "m:" search "=") nil)) + +(defun org-mairix-el-link () + "Return a link with description DESCRIPTION to a message by its ID." + (interactive ) + (when (f-exists? org-mairix-el-store) + (let ((message-id (org-mairix-el--get-link))) + (concat "[[mairixel:" + message-id + "][" + (read-string "E-mail link description: ") + "]]")))) + +(defun org-mairix-el-insert-link () + "Store a link to a message by its ID." + (interactive) + (when (f-exists? org-mairix-el-store) + (let ((message-id (org-mairix-el--get-link))) + (org-insert-link nil (concat "mairixel:" message-id))))) + +(provide 'org-mairix-el) +;;; org-mairix-el ends here diff --git a/archive/.emacs.d/site-lisp/spw-pyblosxom.el b/archive/.emacs.d/site-lisp/spw-pyblosxom.el new file mode 100644 index 00000000..a312231a --- /dev/null +++ b/archive/.emacs.d/site-lisp/spw-pyblosxom.el @@ -0,0 +1,142 @@ +;;; spw-pyblosxom --- helper functions for Sean's Org-mode-managed Pyblosxom blog + +;;; Commentary: + +;;; automate repetitive tasks + +;;; Code: + +(require 'magit) +(require 'f) +(require 's) + +(defvar spw-pyblosxom-image-extensions '("png" "jpg" "jpeg") + "Extensions for image files that may be inserted with `spw-pyblosxom-insert-image'.") + +(defun spw-pyblosxom--image-extensions-regexp () + "Put `spw-pyblosxom-image-extensions' into a regexp disjunction." + (let ((regexp "")) + (dolist (elt spw-pyblosxom-image-extensions regexp) + (if (string= regexp "") + (setq regexp elt) + (setq regexp (concat regexp "\\|" elt)))))) + +(defun spw-pyblosxom--get-images (&optional nothumbs) + "Return a list of image files inserted in the buffer with `spw-pyblosxom-insert-image'. +With optional argument NOTHUMBS, exclude thumbnail files." + (let ((images)) + (save-excursion + (goto-char (point-min)) + (while (search-forward-regexp (concat + "\\[http:\\/\\/spw.sdf.org\\/blog\\/\\(.*?\\(" + (spw-pyblosxom--image-extensions-regexp) + "\\)\\)\\]") nil t) + (if (not (and nothumbs (string-match-p (concat "thumb\\.\\(" + (spw-pyblosxom--image-extensions-regexp) + "\\)") + (match-string-no-properties 1)))) + (add-to-list 'images (concat "~/doc/www/blog/" + (match-string-no-properties 1)))))) + images)) + +(defun spw-pyblosxom-publish () + "Set the rdate.py-readable blog publishing timestamp, stage in git and publish." + (interactive) + ;; 1. set the publication date for rdate.py script + (save-excursion + (goto-char (point-min)) + (if (search-forward-regexp "^#\\+HTML: #published [0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} \\(\\?\\?:\\?\\?:\\?\\?\\|[0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\}\\)") + (replace-match (concat "#+HTML: #published " + (format-time-string "%Y-%m-%d %H:%M:00" nil t))) + (message "entry yasnippet broken"))) + (save-buffer) + ;; 2. stage and publish images and post + (let ((to-publish (cons + (buffer-file-name) + (spw-pyblosxom--get-images)))) + + (dolist (elt to-publish) + (org-publish-file elt) + (magit-stage-file (f-relative elt (magit-toplevel))))) + ;; 3. open a magit status buffer + (magit-status (magit-toplevel))) + +(defun spw-pyblosxom-insert-image (file arg) + "Insert image file FILE into one of my blog posts. +With prefix argument ARG, thumbnail it." + (interactive "fimage file: \nP") + ;; 1. copy image file into right directory with sensible filename + (let ((images (spw-pyblosxom--get-images t))) + (let ((images-count (length images))) + (let ((this-image (concat (f-base buffer-file-name) + (number-to-string (+ images-count 1)) + "." + (f-ext file))) + (this-image-thumb (concat (f-base buffer-file-name) + (number-to-string (+ images-count 1)) + "thumb." + (f-ext file)))) + + (copy-file file this-image) + ;; 2. unless arg, create thumbnail + (when (not arg) + (let ((image-size (split-string (shell-command-to-string + (concat + "identify -format \"%w %h\" " + this-image))))) + (let ((image-width (string-to-number (elt image-size 0))) + (image-height (string-to-number (elt image-size 1)))) + (let ((resize-string (if (< image-height image-width) + "500x" "x500"))) + + (call-process-shell-command "convert" nil nil nil + this-image + "-resize" + resize-string + this-image-thumb))))) + ;; 3. insert link into post at point + (insert "[[http://spw.sdf.org/blog" + (replace-regexp-in-string + "/home/swhitton/doc/www/blog" + "" default-directory) + this-image + "]") + (when (not arg) + (insert "[http://spw.sdf.org/blog" + (replace-regexp-in-string + "/home/swhitton/doc/www/blog" + "" default-directory) + this-image-thumb + "]")) + (insert "]"))))) + +(defun spw-pyblosxom-insert-page-link (link) + "Grab HTML <title> of LINK, ask user to edit and then insert Org URI link." + (interactive "sPaste URL: ") + (let ((title (s-trim (shell-command-to-string (concat "httphtmltitle.py " link))))) + (let ((edited-title (read-string "Edit title: " title))) + (insert "[[" link "][" edited-title "]]")))) + +;;;###autoload +(defun spw-pyblosxom-org-mode-hook () + "Perhaps enable spw-pyblosxom-mode when firing up Org-mode." + (if (or load-file-name buffer-file-name) + (if (string-match-p (concat (substitute-in-file-name "$HOME") "/doc/www/blog/") + (file-name-directory (or load-file-name buffer-file-name))) + (spw-pyblosxom-mode)))) + +;;;###autoload +(define-minor-mode spw-pyblosxom-mode + "Helper functions for my Org-mode-managed Pyblosxom blog." + :lighter " spwPb" + :keymap (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c B B") 'spw-pyblosxom-publish) + (define-key map (kbd "C-c B i") 'spw-pyblosxom-insert-image) + (define-key map (kbd "C-c B l") 'spw-pyblosxom-insert-page-link) + map)) + +;;;###autoload +(add-hook 'org-mode-hook 'spw-pyblosxom-org-mode-hook) + +(provide 'spw-pyblosxom) +;;; spw-pyblosxom.el ends here |