;; $Id: .emacs,v 1.92 2008/11/09 00:52:10 grog Exp grog $
(set-cursor-color "red") ;why has this changed?
(setq blink-cursor-mode nil)
(setq-default case-fold-search nil)
(setq c-tab-always-indent t)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(global-set-key [M-p] 'repeat-complex-command)
; (global-font-lock-mode t)
;; Silence Emacs 22
(setq large-file-warning-threshold nil) ; don't say "File is large, really edit?"
(setq inhibit-startup-message t) ; and don't bring this silly startup screen
(setq load-path (append (list "~/emacs") load-path))
(defun silently-revert-buffer ()
(interactive)
(revert-buffer nil t) )
;;; (setq sentence-end "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*") ;only one space at end of sentence
(global-set-key (quote [67108914]) (quote set-mark-command)) ;;emacs 19.30: what, have the key codes changed?
(global-set-key (quote [4194354]) (quote set-mark-command)) ;; mark as before
(global-set-key "" (quote silently-revert-buffer))
(global-set-key "" 'tags-search)
(global-set-key "B" 'buffer-menu)
(global-set-key "" 'repeat-complex-command)
(global-set-key "" 'compile)
(global-set-key "" 'gdb)
;; (global-set-key "" 'print-buffer)
(global-set-key "" 'reindent-then-newline-and-indent) ;A-CR
(global-set-key "L" 'what-line)
(global-set-key "" 'goto-line)
; (global-set-key "" 'keyboard-quit)
(global-set-key (quote [C-backspace]) (quote backward-delete-char-untabify))
(global-set-key "" 'backward-kill-word)
(global-set-key "h" 'help-for-help)
;; (global-set-key "" 'backward-delete-char) ;; think we don't need this any more
(global-set-key "" 'query-replace-regexp)
(global-set-key (quote [-4194258]) (quote tags-search)) ;c-m-.
(global-set-key (quote [-4194260]) (quote next-file)) ;c-m-,
(put 'eval-expression 'disabled nil)
(setq c-comment-starting-blank nil) ; no initial blank line on multi-line comments
(setq tags-file-name "TAGS")
(load "c-mode")
;; various stuff added for emacs version 19
(global-set-key "" (quote repeat-complex-command)) ;alt-P for previous commands
(global-set-key "F" 'find-file-other-frame)
(global-set-key (quote [-4194257]) (quote indent-all-comments)) ; c-m-/ (from lisp eval; how to set this right?)
(load "iso-insert")
(standard-display-european 1) ;show 8 bit characters correctly
(global-set-key [f2] (quote align-beginning-of-defun))
(global-set-key [M-f2] 'server-edit)
(global-set-key [f3] 'scroll-line-up)
(global-set-key [f4] 8859-1-map) ;F4 gives ISO 8859-1
(global-set-key [f5] 'indent-next-line)
(global-set-key [f6] isearch-forward) ;F6 searches forward
(global-set-key [f7] 'scroll-line-down)
(global-set-key [f8] 'letter-mode)
(global-set-key [S-f8] 'nroff-fill-mode)
(global-set-key [f10] (quote align-end-of-defun))
(global-set-key [f11] 'tidy-up-reply)
(global-set-key [M-f11] 'tidy-up-reply-good)
(global-set-key [S-f11] 'tidy-up-microslop-filth)
(global-set-key [M-S-f11] 'tidy-up-cc-fail-filth)
(global-set-key [C-f11] 'insert-disclaimer)
(global-set-key [M-C-f11] 'insert-trim-warning)
(global-set-key [C-S-f11] 'insert-questions-disclaimer)
(global-set-key [M-f12] 'be-auugexec)
(global-set-key [C-f12] 'be-FreeBSD)
(global-set-key [C-S-f12] 'be-NetBSD)
(global-set-key "5" (quote make-frame-on-display))
(global-set-key [M-S-f1]
(lambda nil
(interactive)
(ispell-change-dictionary "british" nil) ) )
(global-set-key [M-S-f2]
(lambda nil
(interactive)
(ispell-change-dictionary "deutsch" nil) ) )
(global-set-key [M-S-f3]
(lambda nil
(interactive)
(ispell-change-dictionary "francais" nil) ) )
(global-set-key [M-s] 'center-line)
(global-set-key "\234" (quote trim-trailing-whitespace)) ; c-m-\
(column-number-mode 1)
(display-time)
;; Use this to stop batch Emacsen
(defun exit ()
(save-buffers-kill-emacs t) )
(defun tidy-up-reply ()
(interactive)
(letter-mode)
(local-set-key "" (quote server-edit))
(local-set-key "" 'clear-trailing-junk-and-save)
(save-excursion
(beginning-of-buffer)
(search-forward "
")
;; Decide whether to change names
(save-excursion
(if (or (re-search-backward "@[a-z.]*FreeBSD.org" 0 t)
(re-search-backward "@[a-z.]*FreeBSD.ORG" 0 t)
(re-search-backward "@[a-z.]*freebsd.org" 0 t) )
(be-FreeBSD) ) )
(save-excursion
(if (re-search-backward "@[a-z.]*pasocentral.org" 0 t)
(be-pasocentral) ) )
(save-excursion
(if (re-search-backward "@[a-z.]*tvguide.org" 0 t)
(be-tvguide) ) )
(save-excursion
(if (re-search-backward "@craftbrewer.org" 0 t)
(be-craftbrewer) ) )
(save-excursion
(if (or (re-search-backward "@[a-z.]*NetBSD.org" 0 t)
(re-search-backward "@[a-z.]*NetBSD.ORG" 0 t)
(re-search-backward "@[a-z.]*netbsd.org" 0 t) )
(be-NetBSD) ) )
(save-excursion
(if (re-search-backward "@auug.org.au" 0 t)
(be-auugexec) ) )
(save-excursion
(if (re-search-backward "link@anu.edu.au" 0 t)
(be-linklist) ) )
(save-excursion
(if (re-search-backward "craftbrewer.org@lists" 0 t)
(be-craftbrewer) ) )
(beginning-of-buffer)
(while (re-search-forward "^[]>|]" nil t)
(end-of-line)
(let ((limit (point))
(braced nil) )
(if (looking-at "\\]>") ;got a braced expression at the end
(progn (backward-sexp)
(setq braced (char-after (point))) ;save the character as predicate
(delete-char 1)
(insert "~#~") ;make sure we stop here
(setq limit (point)) ) ) ;stop looking at the containing expression
(beginning-of-line)
(while (looking-at "[]~>|%]") ;just a single quote
(delete-char 1) ;remove it
(insert ">") ;and replace with a >
(while (looking-at "[ ]+[]~>:|%]") ;more to come
(delete-char 1) ) ) ;remove the white space
(if (not (looking-at "[ ]")) ; no space after,
(insert " ") ) ;put one in
(if braced
(replace-regexp "~#~" braced nil) ) ) )
;; remove the host name from the reply. This shouldn't be done
;; here, it should be done in mutt, but I know how to do it here.
(beginning-of-buffer)
(replace-regexp "^\\(From.*@\\)[a-z.]*\\(lemis.com\\)" "\\1\\2" nil)
(beginning-of-buffer)
(replace-regexp "[ ]+$" "" nil)
(beginning-of-buffer)
(if (or (re-search-forward "^To:.*questions" nil t)
(re-search-forward "^C[Cc]:.*questions" nil t) )
(save-excursion
(if (and (re-search-forward "
--
" nil t)
(not (looking-at "When replying")) )
(progn (backward-char 1)
(insert "
When replying to this message, please copy the original recipients.
If you don't, I may ignore the reply or reply to the original recipients.
For more information, see http://www.lemis.com/questions.html" ) ) ) ) )
(beginning-of-buffer)
(search-forward "
") ) )
(defun trim-trailing-whitespace ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "[ ]+$" "" nil nil nil) ) )
(defun be-auugexec ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "@[a-z]*\.*lemis.com" "@auug.org.au" nil)
(beginning-of-buffer)
(replace-regexp "grog@" "Greg.Lehey@" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(kill-line 1)
(insert "AUUG: Australian UNIX and Open Systems User Group
") ) )
(if (re-search-forward "^WWW-Home-Page: *" nil t)
(progn
(kill-line 1)
(insert "http://www.auug.org.au/
") ) )
(if (re-search-forward "^-- *
Finger" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
(defun be-craftbrewer ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@" "craftbrewer@" nil) ) )
(defun be-linklist ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@.*lemis.com" "linklist@lemis.com" nil) ) )
(defun be-FreeBSD ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@[a-z]*\.*lemis.com" "grog@FreeBSD.org" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(kill-line 1)
(insert "The FreeBSD Project
") ) )
(if (re-search-forward "^WWW-Home-Page: *" nil t)
(progn
(kill-line 1)
(insert "http://www.FreeBSD.org/
") ) )
(if (re-search-forward "^-- *
Finger" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
(defun be-NetBSD ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@[a-z]*\.*lemis.com" "grog@NetBSD.org" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(kill-line 1)
(insert "The NetBSD Project
") ) )
(if (re-search-forward "^WWW-Home-Page: *" nil t)
(progn
(kill-line 1)
(insert "http://www.NetBSD.org/
") ) )
(if (re-search-forward "^-- *
Finger" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
(defun be-pasocentral ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@[a-z]*\.*lemis.com" "grog@pasocentral.org" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
(defun be-tvguide ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@[a-z]*\.*lemis.com" "tvguide@lemis.com" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
(defun be-craftbrewer ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "grog@[a-z]*\.*lemis.com" "craftbrewer@lemis.com" nil)
(beginning-of-buffer)
(if (re-search-forward "^Organization: *" nil t)
(progn
(beginning-of-line)
(kill-line 1) ) ) ) )
;; same as tidy-up-reply, except that it
;; also gets rid of Jerry D.'s damn silly braces. I
;; can't do this in the general case, because it screws
;; up C code examples
(defun tidy-up-reply-good ()
(interactive)
(letter-mode)
(save-excursion
(beginning-of-buffer)
(while (re-search-forward "^[]>|]" nil t)
(end-of-line)
(let ((limit (point))
(braced nil) )
(if (looking-at "\\]>") ;got a braced expression at the end
(progn (backward-sexp)
(setq braced (char-after (point))) ;save the character as predicate
(delete-char 1)
(insert "~#~") ;make sure we stop here
(setq limit (point)) ) ) ;stop looking at the containing expression
(beginning-of-line)
(while (looking-at "[]:~#}+>|%]") ;just a single quote
(delete-char 1) ;remove it
(insert ">") ;and replace with a >
(while (looking-at "[ ]+[]~#}+>:|%]") ;more to come
(delete-char 1) ) ) ;remove the white space
(if (not (looking-at "[ ]")) ; no space after,
(insert " ") ) ;put one in
(if braced
(replace-regexp "~#~" braced nil) ) ) )
(beginning-of-buffer)
(replace-regexp "[ ]+$" "" nil) ) )
;; Show Microsoft people the crap they come up with.
(defun mess-up-reply ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-string "" "\\205")
(beginning-of-buffer)
(replace-string "" "\\220")
(beginning-of-buffer)
(replace-string "" "\\221")
(beginning-of-buffer)
(replace-string "" "\\222")
(beginning-of-buffer)
(replace-string "" "\\223")
(beginning-of-buffer)
(replace-string "" "\\224")
(beginning-of-buffer)
(replace-string "" "\\225")
(beginning-of-buffer)
(replace-string "" "\\226")
(beginning-of-buffer)
(replace-string "" "--") ) )
;; Show Microsoft people the crap they come up with.
;; Fix this!
(defun improve-microsoft-character ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-string "" "\\205")
(beginning-of-buffer)
(replace-string "" "") ; should be a dagger
(beginning-of-buffer)
(replace-string "" "\\220")
(beginning-of-buffer)
(replace-string "" "`")
(beginning-of-buffer)
(replace-string "" "'")
(beginning-of-buffer)
(replace-string "" "\\223")
(beginning-of-buffer)
(replace-string "" "\\224")
(beginning-of-buffer)
(replace-string "" "\\225")
(beginning-of-buffer)
(replace-string "" "-")
(beginning-of-buffer)
(replace-string "" "\\227") ) )
(defun tidy-up-microslop-filth ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp ">* -----Original Message----- *" "" nil)
(beginning-of-buffer)
(query-replace-regexp "\\[SMTP:\\([^]]+\\)\\]" "<\\1>" nil)
(beginning-of-buffer)
(query-replace-regexp "\\(From:\\|To:\\) *\"\\([A-z0-9 @.]+\\)\"" "\\1 \\2" nil)
(beginning-of-buffer)
(query-replace-regexp "\\([> ]*Sent:.*\\)
\\([> ]*Subject: .*\\)" "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "\\([> ]*From:.*\\)
\\([> ]*Subject: .*\\)" "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "\\([> ]+From:.*\\)
\\([> ]*To: .*\\)" "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "\\([> ]+From:.*\\)
\\([> ]*Cc: .*\\)" "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "\\(>[> ]*From: \\).*[Oo]n [Bb]ehalf [Oo]f " "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "\\(>[> ]*From: \\).*
.*[Oo]n [Bb]ehalf [Oo]f " "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "^>\\(>*\\)\\s *From:\\s *\\(.*\\)
>*\\s *Date:\\s *\\(.*\\)" "\\1 On \\3, \\2 wrote:" nil)
(beginning-of-buffer)
(query-replace-regexp "^>\\(>*\\)\\s *Date: \\(.*\\)
>*\\s *From: *\\(.*\\)" "\\1 On \\2, \\3 wrote:" nil)
(beginning-of-buffer)
(query-replace-regexp "^>\\([> ]*\\)From:[ ]*\\(.*\\)
>*\\s *Sent:[ ]*\\(.*\\)" "\\1On \\3, \\2 wrote:" nil)
(beginning-of-buffer)
(query-replace-regexp "\"'*\\([^\"'
]+\\)'*\" <\\1>" "\\1" nil)
(beginning-of-buffer)
(query-replace-regexp "'\\([^<]+\\)' <" "\\1 <" nil)
(beginning-of-buffer)
(query-replace-regexp " *\\[mailto:\\([^]]+\\)\\] *" " " nil)
(beginning-of-buffer)
; Tidy up "On date ...." lines
(query-replace-regexp "^\\(On .*\\) *([^)]*) *" "\\1" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\(^On .* *<[^>]+\\)> *wrote" " wrote" nil)
(beginning-of-buffer)
(query-replace-regexp "\\( *<[^>]+\\)> *wrote" " wrote" nil)
; Replace "Lehey, Grog" with Greg Lehey
(beginning-of-buffer)
(query-replace-regexp "'*\"'*\\([-A-z ]+\\), *\\([-A-z ]+\\) *\\((.*)\\)'*\"'*" "\\2 \\1" nil)
(beginning-of-buffer)
(query-replace-regexp "'*\"'*\\([-A-z ]+\\), *\\([-A-z ]+\\) *'*\"'*" "\\2 \\1" nil)
(beginning-of-buffer)
(query-replace-regexp "^\\(On .*\\) \\([A-z-]+\\), *\\([A-z-]+\\) \\(wrote:\\)" "\\1 \\3 \\2 \\4" nil)
(query-replace-regexp "^\\(>+\\) *\\([A-z].*\\)
>* *\\([0-9][0-9]/[0-9][0-9]/[0-9][0-9]\\) \\([0-9][0-9]:[0-9][0-9].*\\) *" "\\1 On \\3/ at \\4, \\2 wrote:" nil nil nil) ) )
(defun tidy-up-cc-fail-filth ()
(interactive)
; (save-excursion
(beginning-of-buffer)
(replace-regexp "^\\(>+\\)\\(> .*\\)
\\1\\( .*\\)" "\\1\\2\\3" nil) ); )
(defun insert-disclaimer ()
(interactive)
(save-excursion
(beginning-of-buffer)
(re-search-forward "
" nil t)
(backward-char 1)
(insert "
[Format recovered--see http://www.lemis.com/email/email-format.html]
")
(if (and (re-search-forward "
-- *
" nil t)
(not (looking-at "When replying")) )
(progn (backward-char 1)
(insert "
When replying to this message, please take care not to mutilate the
original text.
For more information, see http://www.lemis.com/email.html" ) ) ) ) )
(defun insert-trim-warning ()
(interactive)
(save-excursion
(beginning-of-buffer)
(re-search-forward "
" nil t)
(backward-char 1)
(insert "
[irrelevant text trimmed]
") ) )
(defun insert-questions-disclaimer ()
(interactive)
(save-excursion
(beginning-of-buffer)
(re-search-forward "
--
" nil t)
(backward-char 1)
(insert "
When replying to this message, please copy the original recipients.
For more information, see http://www.lemis.com/questions.html") ) )
(defun slidy-up-reply ()
(interactive)
(letter-mode)
;;; (let ((anchor (point)))
(save-excursion
(beginning-of-buffer)
(replace-regexp "^\\(>+\\) +[]>:|+] *\\(.*[^]]*\\)$" "\\1> \\2" nil)
(beginning-of-buffer)
(replace-regexp "^\\(>+\\)\\([^ >
]\\)" "\\1 \\2" nil)
(beginning-of-buffer)
(while (re-search-forward "[ ]+$" nil t)
(replace-match "" nil nil) ) ) )
(defun toady-up-reply ()
(interactive)
(letter-mode)
;;; (let ((anchor (point)))
(save-excursion
(beginning-of-buffer)
(while (re-search-forward "^\\([]>}:]+\\)\\([^ ]\\) \\]" nil t)
(replace-match "\\1> \\2" nil nil) )
(beginning-of-buffer)
(while (re-search-forward "^\\([]>}:]+\\)[ ]+\\([|>:]+\\)" nil t)
(replace-match "\\1\\2" nil nil) )
(beginning-of-buffer)
;;; insert a space after initial >>s followed by anything except white space
(replace-regexp "^\\(>+\\)\\([^ >
]\\)" "\\1 \\2")
(beginning-of-buffer)
(while (re-search-forward "[ ]+$" nil t)
(replace-match "" nil nil) ) ) )
;;; (progn (beginning-of-buffer)
;;; (replace-regexp "[ ]+$" "" nil) ) ) ) ) )
;;; (beginning-of-buffer)
;;; (goto-char anchor) ) )
(defun letter-mode () ;this gets called by F8
(interactive)
(indented-text-mode)
(flyspell-mode nil)
(ispell-change-dictionary "british" nil)
(auto-fill-mode nil) )
(defun nroff-fill-mode () ;this gets called by S-F8
(interactive)
(nroff-mode)
(auto-fill-mode nil)
(flyspell-mode nil)
(setq indent-tabs-mode nil) ; tab with spaces.
;; Add stuff for indenting C code
(local-set-key (quote [-4194257]) (quote indent-all-comments)) ; c-m-/ (from lisp eval; how to set this right?) (local-set-key "" (quote repeat-complex-command)) ;alt-P for previous commands
(local-set-key "\e/" 'indent-next-comment) ;invoke with Alt-/
(local-set-key "\e" 'indent-all-comments) ;invoke with ctrl-Alt-/
(local-set-key [C-S-l] 'next-slide-please)
(make-local-variable 'definite-comment-start)
(setq definite-comment-start "[ ]/\\* ") ;comment preceded by a space or a tab
(make-local-variable 'comment-end)
(setq comment-end " */")
(make-local-variable 'comment-column)
(setq comment-column 30)
(make-local-variable 'comment-start-skip)
(setq comment-start-skip "/\\*+ *")
(make-local-variable 'comment-indent-hook)
(setq comment-indent-hook 'c-comment-indent)
;; end C code stuff
(local-set-key "" 'clear-trailing-junk-and-save)
(local-set-key '[67108910] 'expand-sentence-end)
(local-set-key '[M-S-l] 'insert-slide)
(local-set-key '[C-.] 'expand-sentence-end)
(local-set-key '[S-tab] 'tab-to-double-tilde)
(local-set-key '[M-f1] 'set-bi)
(local-set-key '[C-f1] 'set-icw) ;comment in .Ps
(local-set-key '[f1] 'set-i)
(local-set-key '[f2] 'repeat-complex-command)
(local-set-key (quote [M-f2]) (quote move-indices))
(local-set-key (quote [M-f4]) (quote transpose-index-rotated-around-comma))
(local-set-key '[M-f5] 'insert-tbl-skeleton)
(local-set-key '[S-f5] 'insert-page-ref)
(local-set-key '[f6] 'add-nroff-index)
(local-set-key '[C-f6] 'add-nroff-index-cw)
;; (local-set-key '[M-f6] 'add-nroff-indices)
(local-set-key '[M-f7] 'insert-tl-skeleton)
(local-set-key '[S-f8] 'insert-tbl-braces)
(local-set-key '[f8] 'insert-sreg-quote)
(local-set-key '[C-f8] 'insert-sref-quote)
(local-set-key '[C-f7] 'insert-naked-sref-quote)
(local-set-key '[M-f9] 'set-cb)
(local-set-key '[S-f9] 'set-b)
(local-set-key '[f9] 'set-cw)
(local-set-key '[f11] 'beep)
(local-set-key '[f10] 'fill-paragraph)
(local-set-key '[M-f10] 'insert-reply-comment)
(local-set-key '[f12] 'insert-tl-skeleton)
(local-set-key "\242" (lambda () (interactive) (insert "\\[lq]"))) ;M-"
(local-set-key "\247" (lambda () (interactive) (insert "\\[rq]"))) ;M-'
(local-set-key (quote [67108909]) (lambda () (interactive) (insert "\\[em]"))) ;;C--
(set-fill-column 80) )
(defun expand-sentence-end nil
(interactive)
(query-replace-regexp "\\. \\([^
]\\)" ". \\1" nil) )
(defun transpose-index-rotated-around-comma ()
(interactive)
"Find an index hit with a comma in it and add a second hit with the
text before and after the comma transposed"
(query-replace-regexp "X \"\\(.*\\), \\(.*\\)\"$" "X \"\\1, \\2\"
.X \"\\2, \\1\"" nil) )
(defun move-indices ()
(interactive)
"Starting at point, find the next index hit (.X) and move it up to the
next troff command."
(if (re-search-forward "^\\.X " nil t)
(progn
(beginning-of-line)
(kill-line 1)
(re-search-backward "^\\." nil t)
(forward-line)
(yank) ) ) )
(defun insert-tbl-braces ()
(interactive)
"Insert the pair
#T{
T}
at point"
(insert "#T{
T}")
(backward-char 3) )
(defun insert-sreg-quote ()
(interactive)
"Insert the text \\*[] at point and place the cursor between the []"
(insert "\\*[]")
(backward-char 1) )
(defun insert-sref-quote ()
(interactive)
"Insert the text \"\\*[]\" at point and place the cursor between the []"
(insert ".Sref \"\\*[]\" \\&")
(backward-char 5) )
(defun insert-naked-sref-quote ()
(interactive)
"Insert the text \\*[] at point and place the cursor between the []"
(insert ".Sref \\*[] \\&")
(backward-char 4) )
(defun insert-tbl-skeleton ()
(interactive)
(insert ".br
.ne 1i
.TB \"\"
.TS H
box,center,tab(#) ;
lfCWp9 | lw65 .
***headings
=
.TH
**
.TE
")
(search-backward "\"\""
)
(forward-char 1) )
(defun tab-to-double-tilde ()
(interactive)
"Search the next tilde pair and delete them. This is a helper
function for insert-tl-skeleton"
(search-forward "~~")
(backward-delete-char 2) )
(defun insert-tl-skeleton ()
(interactive)
(insert ".tl '\\f[CW]~~~\\fP''\\fI(~)\\fR'
.QS
~~
.QQE
.LP
")
(search-backward "~~~")
(delete-char 3) )
(defun insert-reply-comment ()
(interactive)
(insert "
.\\\" -- ") )
(defun insert-page-ref ()
(interactive)
(insert "see page \\*[]")
(backward-char 1) )
;; Add indices for all italicized expressions
(defun add-nroff-indices ()
(interactive)
(beginning-of-buffer)
(replace-regexp "^\\(.*\\\\fI\\)\\([^\\]+\\)\\(.*\\)$" "\\1\\2\\3
.X \"\\2\"" nil)
(beginning-of-buffer)
(replace-regexp "\\(^\\.X.*[^\"
]+
\\)" "\\1 ")
(beginning-of-buffer)
(replace-regexp "\\(^\\.[A-D]h \\)\\(.*\\)$" "\\1\\2
.X \\2" nil)
(beginning-of-buffer)
(query-replace-regexp "^\\.X \".*\"
" "" nil) )
;; search for an italicized expression and add an index entry.
(defun add-nroff-index ()
"Query add index entry after any text in \\fI"
(interactive)
(let ((finished nil)
(start)
(valid)
(c) )
(while (and (re-search-forward "\\\\fI\\([^\\]+\\)\\\\f[RP]\\([^
]*\\)[
]*" nil t) ;found an italicized comment
(not finished) )
(progn
(search-backward "\\fI")
(forward-char 3) ;beyond the \fI
(setq start (point))
(re-search-forward "\\f[RP]")
(backward-char 3) ;before the \f[RP]
(replace-highlight start (point)) ;highlight what we're going to do
(message "Add index? ")
(setq valid nil)
(while (not valid)
(setq valid t)
(cond ((char-equal (setq c (read-char)) ?y)
(save-excursion
(copy-region-as-kill start (point)) ;copy
(re-search-backward "^\\." nil t) ;find a good place to put the index
(forward-line) ;put on the following line
(insert ".X \"")
(yank)
(insert "\"
")
(forward-line -1) ;back to the beginning of the line
(while (not (looking-at "\\.X"))
(delete-backward-char 1)
(insert " ")
(beginning-of-line) ) ) )
((not (char-equal c ?n))
(setq finished t) ) ) ) ) ) ) )
(defun next-slide-please nil
(interactive)
(insert ".bp
.slide-title \"\"
.Ls B
.LI
")
(search-backward "\"") )
;;; 26 Nov 97
;;; (defun add-nroff-index ()
;;; "Query add index entry after any text in \\fI"
;;; (interactive)
;;; (perform-replace "\\\\fI\\([^\\]+\\)\\\\f[RP]\\([^
;;; ]*\\)[
;;; ]*" "\\\\fI\\1\\\\fP\\2
;;; .X \"\\1\"
;;; " t t nil 1) )
;;; ;; search for an italicized expression and add an index entry.
;;; (defun add-nroff-index ()
;;; "Query add index entry after any text in \\fI"
;;; (interactive)
;;; (perform-replace "^\\(\\.[
;;; -~]+\\)\\\\fI\\([^\\]+\\)\\\\fP\\([^
;;; ]*\\)[
;;; ]*" ".X \"\\1\"
;;; \\1\\\\fI\\2\\\\fP\\3
;;; " t t nil 1) )
(defun add-nroff-index-cw ()
"Query add index entry after any text in \\f[CW]"
(interactive)
(perform-replace "\\\\f(CW\\([^\\]+\\)\\\\fP\\([^
]*\\)[
]*" "\\\\fI\\1\\\\fP\\/\\2
.X \"\\1\"
" t t nil 1) )
(defun scroll-line-down ()
(interactive)
(scroll-down 1) )
(defun scroll-line-up ()
(interactive)
(scroll-up 1) )
(put 'narrow-to-region 'disabled nil)
(defun set-cw ()
(interactive)
(insert "\\f[CW]\\fP")
(backward-char 3) )
(defun set-cb ()
(interactive)
(insert "\\f[CB]\\fP")
(backward-char 3) )
(defun set-b ()
(interactive)
(insert "\\fB\\fP")
(backward-char 3) )
(defun set-i ()
(interactive)
(insert "\\fI\\fP\\/")
(backward-char 5) )
(defun set-bi ()
(interactive)
(insert "\\f[BI]\\fP\\/")
(backward-char 5) )
(defun set-icw ()
(interactive)
(insert "\\fI\\&\\f[CW]")
(backward-char 5) )
(defun insert-slide-title ()
(interactive)
(insert ".Le
.bp
.slide-title \"\"
.Ls B
.LI
")
(search-backward "\"") )
(setq gnus-select-method '(nnspool ""))
(autoload 'gnus "gnus" "Read network news." t)
(autoload 'gnus-post-news "gnuspost" "Post network news." t)
;;;; (setq auto-mode-alist (mapcar 'purecopy
;;;; '(("\\.text$" . text-mode)
;;;; ("\\.c[cp+]*$" . c-mode) ;{Grog, 19.x.91}
;;;; ("\\.ec$" . c-mode) ; Informix ESQL-C file {Grog, 20.xi.92}
;;;; ("\\.h[hcp+]*$" . c-mode)
;;;; ("\\.tex$" . TeX-mode)
;;;; ("\\.el$" . emacs-lisp-mode)
;;;; ("\\.scm$" . scheme-mode)
;;;; ("\\.l$" . lisp-mode)
;;;; ("\\.lisp$" . lisp-mode)
;;;; ("\\.f$" . fortran-mode)
;;;; ("\\.mss$" . scribe-mode)
;;;; ("\\.pl$" . prolog-mode)
;;;; ;;; Less common extensions come here
;;;; ;;; so more common ones above are found faster.
;;;; ("\\.TeX$" . TeX-mode)
;;;; ("\\.sty$" . LaTeX-mode)
;;;; ("\\.bbl$" . LaTeX-mode)
;;;; ("\\.bib$" . text-mode)
;;;; ("\\.article$" . text-mode)
;;;; ("\\.letter$" . text-mode)
;;;; ("\\.texinfo$" . texinfo-mode)
;;;; ("\\.lsp$" . lisp-mode)
;;;; ("\\.prolog$" . prolog-mode)
;;;; ;; Mailer puts message to be edited in /tmp/Re.... or Message
;;;; ("^/tmp/Re" . text-mode)
;;;; ;; some news reader is reported to use this
;;;; ("^/tmp/fol/" . text-mode)
;;;; ("/Message[0-9]*$" . text-mode)
;;;; ("\\.y$" . c-mode)
;;;; ("\\.cc$" . c-mode)
;;;; ("\\.scm.[0-9]*$" . scheme-mode)
;;;; ;; .emacs following a directory delimiter
;;;; ;; in either Unix or VMS syntax.
;;;; ("[]>:/]\\..*emacs" . emacs-lisp-mode)
;;;; ("\\.ml$" . lisp-mode))))
;;;; ;;; Commands added by calc-private-autoloads on Wed May 27 14:03:38 1992.
;;;; (autoload 'calc-dispatch "calc" "Calculator Options" t)
;;;; (autoload 'full-calc "calc" "Full-screen Calculator" t)
;;;; (autoload 'full-calc-keypad "calc" "Full-screen X Calculator" t)
;;;; (autoload 'calc-eval "calc" "Use Calculator from Lisp")
;;;; (autoload 'defmath "calc" nil t t)
;;;; (autoload 'calc "calc" "Calculator Mode" t)
;;;; (autoload 'quick-calc "calc" "Quick Calculator" t)
;;;; (autoload 'calc-keypad "calc" "X windows Calculator" t)
;;;; (autoload 'calc-embedded "calc" "Use Calc inside any buffer" t)
;;;; (autoload 'calc-embedded-activate "calc" "Activate =>'s in buffer" t)
;;;; (autoload 'calc-grab-region "calc" "Grab region of Calc data" t)
;;;; (autoload 'calc-grab-rectangle "calc" "Grab rectangle of data" t)
;;;; (autoload 'edit-kbd-macro "macedit" "Edit Keyboard Macro" t)
;;;; (autoload 'edit-last-kbd-macro "macedit" "Edit Keyboard Macro" t)
;;;; (autoload 'read-kbd-macro "macedit" "Read Keyboard Macro" t)
;;;; (setq load-path (append load-path (list "/pub/gnu/calc-2.02")))
;;;; (global-set-key "\e#" 'calc-dispatch)
;;; End of Calc autoloads.
(defun tex2ix ()
(interactive)
(beginning-of-buffer)
(replace-regexp "\\\\input local" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\bye" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\-" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\\"\\(.\\)" "\\1^" nil)
(beginning-of-buffer)
(replace-regexp "``" "\"" nil)
(beginning-of-buffer)
(replace-regexp "''" "\"" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\twentyninebf\\([^}]*\\)}" "@t = \\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\twentyfourss\\([^}]*\\)}" "@d = \\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\seventeenss\\([^}]*\\)}" "@zb = \\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\ssseventeen\\([^}]*\\)}" "@zb = \\1" nil)
(beginning-of-buffer)
(replace-regexp "\\\\ss[ \\\\
]" "s^" nil)
(beginning-of-buffer)
(replace-regexp "\\\\ss" "s^" nil)
(beginning-of-buffer)
(replace-regexp "%@v =
" "@v = " nil)
(beginning-of-buffer)
(replace-regexp "{\\\\rm von \\([^}]*\\)}" "@a = \\1" nil)
(beginning-of-buffer)
(beginning-of-buffer)
(replace-regexp "{\\\\tt \\([^}]*\\)}" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\bf \\([^}]*\\)}" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\it \\([^}]*\\)}" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\tt" "" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\bf" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\item{\\([^}]*\\)}" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\item" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\nl" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\hskip.*mm" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\indent.*mm" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\([\\\\$%_^~]\\)" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "}" "" nil)
(end-of-buffer)
(insert "
@au1 = Greg Lehey
@au2 = ist unabha^ngiger Unternehmensberater fu^r Hard-
und Software, seit zwanzig Jahren im Gescha^ft und hat
seine Sporen bei Herstellern wie Univac und Tandem und
bei Gros^anwendern wie Karstadt verdient.
(E-Mail: grog%lemis@germany.eu.net)")
(beginning-of-buffer)
;;trim multiple LFs to a maximum of two
(replace-regexp "
[
]+" "
" nil)
(beginning-of-buffer) )
(defun 8bit-to-tex ()
(interactive)
(beginning-of-buffer)
(replace-regexp "" "\\\"a"" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\"u"" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\"o"" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\"U"" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\"A"" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\"O"" nil)
(beginning-of-buffer)
(replace-regexp "[^A-Za-z0-9]" "\\s" nil)
(beginning-of-buffer)
(replace-regexp "" "\\s " nil)
(beginning-of-buffer) )
(defun parcompress ()
(interactive)
(beginning-of-buffer)
;;replace single LFs with spaces when the following line doesn't start with a space or tab
(replace-regexp "\\([^
]\\)
\\([^
]\\)" "\\1 \\2" nil) )
(defun ix2tex ()
(interactive)
(beginning-of-buffer)
(insert "\\input local
")
(end-of-buffer)
(insert "
\bye
")
(replace-regexp "\\\\ss[ \\\\
]" "s^" nil)
(beginning-of-buffer)
(replace-regexp "\\\\ss" "s^" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\twentyninebf\\([^}]*\\)}" "@t = \\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\twentyfourss\\([^}]*\\)}" "@d = \\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\seventeenss\\([^}]*\\)}" "@zb = \\1" nil)
(beginning-of-buffer)
(replace-regexp "%@v =
" "@v = " nil)
(beginning-of-buffer)
(replace-regexp "{\\\\rm von \\([^}]*\\)}" "@a = \\1" nil)
(beginning-of-buffer)
;;replace single LFs with spaces when the following line doesn't start with a space or tab
(replace-regexp "\\([^
]\\)
\\([^
]\\)" "\\1 \\2" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\tt \\([^}]*\\)}" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\bf \\([^}]*\\)}" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\tt" "" nil)
(beginning-of-buffer)
(replace-regexp "{\\\\bf" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\item{\\([^}]*\\)}" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\item" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\nl" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\hskip.*mm" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\indent.*mm" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\([\\\\$%_^~]\\)" "\\1" nil)
(beginning-of-buffer)
(replace-regexp "}" "" nil)
(end-of-buffer)
(insert "
@au1 = Greg Lehey
@au2 = ist unabha^ngiger Unternehmensberater fu^r Hard-
und Software, seit zwanzig Jahren im Gescha^ft und hat
seine Sporen bei Herstellern wie Univac und Tandem und
bei Gros^anwendern wie Karstadt verdient.
(E-Mail: grog%lemis@germany.eu.net)")
(beginning-of-buffer)
;;trim multiple LFs to a maximum of two
(replace-regexp "
[
]+" "
" nil)
(beginning-of-buffer) )
(load "din-tastatur") ;and German keyboard layout
(put 'downcase-region 'disabled nil)
; GCL stuff
; (autoload 'find-doc "find-doc" nil t)
; (global-set-key "d" 'find-doc)
; (visit-doc-file "/usr/local/lib/gcl/doc/DOC")
; new version: assume big images in subdirectory big, small images in subdirectory small.
(defun mkimage ()
(interactive)
(beginning-of-buffer)
(query-replace-regexp "^\\(.+\\)\\.jpeg$" "
" nil) )
(defun html-fill-mode ()
(interactive)
(html-mode)
(auto-fill-mode nil)
(flyspell-mode nil)
(local-set-key "" 'clear-trailing-junk-and-save)
(local-set-key '[C-.] 'expand-sentence-end)
(local-set-key '[67108910] 'expand-sentence-end)
(local-set-key '[M-f1] 'html-set-bi)
(local-set-key '[C-f1] 'html-set-icw) ;comment in .Ps
(local-set-key '[f1] 'html-set-i)
(local-set-key '[f2] 'tagpair)
(local-set-key '[M-f2] 'insert-paragraph)
(local-set-key '[C-f2] 'diary-header)
(local-set-key '[S-f2] 'italic-blockquote)
(local-set-key '[M-S-f2] 'atag)
(local-set-key '[M-S-p] 'insert-paragraph)
(local-set-key '[M-f4] 'html-insert-onephotopage)
(local-set-key '[f5] 'indent-next-line)
(local-set-key '[c-f5] 'html-markup-for-revision)
(local-set-key '[S-f5] 'offset-html-markup-for-revision)
(local-set-key '[M-f5] 'highlight-html-markup-for-revision)
(local-set-key '[f6] 'insert-href)
(local-set-key '[C-f6] 'insert-partial-href)
(local-set-key '[M-f6] 'convert-mailref)
(local-set-key '[M-S-f6] 'insert-wikipedia-href)
(local-set-key '[S-f6] 'insert-mailref)
(local-set-key '[C-f7] 'html-set-literaltext)
(local-set-key '[S-f7] 'nofilltext)
(local-set-key '[M-f7] 'html-inphp)
(local-set-key '[C-f8] 'table-tag)
(local-set-key '[S-f8] 'tr-tag)
(local-set-key '[M-f8] 'td-tag)
(local-set-key '[f9] 'html-set-cw)
(local-set-key '[M-f9] 'html-set-cb)
(local-set-key '[S-f9] 'html-set-b)
(local-set-key '[M-f10] 'html-insert-onephoto)
(local-set-key '[M-S-f10] 'strip-photo-URL)
(local-set-key '[S-f10] 'html-insert-diaryref)
(local-set-key '[C-f10] 'html-insert-diarytag)
(local-set-key (quote [67108909]) (lambda () (interactive) (insert "—"))) ;;C--
(local-set-key (quote [S-right]) (lambda () (interactive) (insert " –> "))) ;;S-->
;; the only way I can do a c-spc
(local-set-key (quote [67108896]) (lambda () (interactive) (insert " "))) ;;C-SPC
(local-set-key "\242" (lambda () (interactive) (insert "“"))) ;M-"
(local-set-key "\247" (lambda () (interactive) (insert "”"))) ;M-'
;; C-M-'. For some reason I can't specify this directly.
(local-set-key '[201326631] (lambda () (interactive) (insert "\" "))) ;C-M-'
(local-set-key '[67108924] (lambda () (interactive) (insert "<"))) ; c-<
(local-set-key '[67108926] (lambda () (interactive) (insert ">"))) ; c->
(local-set-key '[67108902] (lambda () (interactive) (insert "&"))) ; c-&
(local-set-key "\321" 'html-tidy)
(local-set-key "\221" 'html-realtidy)
(set-fill-column 100) )
(defun italic-blockquote ()
(interactive)
(insert "
")
(save-excursion
(insert "
") ) )
(defun table-tag ()
(interactive)
(insert "
")
(save-excursion
(insert "
") ) )
(defun tr-tag ()
(interactive)
(insert "
")
(save-excursion
(insert "
") ) )
(defun td-tag ()
(interactive)
(insert "
")
(save-excursion
(insert "
") ) )
(defun html-set-cw ()
(interactive)
(insert " ")
(backward-char 5) )
(defun html-set-cb ()
(interactive)
(insert " ")
(backward-char 9) )
(defun html-set-b ()
(interactive)
(insert " ")
(backward-char 4) )
(defun html-set-i ()
(interactive)
(insert " ")
(backward-char 4) )
(defun html-set-bi ()
(interactive)
(insert " ")
(backward-char 8) )
(defun html-set-icw ()
(interactive)
(insert "FOO!")
(backward-char 4) )
(defun html-markup-for-revision ()
(interactive)
(insert " ")
(backward-char 7) )
(defun offset-html-markup-for-revision ()
(interactive)
(indent-for-tab-command)
(insert "
")
(backward-char 12) )
(defun highlight-html-markup-for-revision ()
(interactive)
(insert " ")
(search-backward "<" nil t) )
;; Insert the surroundings of an a href construct.
(defun insert-href ()
(interactive)
(insert "") ) )
;; Insert the surroundings of an a href construct.
;; This one includes the http://www. stuff
(defun insert-partial-href ()
(interactive)
(insert "") ) )
(defun insert-lemis-href ()
(interactive)
(insert " ")
(backward-char 6) )
(defun insert-wikipedia-href ()
(interactive)
(setq ref (read-from-minibuffer "Wikipedia article: "))
(insert "")
(save-excursion
(insert ref " ") ) )
(defun insert-mailref ()
(interactive)
(insert " ")
(backward-char 6) )
(defun convert-mailref ()
(interactive)
(replace-regexp "\\([^<]+\\)<\\([^>]+\\)>" "\\1 ") )
;; the following functions insert pairs of tags, correctly indented,
;; with an empty line (also correctly indented) between them.
(defun insertpair (tag)
(interactive)
(insert "
")
(indent-for-tab-command)
(insert "<" tag ">
")
(indent-for-tab-command)
(save-excursion
;; It would be nice to put this on a marked part of the text, but
;; in practice it's too confusing
;; (if (and (mark) (> (mark) (point)))
;; (goto-char (mark)) )
;; this is more complicated than it looks. We need to indent
;; *after* inserting the tag, because the indentation will then be
;; different.
(insert "
")
(insert "" tag ">
")
(previous-line)
(indent-for-tab-command) ) )
(defun insert-paragraph ()
(interactive)
(insertpair "p") )
(defun tagpair ()
(interactive)
(let ((mycol (current-column))
(tag (read-from-minibuffer "Tag name: ")) )
(insertpair tag ) ) )
(defun atag ()
(interactive)
(let ((tag (read-from-minibuffer "Tag name: ")))
(indent-for-tab-command)
(insert "
") ) )
(defun set-pre ()
(interactive)
(insertpair "pre") )
(defun html-set-literaltext ()
(interactive)
(insert">> */ ?>
")) )
(defun html-inphp ()
(interactive)
(indent-for-tab-command)
(insert "
") ) )
(defun nofilltext ()
(interactive)
(indent-for-tab-command)
(insert "
") ) )
;; Insert a photo on this page.
(defun html-insert-onephoto ()
(interactive)
(insert "
") ) )
;; Create a new page with just this one photo
(defun html-insert-onephotopage ()
(interactive)
(insert "
") ) )
(defun html-insert-diaryref ()
(interactive)
(insert "
") ) )
(defun html-insert-diarytag ()
(interactive)
(insert "
") ) )
(defun strip-photo-URL ()
"Change a link or image location of an image into a showphoto() invocation of that photo"
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp
"^[ ]*http:.*&dirdate=\\([0-9]+\\).*&image=\\([^#?]*\\).*"
" ") ) )
; SGML stuff
(defun sgml-fill-mode ()
(interactive)
(sgml-mode)
(auto-fill-mode nil)
(flyspell-mode nil)
(local-set-key '[f1] 'sgml-emphasis)
(local-set-key '[S-f1] 'sgml-filename)
(local-set-key '[C-f1] 'sgml-devicename)
(local-set-key '[M-f1] 'sgml-hostid)
(local-set-key '[C-S-f1] 'sgml-application)
(local-set-key '[f2] 'tagpair)
(local-set-key '[M-f2] 'sgml-insert-paragraph)
(local-set-key '[C-f2] 'sgml-sect1)
(local-set-key '[S-f2] 'sgml-sect)
(local-set-key '[C-f3] 'sgml-command)
(local-set-key '[S-f3] 'sgml-citerefentry)
(local-set-key '[M-f3] 'sgml-option)
(local-set-key '[S-f4] 'sgml-informalexample)
(local-set-key '[M-f4] 'sgml-example)
(local-set-key '[f5] 'sgml-markup-for-revision)
(local-set-key '[S-f5] 'offset-sgml-markup-for-revision)
(local-set-key '[f6] 'sgml-link)
(local-set-key '[C-f6] 'sgml-xref)
(local-set-key '[S-f6] 'sgml-anchor)
(local-set-key '[M-f6] 'sgml-ulink)
(local-set-key '[f8] 'sgml-screen)
(local-set-key '[C-f8] 'sgml-table-skel)
(local-set-key '[S-f8] 'sgml-table-row)
(local-set-key '[M-f8] 'sgml-table-entry)
(local-set-key '[M-S-f8] 'sgml-informaltable)
(local-set-key '[f9] 'sgml-literal)
(local-set-key '[M-f9] 'sgml-userinput)
(local-set-key '[C-f9] 'sgml-replaceable)
(local-set-key '[M-S-f9] 'sgml-programlisting)
(local-set-key '[f10] 'sgml-listitem)
(local-set-key '[C-f10] 'sgml-variablelist)
(local-set-key '[S-f10] 'sgml-varlistentry)
(local-set-key '[M-f10] 'sgml-itemizedlist)
(local-set-key '[M-S-f10] 'sgml-orderedlist)
(set-fill-column 80) )
(defun sgml-application nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-citerefentry nil
(interactive)
(insert "
*
")
(search-backward "<" nil t 4) )
(defun sgml-command nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-option nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-emphasis nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-filename nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-devicename nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-hostid nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-literal nil
(interactive)
(insert " ")
(search-backward "<" nil t) )
(defun sgml-sect1 nil
(interactive)
(insert "
")
(search-backward "
")
(search-backward "")
(search-backward "<" nil t) )
(defun sgml-anchor nil
(interactive)
(insert " ")
(search-backward "\"" nil t) )
(defun sgml-xref nil
(interactive)
(insert " ")
(search-backward "\"" nil t) )
(defun sgml-link nil
(interactive)
(insert " ")
(search-backward "\"" nil t) )
(defun sgml-ulink nil
(interactive)
(insert " ")
(search-backward "\"" nil t) )
(defun sgml-userinput ()
(interactive)
(insert " ")
(backward-char 12) )
(defun sgml-markup-for-revision ()
(interactive)
(insert " ")
(backward-char 7) )
(defun offset-sgml-markup-for-revision ()
(interactive)
(insert "
")
(backward-char 12) )
(defun sgml-insert-paragraph ()
(interactive)
(insert "
")
(backward-char 8) )
(defun sgml-informalexample ()
(interactive)
(insert "
")
(backward-char 19) )
(defun sgml-example ()
(interactive)
(insert "
")
(backward-char 11) )
(defun sgml-listitem nil
(interactive)
(insert "
")
(backward-char 21) )
(defun sgml-varlistentry nil
(interactive)
(insert "
")
(search-backward "
")
(backward-char 17) )
(defun sgml-variablelist nil
(interactive)
(insert "
")
(search-backward "
<" nil t) )
(defun sgml-orderedlist nil
(interactive)
(insert "
")
(backward-char 16) )
(defun sgml-programlisting nil
(interactive)
(insert "
")
(backward-char 19) )
(defun sgml-screen nil
(interactive)
(insert "
")
(backward-char 11) )
(defun sgml-table-skel ()
(interactive)
(insert "
")
(save-excursion
(insert "
XXX Header
XXX Header
XXX
") ) )
(defun sgml-informaltable nil
(interactive)
(insert "
")
(forward-line -3) )
(defun sgml-table-row nil
(interactive)
(insert "
")
(forward-line -1) )
(defun sgml-table-entry nil
(interactive)
(insert "
")
(forward-line -1) )
(defun sgml-programlisting nil
(interactive)
(insert "
")
(backward-char 19) )
; calendar stuff
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(browse-url-netscape-arguments nil)
'(browse-url-netscape-program "firefox")
'(calendar-week-start-day 1)
'(confirm-kill-emacs (quote yes-or-no-p))
'(erc-auto-query (quote frame))
'(erc-auto-set-away nil)
'(erc-autojoin-channels-alist (quote (("irc.lerdorf.com" "#ozlabs") ("irc.oz.org" "#bugs"))))
'(erc-away-nickname "groggy|away")
'(erc-beep-p t)
'(erc-email-userid "grog@lemis.com")
'(erc-format-query-as-channel-p nil)
'(erc-frame-dedicated-flag nil)
'(erc-interpret-mirc-color t)
'(erc-join-buffer (quote frame))
'(erc-minibuffer-notice t)
'(erc-mode-line-format "%n %m on %s %a %o")
'(erc-modules (quote (autoaway autojoin bbdb button fill irccontrols log match netsplit noncommands pcomplete readonly ring scrolltobottom stamp track)))
'(erc-nick (quote ("grOogle" "groOgle" "groggly" "gurgle" "groggy" "grog")))
'(erc-nick-uniquifier "|grOogle")
'(erc-prompt-for-channel-key t)
'(erc-public-away-p t)
'(erc-reuse-buffers nil)
'(erc-server "irc.oz.org")
'(erc-user-full-name "Greg Lehey")
'(erc-whowas-on-nosuchnick t)
'(mark-holidays-in-calendar t)
'(safe-local-variable-values (quote ((case-fold-search . t))))
'(tab-stop-list (quote (16 32 48 64 80 96 112 128)))
'(vc-rcs-diff-switches (quote ("-wu"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(erc-current-nick-face ((t (:foreground "green4" :weight bold))))
'(erc-keyword-face ((t (:foreground "green3" :weight bold))))
'(erc-pal-face ((t (:foreground "magenta3" :weight bold))))
'(erc-timestamp-face ((t (:foreground "dark green" :weight bold))))
'(fg:erc-color-face0 ((t (:foreground "black"))))
'(fg:erc-color-face10 ((t (:foreground "dark blue"))))
'(fg:erc-color-face11 ((t (:foreground "darkcyan"))))
'(fg:erc-color-face15 ((t (:foreground "black"))))
'(fg:erc-color-face8 ((t (:foreground "brown"))))
'(fg:erc-color-face9 ((t (:foreground "darkgreen")))))
(defun makemail ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "Copied By:.*
*SENT: \\(.*\\)$" "
From Transfer \\1
Date: \\1" nil)
(beginning-of-buffer)
; *Sent: *\\([0-9]+\\) *\\([A-z]*\\) *\\([0-9]*\\) *\\(.*\\)$" "
(replace-regexp "Printed by: .*
Sent: *\\([^ ]*\\) *\\([^ ]*\\) *\\([^ ]*\\) *\\(.*\\)" "
From Transfer Sun \\2 \\1 \\4 19\\3
Date: \\2 \\1 \\4 19\\3" nil)
(beginning-of-buffer)
(replace-regexp "\\(^Date.*
\\) *FROM:" "\\1From:" nil)
(beginning-of-buffer)
(replace-regexp "^\\(From: .*
\\) *TO:" "\\1To:" nil)
(beginning-of-buffer)
(replace-regexp "^\\(To: .*
\\) *CC." "\\1Cc:" nil)
(beginning-of-buffer)
(replace-regexp "^\\(To: .*
\\) *Cc." "\\1Cc:" nil)
(beginning-of-buffer)
(replace-regexp "^\\(To: .*
\\) *SUBJECT:" "\\1Subject:" nil)
(beginning-of-buffer)
(replace-regexp "^\\(Cc: .*
\\) *SUBJECT:" "\\1Subject:" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(01\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Jan \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(02\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Feb \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(03\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Mar \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(04\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Apr \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(05\\)-\\(..\\) *\\(.*\\)" "\\1 Sun May \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(06\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Jun \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(07\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Jul \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(08\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Aug \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(09\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Sep \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(10\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Oct \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(11\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Nov \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "\\(From Transfer\\) *\\(..\\)-\\(12\\)-\\(..\\) *\\(.*\\)" "\\1 Sun Dec \\4 \\5 19\\2" nil)
(beginning-of-buffer)
(replace-regexp "
\\(From Transfer\\)" "
\\1" nil)
(beginning-of-buffer)
(replace-regexp "^MSG \\(.*\\) *FROM: *\\([^ ]*\\) [^0-9]*\\([0-9][^ ]*\\) *\\(.*\\) \\(.*\\), \\(.*\\)
.*
*TO: *\\\\*\\(.*\\)
*SUBJECT: *\\(.*\\)" "
From tandem Sun \\4 \\3 \\6 \\5
From: \\2
To: \\7
Subject: \\8
Date: \\4 \\3 \\6 \\5
Message-Id: \\1
" nil)
(beginning-of-buffer)
(delete-char 1) ))
(defun mkhtml ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "^\\.H\\([0-9]\\) \"\\(.*\\)\"" "\\2 " nil)
(beginning-of-buffer)
(replace-regexp "^\\.\\\\\" \\(.*\\)" "" nil)
(beginning-of-buffer)
(replace-regexp "nroff-fill" "html-fill" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Addr" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Date[GY]* \"\\(.*\\)\"" "
\\1
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.sp.*$" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Ls.*$" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.LI" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Le" " " nil)
(beginning-of-buffer)
(replace-regexp "\\\\fI\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\f(BI\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\f(CB\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\f(CW\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\[/|]" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.P$" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.br" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.X .*
" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Pn .*
" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.De" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.D[sx]" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.URL +\\([^
]+\\) *" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\(em" "--" nil)
(beginning-of-buffer)
(replace-regexp "^\\.PSPIC +\"\\(.*\\)\"$" " " nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\.Indent" "
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\.End-indent" "
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\.Aside" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\.End-aside" " " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\.Command \\([^
*]+\\) *" "\\1 " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\.Daemon \\([^
*]+\\) *" "\\1 " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\.File \\([^
*]+\\) *" "\\1 " nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\.H\\([0-9]\\) +\\(.*\\)" "\\2 " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\[lq\\]" "“" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\[rq\\]" "”" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\f\\[CW\\]\\(.*\\)\\\\f[PR]" "\\1 " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\[em\\]" "—" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\f\\[BI\\]\\(.*\\)\\\\f[PR]" "\\1 "
nil nil nil)
) )
(defun mksgml ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "\\.Chapter .*\\[\\([^]]+\\).*\"\\(.*\\)\"" "
\\2
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.H\\([0-9]\\) \"\\(.*\\)\"" "
\\2 " nil)
(beginning-of-buffer)
(replace-regexp "^\\.\\\\\" *\\(.*\\)" "" nil)
(beginning-of-buffer)
(replace-regexp "\\\\\\*\\[\\([^]]*\\)\\]" "" nil)
(beginning-of-buffer)
(beginning-of-buffer)
(replace-regexp "nroff-fill" "sgml-fill" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Addr" "
" nil)
(beginning-of-buffer)
;; XXX
(replace-regexp "^\\.Date[GY]* \"\\(.*\\)\"" "
\\1
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.sp.*$" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Ls.*$" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.LI" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Le" "
" nil)
(beginning-of-buffer)
(replace-regexp "\\\\fI\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\f(CB\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\f(CW\\([^\\]*\\)\\\\f[PR]" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\\\[|/]" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.P$" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.br" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.X .*
" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.Pn \\(.*\\)" "" nil)
(beginning-of-buffer)
(replace-regexp "^\\.De" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.D[sx]" "
" nil)
(beginning-of-buffer)
(replace-regexp "^\\.URL +\\([^
]+\\) *" "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "#T{
\\([^}]+\\)
T}" "
\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\(/[^<]+\\) " "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\) " "\\1 " nil)
(beginning-of-buffer)
(replace-regexp "\\.FS" "" nil)
(beginning-of-buffer)
(replace-regexp "\\.FE" " " nil)
(beginning-of-buffer)
(replace-regexp "\\\\(em" "—" nil) ) )
;;;; XXX finish me
(setq html-to-roff-chars
'(("“" . "\\\\[lq]")
("”" . "\\\\[rq]")
("—" . "\\\\[em]")
("–" . "\\\\[en]")
(" " . " ")
("™" . "\\[tm]")
("&" . "&")
("–" . "\\\\[hy]")
("‘" . "\\\\[oq]")
("’" . "\\\\[cq]")
("“" . "\\\\[lq]")
("”" . "\\\\[rq]")
("…" . "...")
("″" . "\\\\[rq]") ; XXX ?
(" *— *" . "\\\\[em]")
("<" . "<")
(">" . ">") ) )
(defun html-to-roff ()
(interactive)
"Convert HTML to some semblance of *roff"
(save-excursion
(beginning-of-buffer)
(insert ".\\\" -*- nroff-fill -*-
.\\\" $Id: .emacs,v 1.92 2008/11/09 00:52:10 grog Exp grog $
")
(nroff-fill-mode)
(replace-regexp "" ".LI
" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\([^>]+\\) " "\\\\fI\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\([^>]+\\)" "\\\\f(CW\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "" "
T}" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "]*>" "
T{
" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "" ".Dx" nil nil nil)
;;;; images
(beginning-of-buffer)
(query-replace-regexp "alt=\"[^\"]+\"" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp " " "
.PIC \\1
" nil nil nil)
;;;; replace URIs
(beginning-of-buffer)
(query-replace-regexp "\\([^<]+\\) \\([^
]*\\)" "\\2
.URI ( \\1 )\\3
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "
*
*" "
.P
" nil)
(beginning-of-buffer)
(replace-regexp "<[hH]3>\\(.*\\)[Hh]3>" ".H3 \"\\1\"" nil nil nil)
(beginning-of-buffer)
(replace-regexp "
*
*" ".Le
" nil)
(beginning-of-buffer)
(replace-regexp "
*
*" "
" nil)
(beginning-of-buffer)
(replace-regexp "" "\\\\fB" nil)
(beginning-of-buffer)
(replace-regexp "
*
*" "
.Ls
" nil)
(beginning-of-buffer)
(replace-regexp "
*
*" "
.Le
" nil)
(beginning-of-buffer)
(replace-regexp "
*
*" "
.br
" nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]*\\) " "\\\\fI\\1\\\\fP\\\\[|/]" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]*\\) " "\\\\fB\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]*\\) " "\\\\f[CW]\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" "" nil)
(beginning-of-buffer)
(replace-regexp "]*>\\(.*\\)$" ".H\\1 \"\\2\"" nil)
(beginning-of-buffer)
(replace-regexp "]+>" ".TS
center,tab(#) ;
lw10 | lw10 | lw6 | lw6 | lw6 | lw6 | lw6 | lw6 | lw6 | lw6 | lw6 ." nil nil nil)
(beginning-of-buffer)
(replace-regexp "" ".ce
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "
]*>" ".TE
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "*tr>" "
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" ".Dx" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " ".De" nil nil nil)
(beginning-of-buffer)
(replace-regexp "[ ]+$" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^
" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " ".ps 3i" nil nil nil)
(beginning-of-buffer)
(replace-regexp ".jpeg\">" ".ps 3i" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\\\fB" "\\\\f[CB]" nil nil nil)
(beginning-of-buffer)
(while (search-forward "ä" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "Ä" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "ö" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "Ö" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "ü" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "Ü" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(while (search-forward "ß" nil t)
(replace-match "" nil t))
(beginning-of-buffer)
(replace-regexp " " "\\\\fP" nil nil nil)
(beginning-of-buffer)
(replace-regexp "[bit]*>" "\\\\fP" nil nil nil)
(beginning-of-buffer)
(replace-regexp " ]*>" "T{
" nil nil nil)
(beginning-of-buffer)
(replace-regexp " ]*>" "
T}" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\(.*\\) " ".Chapter 0 \\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp "?body>" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "]*>\\(.*\\) " "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp "]*>\\(.*\\) " "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]*\\) " "\\\\fI\\1\\\\fP" nil nil nil)
;; later: others can be encapsulated inside
(beginning-of-buffer)
(replace-regexp "]*>\\([^<]*\\) " "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" "
.Ds
" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " ".br
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\)\\([^
]+\\) *" "
.Command \\1 \\2
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\) *" "
.Command \\1
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\) \\([^
]+\\) *" "
.Command \\1 \\2
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\) *" "
.Command \\1
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^<]+\\) *" "\\\\fI\\1\\\\fP" nil nil nil)
;; last
(beginning-of-buffer)
(replace-regexp "^[ ]*
" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^[ ]+" "" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" "
.blockquote
" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " "
./blockquote
" nil nil nil)
(beginning-of-buffer)
(replace-regexp "" "\\\\fI" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " "\\\\fP" nil nil nil)
;;;; Table stuff
(beginning-of-buffer)
(query-replace-regexp "]*>\\(.*\\) " "\\1#" nil nil nil)
(beginning-of-buffer)
;;;; Remove excessive .P lines.
(beginning-of-buffer)
(query-replace-regexp "\\.P
\\.H" ".H" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\(^\\.H[0-9] .*\\)
\\.P
" "\\1
" nil nil nil)
(beginning-of-buffer)
;;; fix characters
(let ((charlist html-to-roff-chars))
(while charlist
(beginning-of-buffer)
(eval (list 'query-replace-regexp (caar charlist) (cdar charlist) nil nil nil))
(setq charlist (cdr charlist)) ) )
))
; Split aggregated mail files
; Fire this off with:
;
; for i in B* C*; do echo $i; emacs -batch $i -l fixmail.el -f fixmail -f save-buffer -f save-buffers-kill-emacs; done
; after that, run makemail (in .emacs)
(defun fixmail ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "Copied By: LEHEY.*
.*
.*
.*CONTENTS OF FOLDER \\([^ ]+\\).*
" "EOF
cat >extracts/\\1 <<\\\\EOF" nil)
(beginning-of-buffer)
(replace-string " " "" nil)
(beginning-of-buffer)
(kill-line)
(kill-line)
(end-of-buffer)
(insert "EOF") ) )
; (load "/usr/local/share/emacs/dismal-1.4/dismal-mode-defaults.el")
; (load "~/emacs/irc-alf-msa17.el")
; For tidying up broken html files.
(defun tidy-html ()
(interactive)
(save-excursion
(beginning-of-buffer)
(insert "
")
(replace-regexp "\.htm\b" ".html" nil)
(beginning-of-buffer)
; put an empty line before each < at the beginning of the line
(replace-regexp "\\([^
]\\)
<" "\\1
<" nil)
(beginning-of-buffer)
(while (< (point) (point-max))
(forward-paragraph)
(fill-paragraph nil) )
(save-buffer) )
)
(defun align-beginning-of-defun ()
(interactive)
(beginning-of-defun)
(recenter) )
(defun align-end-of-defun ()
(interactive)
(end-of-defun)
(recenter) )
;; Tricks
;; Add name tag to diary
;; (query-replace-regexp "\\(.*, \\)\\([0-9]+\\)\\( .*$\\)" "\\1\\2\\3 " nil nil nil)
;; (add-hook 'vc-log-mode-hook
;; '(lambda()
;; (if (= (buffer-size) 0) (insert "
;; PR:
;; Approved by:
;; Reviewed by:
;; MFC after:
;; " )) ) )
(defun tex-fill-mode ()
(interactive)
(tex-mode)
(auto-fill-mode nil)
(flyspell-mode nil)
(setq indent-tabs-mode nil) ; tab with spaces.
(local-set-key '[M-f1] 'set-tex-bi)
;; (local-set-key '[C-f1] 'set-tex-icw)
(local-set-key '[f1] 'set-tex-i)
(local-set-key '[f2] 'tex-tagpair)
;; (local-set-key (quote [M-f2]) (quote move-indices))
;; (local-set-key (quote [M-f4]) (quote transpose-index-rotated-around-comma))
;; (local-set-key '[M-f5] 'insert-tbl-skeleton)
;; (local-set-key '[S-f5] 'insert-page-ref)
;; (local-set-key '[f6] 'add-nroff-index)
;; (local-set-key '[C-f6] 'add-nroff-index-cw)
;; (local-set-key '[M-f6] 'add-nroff-indices)
;; (local-set-key '[M-f7] 'insert-tl-skeleton)
;; (local-set-key '[S-f8] 'insert-tbl-braces)
;; (local-set-key '[f8] 'insert-sreg-quote)
;; (local-set-key '[C-f8] 'insert-sref-quote)
;; (local-set-key '[C-f7] 'insert-naked-sref-quote)
(local-set-key '[M-f9] 'set-tex-cb)
(local-set-key '[S-f9] 'set-tex-b)
(local-set-key '[f9] 'set-tex-cw)
(local-set-key '[f11] 'beep)
(local-set-key '[f10] 'fill-paragraph)
;; (local-set-key '[M-f10] 'insert-reply-comment)
;; (local-set-key '[f12] 'insert-tl-skeleton)
(set-fill-column 80) )
(defun set-tex-cw ()
(interactive)
(insert "{\\tt }")
(backward-char 1) )
;; constant bold is what? XXX
(defun set-tex-cb ()
(interactive)
(insert "{\\tt }")
(backward-char 1) )
(defun set-tex-b ()
(interactive)
(insert "{\\bf }")
(backward-char 1) )
(defun set-tex-i ()
(interactive)
(insert "{\\em }")
(backward-char 1) )
(defun set-tex-bi ()
(interactive)
(insert "{\\bf }")
(backward-char 1) )
(defun tex-tagpair ()
(interactive)
(let ((tag (read-from-minibuffer "Tag name: ")))
(insert "\\begin{" tag "}
")
(save-excursion
(insert "
\\end{" tag "}
") ) ) )
(defun gloss ()
(interactive)
(query-replace-regexp "\\([A-za-z0-9]+\\)" "\\1 " nil))
;; initial value
(setq diary-header-day "")
(defun diary-header ()
(interactive)
(setq diary-header-day (read-from-minibuffer "Day: "))
(insert "
")
(save-excursion
(insert "
") ) )
;;;; Macros to update diary entries.
;;; Add a name to each day in the buffer.
(defun add-day-tag ()
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "\\([^<][^,
]+\\), *\\([0-9]+\\)\\([^<]+\\)" "\\1, \\2\\3 " nil nil nil) ) )
;;; Add links to photos for each day in the buffer.
;;; Writeme!
(defun add-days-photos ()
(interactive)
(save-excursion
))
(defun add-long-day-tag ()
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "h2>\\([A-z]+, \\)\\([0-9]+\\) \\([A-z]+\\) \\([0-9]+\\)" "h2>\\1\\2 \\3 \\4 " nil nil nil) ) )
(defun correct-day-tag ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "\\(]+>\\)" "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " " " nil nil nil) ) )
;; take a list
;; quantity ingredient step
;; and make a table entry out of it.
;; note double spaces between items.
(defun mkrecipe ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp " +" " " nil nil nil)
(beginning-of-buffer)
(replace-regexp "^$" " " nil nil nil)
(beginning-of-buffer)
(replace-regexp "\\([^>]\\)$" "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\([^<]\\)" "\\1" nil nil nil)
(beginning-of-buffer)
(replace-regexp " " " " nil nil nil) ) )
(defun make-2-tab ()
(interactive)
"Turn lines with two columns separated by tabs into an HTML table"
(query-replace-regexp "^ *\\([^ ]+\\)[ ]+\\([^
]+\\)" " \\1 \\2 " nil nil nil) )
(defun make-3-tab ()
(interactive)
"Turn lines with three columns separated by tabs into an HTML table"
(query-replace-regexp "^ *\\([^ ]+\\)[ ]+\\([^ ]+\\)[ ]+\\([^
]+\\)" "\\1 \\2 \\3 " nil nil nil) )
;; This one for ingredients tables
;; XXX not finished. Limit to region, ensure that we start in the right place.
(defun make-ingredients-tab ()
(interactive)
"Turn lines in region with three columns separated by tabs into an HTML table with spacing columns"
(save-excursion
(query-replace-regexp " +" " " nil nil nil)
(query-replace-regexp "^\\(.*\\) \\(.*\\) \\(.*\\)"
"\\1 \\2 \\3 "
nil
nil
nil) ) )
(defun make-4-tab ()
(interactive)
"Turn lines with four columns separated by tabs into an HTML table"
(query-replace-regexp "^ *\\([^ ]+\\)[ ]+\\([^ ]+\\)[ ]+\\([^ ]+\\)[ ]+\\([^
]+\\)" "\\1 \\2 \\3 \\4 " nil nil nil) )
;; Tidy up file with HTML tidy. This has the problem that it doesn't
;; understand PHP at all well.
(defun html-realtidy ()
(interactive)
(save-buffer)
(save-excursion
;;;; First do the normal tidy-ups
(html-tidy)
(shell-command (concat "tidy -m -asxhtml " (buffer-file-name) " > /dev/null"))
(silently-revert-buffer)
(untabify 0 (point-max))
(beginning-of-buffer)
;;;; on its own line, correctly indented.
(replace-regexp "^\\([ ]*\\)
\\([^
]\\)" "\\1
\\1\\2" nil nil nil)
(beginning-of-buffer)
;;;;
on its own line, correctly indented.
(replace-regexp "^\\([ ]*\\)\\([^
]+\\)
" "\\1\\2
\\1
" nil nil nil)
;;;;
;;;; clean up spurious spacing
(beginning-of-buffer)
(query-replace-regexp " *
" "")
(beginning-of-buffer)
(query-replace-regexp "
" "")
;; multiple passes to fix showphoto
(beginning-of-buffer)
(query-replace-regexp "showphoto[ ]*
[ ]*" "showphoto ")
(beginning-of-buffer)
(query-replace-regexp "^\\([ ]+\\)\\([^
].*\\) \\(<\\?php showphoto\\)" "\\1\\2
\\1\\3")
(beginning-of-buffer)
(replace-regexp "[ ]*
[ ]*
[ ]*
" "")
(beginning-of-buffer)
(replace-regexp "
\\(
[ ]*\\) indent
(beginning-of-buffer)
(replace-regexp "^ * *
" "" nil nil nil)
;;;; remove HTML tidy line
(beginning-of-buffer)
(replace-regexp "^ .*generator.*HTML Tidy.*
" "" nil nil nil)
;;;; indent
(beginning-of-buffer)
(replace-regexp "^\\([ ]* on its own line, correctly indented.
(beginning-of-buffer)
(replace-regexp "^\\([ ]*\\)\\([^
]\\)" "\\1
\\1\\2" nil nil nil)
;; on its own line, correctly indented.
(beginning-of-buffer)
(replace-regexp "^\\([ ]*\\)\\(.+\\) *$" "\\1\\2
\\1" nil nil nil)
) )
;; Tidy up file without HTML tidy.
(defun html-tidy ()
(interactive)
(save-buffer)
(save-excursion
(untabify 0 (point-max))
(beginning-of-buffer)
;;;; Add magic for Emacs at start if not already there
(if (not (looking-at "
") )
;;;; make sure we don't fold the AUUGid line
(if (search-forward "$AUUGid" nil t)
(progn
(end-of-line)
(if (not (looking-at ";"))
(progn (delete-char 1)
(insert " ") ) ) ) )
;;;; gdb prompt
(beginning-of-buffer)
(replace-regexp "=== gdb ->" "=== gdb ->" nil nil nil)
(beginning-of-buffer)
(replace-regexp "=== gdb -> \\([^<].*\\)" "=== gdb -> \\1 " nil nil nil)
;;;; bash prompt
(beginning-of-buffer)
(replace-regexp "^ *\\(^=== .* -\\)>" "\\1>" nil nil nil)
(beginning-of-buffer)
(replace-regexp "^\\(===.*)\\) \\([^ ]+\\) \\([0-9]+\\) -> *\\(.*\\)"
"\\1 \\2 \\3 -> \\4 " nil nil nil)
;;;; second space after .
(beginning-of-buffer)
(replace-regexp "\\. \\([^
]\\)" ". \\1" nil nil nil)
(beginning-of-buffer)
;; Don't break $Id strings.
(replace-regexp "\\(\\$Id[^$]+\\)
[ ]+" "\\1 " nil nil nil) ) )
(defun html-2-rssxml ()
(interactive)
;;;; change the date to a header
(save-excursion
(beginning-of-buffer)
;; Replace the comment at the beginning of the entry with an item header.
;; regexp:
;; \1: First three letters of weekday
;; \2: rest of weekday, space
;; \3: day of month
;; \4: First three letters of month
;; \5: Rest of month, space
;; \6: Year
(replace-regexp " *"
"-
http://www.lemis.com/grog/diary-\\4\\6.html#\\3
http://www.lemis.com/grog/diary-\\4\\6.html#\\3
\\1\\2\\3 \\4\\5\\6
\\1, \\3 \\4 \\6 00:01:02 +0000
" nil nil nil)
(search-backward "diary-" nil t 2)
(downcase-word 2)
(search-forward "diary-" nil t 1)
(downcase-word 2)
(absolutize-links)
(end-of-buffer)
(insert "
]]>
")))
;; go through a buffer and replace links relative to
;; http://www.lemis.com/grog/ with absolute links. Also handles links
;; starting with /.
(defun absolutize-links ()
(interactive)
(beginning-of-buffer)
(while (re-search-forward "href=\"\\|src=\"" nil t)
(cond ((looking-at "/")
(insert "http://www.lemis.com"))
((not (looking-at "http:"))
(insert "http://www.lemis.com/grog/") ) ) ) )
(defun xml-fill-mode ()
(interactive)
(nxml-mode)
(auto-fill-mode nil)
(flyspell-mode nil)
(local-set-key "" 'clear-trailing-junk-and-save)
(local-set-key '[C-.] 'expand-sentence-end)
(local-set-key '[67108910] 'expand-sentence-end)
(local-set-key '[M-f1] 'html-set-bi)
(local-set-key '[C-f1] 'html-set-icw) ;comment in .Ps
(local-set-key '[f1] 'html-set-i)
(local-set-key '[f2] 'tagpair)
(local-set-key '[M-f2] 'insert-paragraph)
(local-set-key '[C-f2] 'diary-header)
(local-set-key '[S-f2] 'italic-blockquote)
(local-set-key '[M-S-p] 'insert-paragraph)
(local-set-key '[f5] 'indent-next-line)
(local-set-key '[c-f5] 'html-markup-for-revision)
(local-set-key '[S-f5] 'offset-html-markup-for-revision)
(local-set-key '[M-f5] 'highlight-html-markup-for-revision)
(local-set-key '[f6] 'insert-href)
(local-set-key '[C-f6] 'insert-mailref)
(local-set-key '[M-f6] 'convert-mailref)
(local-set-key '[M-S-f6] 'insert-wikipedia-href)
(local-set-key '[S-f6] 'insert-partial-href)
(local-set-key '[f8] 'set-pre)
(local-set-key '[C-f8] 'table-tag)
(local-set-key '[S-f8] 'tr-tag)
(local-set-key '[M-f8] 'td-tag)
(local-set-key '[M-f9] 'html-set-cb)
(local-set-key '[S-f9] 'html-set-b)
(local-set-key '[f9] 'html-set-cw)
(local-set-key '[M-f10] 'html-insert-onephoto)
(local-set-key '[S-f10] 'html-insert-diaryref)
(local-set-key '[C-f10] 'html-insert-diarytag)
(local-set-key (quote [67108909]) (lambda () (interactive) (insert "—"))) ;;C--
(local-set-key (quote [S-right]) (lambda () (interactive) (insert " –> "))) ;;S-->
;; the only way I can do a c-spc
(local-set-key (quote [67108896]) (lambda () (interactive) (insert " "))) ;;C-SPC
(local-set-key "\242" (lambda () (interactive) (insert "“"))) ;M-"
(local-set-key "\247" (lambda () (interactive) (insert "”"))) ;M-'
(local-set-key (quote [67108898]) (lambda () (interactive) (insert "\" "))) ;M-'
(local-set-key "\321" 'html-tidy)
(local-set-key "\221" 'html-realtidy)
(set-fill-column 100) )
(defun xml-tidy ()
(interactive)
(save-buffer)
(let ((pos))
(untabify 0 (point-max))
(shell-command (concat "tidy -m -xml " (buffer-file-name) " > /dev/null"))
(setq pos (point))
(silently-revert-buffer)
(untabify 0 (point-max))
(retidy-xml)
(goto-char pos)
) )
;; tidy up after xml tidy
;; this is a cut-down version of retidy-html, now deceased
(defun retidy-xml ()
(interactive)
(save-excursion
(beginning-of-buffer)
(if (not (looking-at "
") )
;; on its own line, correctly indented.
(replace-regexp "^\\([ ]*\\)
\\([^
]\\)" "\\1
\\1\\2" nil nil nil)
(beginning-of-buffer)
;;
on its own line, correctly indented.
(replace-regexp "^\\([ ]*\\)\\([^
]+\\)" "\\1\\2
\\1" nil nil nil)
;; Don't break $Id strings.
(replace-regexp "\\(\\$Id[^$]+\\)
[ ]+" "\\1 " nil nil nil)
;;;; second space after .
(beginning-of-buffer)
(replace-regexp "\\. \\([^
]\\)" ". \\1" nil nil nil)
) )
;; Convert LaTeX to roff (first approximation; FIXME)
(defun tex-to-roff ()
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "^[ ]+" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\begin{itemize}" ".Ls B" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\end{itemize}" ".Le" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\item" ".LI" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "{\\\\em +\\([^}]+\\)}" "\\\\fI\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\section\\**{\\([^}]+\\)}" ".H2 \"\\1\"" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\subsection\\**{\\([^}]+\\)}" ".H3 \"\\1\"" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\begin{enumerate}" ".Ls" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\end{enumerate}" ".Le" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\begin{quote}" ".blockquote" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\end{quote}" "./blockquote" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\noindent" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\scalebox{.55}{\\\\includegraphics{\\([^}]+\\)}}" ".XPSPIC \\1" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\begin{verbatim}" ".Ds" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\end{verbatim}" ".De" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "{\\\\tt +\\([^}]+\\)}" "\\\\f[CW]\\1\\\\fP" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "
+\\." "
." nil nil nil)
(query-replace-regexp "^\\(\\..*
\\)
+" "\\1" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "
+" "
.P
" nil nil nil)
"\begin{tabular}{l r }
Directory & Number of executables \\
\\
\fI/bin\fP & 40 \\
\fI/usr/bin\fP & 406 \\
\fI/sbin\fP & 104 \\
\fI/usr/sbin\fP & 229 \\
\fI/usr/local/bin\fP & 630 \\
\fI/usr/local/sbin\fP & 35 \\
\fI/usr/X11R6/bin\fP & 353 \\
\\
Total & 1797 \\
\end{tabular}"
(beginning-of-buffer)
(query-replace-regexp "[ ]+&[ ]+" "#" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp " *\\\\\\\\$" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\LaTeX\\\\*" "\\\\*[LaTeX]" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "\\\\TeX\\\\*" "\\\\*[TeX]" nil nil nil) ) )
(defun fixup-open-office-abortion ()
(interactive)
(save-excursion
(query-replace "``" "\342\200\234" nil nil nil)
(beginning-of-buffer)
(query-replace "--" "―" nil nil nil)
(beginning-of-buffer)
(query-replace "''" "\342\200\235" nil nil nil)
(query-replace-regexp "\\\\chapter[[{]\\([^]}]+\\)[]}]" ".Chapter 0 \"\\1\"" nil nil nil)
(query-replace-regexp "\\.LI *\\([^
]\\)" ".LI
\\1" nil nil nil)
(query-replace-regexp "{\\\\bf *\\([^}]+\\)}" "\\\\fB\\1\\\\fP" nil nil nil)
(query-replace-regexp "^%" "#" nil nil nil)
(query-replace-regexp "\\\\%" "%" nil nil nil)
(query-replace-regexp "\\\\&" "&" nil nil nil)
(query-replace-regexp "\\\\cite{\\([^}]+\\)}" "[\\1]" nil nil nil)
(query-replace-regexp "\\\\bibitem{\\([^}]+\\)}" "\\\\fB\\1\\\\fP" nil nil nil)
) )
(defun convert-rosss-notes ()
(interactive)
(save-excursion
(beginning-of-buffer)
; convert headings
(query-replace-regexp "\\(.*\\)
--+" "\\1 " nil nil nil)
(beginning-of-buffer)
; convert items, all except last.
(query-replace-regexp "^\\* +\\([^*]+\\)" "\\1 " nil nil nil)
(beginning-of-buffer)
; convert last item, painfully
(query-replace-regexp "li>\\*" "li>" nil nil nil)
(beginning-of-buffer)
; end a list (two empty lines)
(query-replace-regexp "
" " " nil nil nil)
(beginning-of-buffer)
; start an ordered list
(query-replace-regexp "^ *1\\. +" "" nil nil nil)
(beginning-of-buffer)
; remainder of ordered list. We still need to identify the end.
(query-replace-regexp "^ *[0-9]\\. +" " " nil nil nil)
(beginning-of-buffer)
; first entry only of second level ul. Skip the remaining ones.
(query-replace-regexp "^ *- *" "" nil nil nil)
(beginning-of-buffer)
; second level ul. Need to surround it with something.
(query-replace-regexp "^ *- *" " " nil nil nil) ) )
(defun degrump ()
(interactive)
(query-replace-regexp "Name: *\\(.*\\)
Date: \\(.*\\)" "On \\2, \\1 wrote:" nil nil nil) )
(defun xml-to-roff ()
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "?office[^>]+>" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "?style[^>]+>" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "?text[^>]+>" "" nil nil nil)
(beginning-of-buffer)
(query-replace-regexp "'" "'" nil nil nil)
(html-to-roff)
))
;; Change headers into a client-access entry.
(defun refuse-spam ()
(interactive)
(save-excursion
(replace-regexp "^ +by .*
" "" nil nil nil) )
(save-excursion
(replace-regexp "^\\([^0-9#
]\\)" "# \\1" nil nil nil) )
(save-excursion
(replace-regexp "\\[\\([0-9]+\\.[0-9]+\\.[0-9]+\\)\\(.*
.*\\)$" "[\\1\\2
\\1 550 See http://www.lemis.com/dontspam.html. Please use your ISP's mail server." nil nil nil) ) )
(defun reverse-chars ()
(interactive)
(let ((result ""))
(save-excursion
(if (> (point) (mark))
(exchange-point-and-mark) )
(while (< (point) (mark))
(setq result (concat (char-to-string (char-after (point))) result))
(delete-char 1) )
(insert result) ) ) )
(defun reverse-words ()
(interactive)
(let ((result "")
(start (point)) )
(save-excursion
(if (> (point) (mark))
(progn
(exchange-point-and-mark)
(setq start (point)) ) )
(forward-word 1)
(backward-word 1)
(while (< (point) (mark))
(forward-word 1)
(setq result (concat (buffer-substring start (point)) result))
(delete-region start (point))
(setq start (point)) )
(insert result) ) ) )
(defun clear-trailing-junk-and-save ()
"Trim white space from the end of all lines, then save the file"
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "\\([^-][^-]\\)[ ]+$" "\\1" nil nil nil) )
(save-buffer) )
(defun insert-image-location ()
(interactive)
(message "Image location: ")
(setq sect (read-char))
(insert "
")
(search-backward "
" ) ) )
;; (require 'xcscope)
(defun wiki-to-roff ()
(interactive)
"Convert HTML to some semblance of *roff. Work in progress"
(save-excursion
(beginning-of-buffer)
;;;; constant width
(query-replace-regexp "\\^\\^\\([^^]+\\)\\^\\^" "\\\\f(CW\\1\\\\fP" nil nil nil)
;;;; bold italic
(query-replace-regexp "\\__''\\(.*\\)''__" "\\\\f(BI\\1\\\\fP" nil nil nil)
;;;; italic
(query-replace-regexp "''\\(.*\\)''" "\\\\fI\\1\\\\fP" nil nil nil)
))
; Stuff for converting UTF to Rofff
(defun utf-to-roff ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-string "\\u00D0" "\\[-D]") ; -D Eth
(beginning-of-buffer)
(replace-string "\\u00F0" "\\[Sd]") ; `'o eth
(beginning-of-buffer)
(replace-string "\\u00DE" "\\[TP]") ; Ib Thorn
(beginning-of-buffer)
(replace-string "\\u00FE" "\\[Tp]") ; pb thorn
(beginning-of-buffer)
(replace-string "\\u00DF" "\\[ss]") ; B germandbls
(beginning-of-buffer)
(replace-string "\\u0066_0066" "\\[ff]") ; ff ff
(beginning-of-buffer)
(replace-string "\\u0066_0069" "\\[fi]") ; fi fi
(beginning-of-buffer)
(replace-string "\\u0066_006C" "\\[fl]") ; fl fl
(beginning-of-buffer)
(replace-string "\\u0066_0066_0069" "\\[Fi]") ; ffi ffi
(beginning-of-buffer)
(replace-string "\\u0066_0066_006C" "\\[Fl]") ; ffl ffl
(beginning-of-buffer)
(replace-string "\\u0141" "\\[/L]") ; /L Lslash
(beginning-of-buffer)
(replace-string "\\u0142" "\\[/l]") ; /l lslash
(beginning-of-buffer)
(replace-string "\\u00D8" "\\[/O]") ; /O Oslash
(beginning-of-buffer)
(replace-string "\\u00F8" "\\[/o]") ; /o oslash
(beginning-of-buffer)
(replace-string "\\u00C6" "\\[AE]") ; AE AE
(beginning-of-buffer)
(replace-string "\\u00E6" "\\[ae]") ; ae ae
(beginning-of-buffer)
(replace-string "\\u0152" "\\[OE]") ; OE OE
(beginning-of-buffer)
(replace-string "\\u0153" "\\[oe]") ; oe oe
(beginning-of-buffer)
(replace-string "\\u0132" "\\[IJ]") ; IJ IJ
(beginning-of-buffer)
(replace-string "\\u0133" "\\[ij]") ; ij ij
(beginning-of-buffer)
(replace-string "\\u0131" "\\[.i]") ; i dotlessi
(beginning-of-buffer)
(replace-string "\---" "\\[.j]") ; (N/A) dotlessj
(beginning-of-buffer)
(replace-string "\\u0041_0301" "\\['A]") ; 'A Aacute
(beginning-of-buffer)
(replace-string "\\u0043_0301" "\\['C]") ; (N/A) Cacute
(beginning-of-buffer)
(replace-string "\\u0045_0301" "\\['E]") ; 'E Eacute
(beginning-of-buffer)
(replace-string "\\u0049_0301" "\\['I]") ; 'I Iacute
(beginning-of-buffer)
(replace-string "\\u004F_0301" "\\['O]") ; 'O Oacute
(beginning-of-buffer)
(replace-string "\\u0055_0301" "\\['U]") ; 'U Uacute
(beginning-of-buffer)
(replace-string "\\u0059_0301" "\\['Y]") ; 'Y Yacute
(beginning-of-buffer)
(replace-string "\\u0061_0301" "\\['a]") ; 'a aacute
(beginning-of-buffer)
(replace-string "\\u0063_0301" "\\['c]") ; (N/A) cacute
(beginning-of-buffer)
(replace-string "\\u0065_0301" "\\['e]") ; 'e eacute
(beginning-of-buffer)
(replace-string "\\u0069_0301" "\\['i]") ; 'i iacute
(beginning-of-buffer)
(replace-string "\\u006F_0301" "\\['o]") ; 'o oacute
(beginning-of-buffer)
(replace-string "\\u0075_0301" "\\['u]") ; 'u uacute
(beginning-of-buffer)
(replace-string "\\u0079_0301" "\\['y]") ; 'y yacute
(beginning-of-buffer)
(replace-string "\\u0041_0308" "\\[:A]") ; "A Adieresis
(beginning-of-buffer)
(replace-string "\\u0045_0308" "\\[:E]") ; "E Edieresis
(beginning-of-buffer)
(replace-string "\\u0049_0308" "\\[:I]") ; "I Idieresis
(beginning-of-buffer)
(replace-string "\\u004F_0308" "\\[:O]") ; "O Odieresis
(beginning-of-buffer)
(replace-string "\\u0055_0308" "\\[:U]") ; "U Udieresis
(beginning-of-buffer)
(replace-string "\\u0059_0308" "\\[:Y]") ; (N/A) Ydieresis
(beginning-of-buffer)
(replace-string "\\u0061_0308" "\\[:a]") ; "a adieresis
(beginning-of-buffer)
(replace-string "\\u0065_0308" "\\[:e]") ; "e edieresis
(beginning-of-buffer)
(replace-string "\\u0069_0308" "\\[:i]") ; "i idieresis
(beginning-of-buffer)
(replace-string "\\u006F_0308" "\\[:o]") ; "o odieresis
(beginning-of-buffer)
(replace-string "\\u0075_0308" "\\[:u]") ; "u udieresis
(beginning-of-buffer)
(replace-string "\\u0079_0308" "\\[:y]") ; "y ydieresis
(beginning-of-buffer)
(replace-string "\\u0041_0302" "\\[^A]") ; ^A Acircumflex
(beginning-of-buffer)
(replace-string "\\u0045_0302" "\\[^E]") ; ^E Ecircumflex
(beginning-of-buffer)
(replace-string "\\u0049_0302" "\\[^I]") ; ^I Icircumflex
(beginning-of-buffer)
(replace-string "\\u004F_0302" "\\[^O]") ; ^O Ocircumflex
(beginning-of-buffer)
(replace-string "\\u0055_0302" "\\[^U]") ; ^U Ucircumflex
(beginning-of-buffer)
(replace-string "\\u0061_0302" "\\[^a]") ; ^a acircumflex
(beginning-of-buffer)
(replace-string "\\u0065_0302" "\\[^e]") ; ^e ecircumflex
(beginning-of-buffer)
(replace-string "\\u0069_0302" "\\[^i]") ; ^i icircumflex
(beginning-of-buffer)
(replace-string "\\u006F_0302" "\\[^o]") ; ^o ocircumflex
(beginning-of-buffer)
(replace-string "\\u0075_0302" "\\[^u]") ; ^u ucircumflex
(beginning-of-buffer)
(replace-string "\\u0041_0300" "\\[`A]") ; `A Agrave
(beginning-of-buffer)
(replace-string "\\u0045_0300" "\\[`E]") ; `E Egrave
(beginning-of-buffer)
(replace-string "\\u0049_0300" "\\[`I]") ; `I Igrave
(beginning-of-buffer)
(replace-string "\\u004F_0300" "\\[`O]") ; `O Ograve
(beginning-of-buffer)
(replace-string "\\u0055_0300" "\\[`U]") ; `U Ugrave
(beginning-of-buffer)
(replace-string "\\u0061_0300" "\\[`a]") ; `a agrave
(beginning-of-buffer)
(replace-string "\\u0065_0300" "\\[`e]") ; `e egrave
(beginning-of-buffer)
(replace-string "\\u0069_0300" "\\[`i]") ; `i igrave
(beginning-of-buffer)
(replace-string "\\u006F_0300" "\\[`o]") ; `o ograve
(beginning-of-buffer)
(replace-string "\\u0075_0300" "\\[`u]") ; `u ugrave
(beginning-of-buffer)
(replace-string "\\u0041_0303" "\\[~A]") ; ~A Atilde
(beginning-of-buffer)
(replace-string "\\u004E_0303" "\\[~N]") ; ~N Ntilde
(beginning-of-buffer)
(replace-string "\\u004F_0303" "\\[~O]") ; ~O Otilde
(beginning-of-buffer)
(replace-string "\\u0061_0303" "\\[~a]") ; ~a atilde
(beginning-of-buffer)
(replace-string "\\u006E_0303" "\\[~n]") ; ~n ntilde
(beginning-of-buffer)
(replace-string "\\u006F_0303" "\\[~o]") ; ~o otilde
(beginning-of-buffer)
(replace-string "\\u0053_030C" "\\[vS]") ; (N/A) Scaron
(beginning-of-buffer)
(replace-string "\\u0073_030C" "\\[vs]") ; (N/A) scaron
(beginning-of-buffer)
(replace-string "\\u005A_030C" "\\[vZ]") ; (N/A) Zcaron
(beginning-of-buffer)
(replace-string "\\u007A_030C" "\\[vz]") ; (N/A) zcaron
(beginning-of-buffer)
(replace-string "\\u0043_0327" "\\[,C]") ; ,C Ccedilla
(beginning-of-buffer)
(replace-string "\\u0063_0327" "\\[,c]") ; ,c ccedilla
(beginning-of-buffer)
(replace-string "\\u0041_030A" "\\[oA]") ; oA Aring
(beginning-of-buffer)
(replace-string "\\u0061_030A" "\\[oa]") ; oa aring
(beginning-of-buffer)
(replace-string "\\u030B" "\\[a\"]") ; hungarumlaut
(beginning-of-buffer)
(replace-string "\\u0304" "\\[a-]") ;macron
(beginning-of-buffer)
(replace-string "\\u0307" "\\[a.]") ; (N/A) dotaccent
(beginning-of-buffer)
(replace-string "\\u0302" "\\[a^]") ; ^ circumflex
(beginning-of-buffer)
(replace-string "\\u0301" "\\[aa]") ; ' acute
(beginning-of-buffer)
(replace-string "\\u0300" "\\[ga]") ; ` grave
(beginning-of-buffer)
(replace-string "\\u0306" "\\[ab]") ; '` breve
(beginning-of-buffer)
(replace-string "\\u0327" "\\[ac]") ; , cedilla
(beginning-of-buffer)
(replace-string "\\u0308" "\\[ad]") ; " dieresis
(beginning-of-buffer)
(replace-string "\\u030C" "\\[ah]") ; v caron
(beginning-of-buffer)
(replace-string "\\u030A" "\\[ao]") ; o ring
(beginning-of-buffer)
(replace-string "\\u0303" "\\[a~]") ; ~ tilde
(beginning-of-buffer)
(replace-string "\\u0328" "\\[ho]") ; , ogonek
(beginning-of-buffer)
(replace-string "\\u005E" "\\[ha]") ; ^ asciicircum
(beginning-of-buffer)
(replace-string "\\u007E" "\\[ti]") ; ~ asciitilde
(beginning-of-buffer)
(replace-string "\\u201E" "\\[Bq]") ; ,, quotedblbase
(beginning-of-buffer)
(replace-string "\\u201A" "\\[bq]") ; , quotesinglbase
(beginning-of-buffer)
(replace-string "\\u201C" "\\[lq]") ; " quotedblleft
(beginning-of-buffer)
(replace-string "\\u201D" "\\[rq]") ; " quotedblright
(beginning-of-buffer)
(replace-string "\\u2018" "\\[oq]") ; ` quoteleft
(beginning-of-buffer)
(replace-string "\\u2019" "\\[cq]") ; ' quoteright
(beginning-of-buffer)
(replace-string "\\u0027" "\\[aq]") ; ' quotesingle
(beginning-of-buffer)
(replace-string "\\u0022" "\\[dq]") ; " quotedbl
(beginning-of-buffer)
(replace-string "\\u00AB" "\\[Fo]") ; << guillemotleft
(beginning-of-buffer)
(replace-string "\\u00BB" "\\[Fc]") ; >> guillemotright
(beginning-of-buffer)
(replace-string "\\u2039" "\\[fo]") ; < guilsinglleft
(beginning-of-buffer)
(replace-string "\\u203A" "\\[fc]") ; > guilsinglright
(beginning-of-buffer)
(replace-string "\\u00A1" "\\[r!]") ; ,i exclamdown
(beginning-of-buffer)
(replace-string "\\u00BF" "\\[r?]") ; 'c questiondown
(beginning-of-buffer)
(replace-string "\\u2014" "\\[em]") ; -- emdash
(beginning-of-buffer)
(replace-string "\\u2013" "\\[en]") ; - endash
(beginning-of-buffer)
(replace-string "\\u2010" "\\[hy]") ; - hyphen
(beginning-of-buffer)
(replace-string "\\u005B" "\\[lB]") ; [ bracketleft
(beginning-of-buffer)
(replace-string "\\u005D" "\\[rB]") ; ] bracketright
(beginning-of-buffer)
(replace-string "\\u007B" "\\[lC]") ; { braceleft
(beginning-of-buffer)
(replace-string "\\u007D" "\\[rC]") ; } braceright
(beginning-of-buffer)
(replace-string "\\u27E8" "\\[la]") ; < angleleft
(beginning-of-buffer)
(replace-string "\\u27E9" "\\[ra]") ; > angleright
(beginning-of-buffer)
(replace-string "\\u23AA" "\\[bv]") ; | braceex
(beginning-of-buffer)
(replace-string "\\u23AA" "\\[braceex]") ; (N/A) braceex
(beginning-of-buffer)
(replace-string "\\u23A1" "\\[bracketlefttp]") ; (N/A) bracketlefttp
(beginning-of-buffer)
(replace-string "\\u23A3" "\\[bracketleftbt]") ; (N/A) bracketleftbt
(beginning-of-buffer)
(replace-string "\\u23A2" "\\[bracketleftex]") ; (N/A) bracketleftex
(beginning-of-buffer)
(replace-string "\\u23A4" "\\[bracketrighttp]") ; (N/A) bracketrighttp
(beginning-of-buffer)
(replace-string "\\u23A6" "\\[bracketrightbt]") ; (N/A) bracketrightbt
(beginning-of-buffer)
(replace-string "\\u23A5" "\\[bracketrightex]") ; (N/A) bracketrightex
(beginning-of-buffer)
(replace-string "\\u23A7" "\\[lt]") ; ,- bracelefttp
(beginning-of-buffer)
(replace-string "\\u23A7" "\\[bracelefttp]") ; (N/A) bracelefttp
(beginning-of-buffer)
(replace-string "\\u23A8" "\\[lk]") ; { braceleftmid
(beginning-of-buffer)
(replace-string "\\u23A8" "\\[braceleftmid]") ; (N/A) braceleftmid
(beginning-of-buffer)
(replace-string "\\u23A9" "\\[lb]") ; `- braceleftbt
(beginning-of-buffer)
(replace-string "\\u23A9" "\\[braceleftbt]") ; (N/A) braceleftbt
(beginning-of-buffer)
(replace-string "\\u23AA" "\\[braceleftex]") ; (N/A) braceleftex
(beginning-of-buffer)
(replace-string "\\u23AB" "\\[rt]") ; -. bracerighttp
(beginning-of-buffer)
(replace-string "\\u23AB" "\\[bracerighttp]") ; (N/A) bracerighttp
(beginning-of-buffer)
(replace-string "\\u23AC" "\\[rk]") ; } bracerightmid
(beginning-of-buffer)
(replace-string "\\u23AC" "\\[bracerightmid]") ; (N/A) bracerightmid
(beginning-of-buffer)
(replace-string "\\u23AD" "\\[rb]") ; -' bracerightbt
(beginning-of-buffer)
(replace-string "\\u23AD" "\\[bracerightbt]") ; (N/A) bracerightbt
(beginning-of-buffer)
(replace-string "\\u23AA" "\\[bracerightex]") ; (N/A) bracerightex
(beginning-of-buffer)
(replace-string "\\u239B" "\\[parenlefttp]") ; (N/A) parenlefttp
(beginning-of-buffer)
(replace-string "\\u239D" "\\[parenleftbt]") ; (N/A) parenleftbt
(beginning-of-buffer)
(replace-string "\\u239C" "\\[parenleftex]") ; (N/A) parenleftex
(beginning-of-buffer)
(replace-string "\\u239E" "\\[parenrighttp]") ; (N/A) parenrighttp
(beginning-of-buffer)
(replace-string "\\u23A0" "\\[parenrightbt]") ; (N/A) parenrightbt
(beginning-of-buffer)
(replace-string "\\u239F" "\\[parenrightex]") ; (N/A) parenrightex
(beginning-of-buffer)
(replace-string "\\u2190" "\\[<-]") ; <- arrowleft
(beginning-of-buffer)
(replace-string "\\u2192" "\\[->]") ; -> arrowright
(beginning-of-buffer)
(replace-string "\\u2194" "\\[<>]") ; <-> arrowboth
(beginning-of-buffer)
(replace-string "\\u2193" "\\[da]") ; |v arrowdown
(beginning-of-buffer)
(replace-string "\\u2191" "\\[ua]") ; |^ arrowup
(beginning-of-buffer)
(replace-string "\\u2195" "\\[va]") ; (N/A) arrowupdn
(beginning-of-buffer)
(replace-string "\\u21D0" "\\[lA]") ; <= arrowdblleft
(beginning-of-buffer)
(replace-string "\\u21D2" "\\[rA]") ; => arrowdblright
(beginning-of-buffer)
(replace-string "\\u21D4" "\\[hA]") ; <=> arrowdblboth
(beginning-of-buffer)
(replace-string "\\u21D3" "\\[dA]") ; =v arrowdbldown
(beginning-of-buffer)
(replace-string "\\u21D1" "\\[uA]") ; =^ arrowdblup
(beginning-of-buffer)
(replace-string "\\u21D5" "\\[vA]") ; (N/A) uni21D5
(beginning-of-buffer)
(replace-string "\\u23AF" "\\[an]") ; - arrowhorizex
(beginning-of-buffer)
(replace-string "\\u007C" "\\[ba]") ; | bar
(beginning-of-buffer)
(replace-string "\\u2502" "\\[br]") ; | SF110000
(beginning-of-buffer)
(replace-string "\\u005F" "\\[ul]") ; _ underscore
(beginning-of-buffer)
(replace-string "\for" "\\use") ; _ `\[radicalex]'
(beginning-of-buffer)
(replace-string "\continuation" "\overline") ; "\[rn]" u203E
(beginning-of-buffer)
(replace-string "\---" "\\[ru]") ; _ ---
(beginning-of-buffer)
(replace-string "\\u00A6" "\\[bb]") ; | brokenbar
(beginning-of-buffer)
(replace-string "\\u002F" "\\[sl]") ; / slash
(beginning-of-buffer)
(replace-string "\\u005C" "\\[rs]") ; \ backslash
(beginning-of-buffer)
(replace-string "\\u25CB" "\\[ci]") ; O circle
(beginning-of-buffer)
(replace-string "\\u2022" "\\[bu]") ; +o bullet
(beginning-of-buffer)
(replace-string "\\u2021" "\\[dd]") ; |= daggerdbl
(beginning-of-buffer)
(replace-string "\\u2020" "\\[dg]") ; |- dagger
(beginning-of-buffer)
(replace-string "\\u25CA" "\\[lz]") ; <> lozenge
(beginning-of-buffer)
(replace-string "\\u25A1" "\\[sq]") ; [] uni25A1
(beginning-of-buffer)
(replace-string "\\u00B6" "\\[ps]") ; 9| paragraph
(beginning-of-buffer)
(replace-string "\\u00A7" "\\[sc]") ; S section
(beginning-of-buffer)
(replace-string "\\u261C" "\\[lh]") ; <= uni261C
(beginning-of-buffer)
(replace-string "\\u261E" "\\[rh]") ; => a14
(beginning-of-buffer)
(replace-string "\\u0040" "\\[at]") ; @ at
(beginning-of-buffer)
(replace-string "\\u0023" "\\[sh]") ; # numbersign
(beginning-of-buffer)
(replace-string "\\u21B5" "\\[CR]") ; _| carriagereturn
(beginning-of-buffer)
(replace-string "\\u2713" "\\[OK]") ; (N/A) a19
(beginning-of-buffer)
(replace-string "\\u00A9" "\\[co]") ; (C) copyright
(beginning-of-buffer)
(replace-string "\\u00AE" "\\[rg]") ; (R) registered
(beginning-of-buffer)
(replace-string "\\u2122" "\\[tm]") ; tm trademark
(beginning-of-buffer)
(replace-string "\\u0024" "\\[Do]") ; $ dollar
(beginning-of-buffer)
(replace-string "\\u00A2" "\\[ct]") ; /c cent
(beginning-of-buffer)
(replace-string "\\u20AC" "\\[eu]") ; EUR ---
(beginning-of-buffer)
(replace-string "\\u20AC" "\\[Eu]") ; EUR Euro
(beginning-of-buffer)
(replace-string "\\u00A5" "\\[Ye]") ; =Y yen
(beginning-of-buffer)
(replace-string "\\u00A3" "\\[Po]") ; -L sterling
(beginning-of-buffer)
(replace-string "\\u00A4" "\\[Cs]") ; ox currency
(beginning-of-buffer)
(replace-string "\\u0192" "\\[Fn]") ; ,f florin
(beginning-of-buffer)
(replace-string "\\u00B0" "\\[de]") ; o degree
(beginning-of-buffer)
(replace-string "\\u2030" "\\[%0]") ; %o perthousand
(beginning-of-buffer)
(replace-string "\\u2032" "\\[fm]") ; ' minute
(beginning-of-buffer)
(replace-string "\\u2033" "\\[sd]") ; '' second
(beginning-of-buffer)
(replace-string "\\u00B5" "\\[mc]") ; ,u mu
(beginning-of-buffer)
(replace-string "\\u00AA" "\\[Of]") ; _a ordfeminine
(beginning-of-buffer)
(replace-string "\\u00BA" "\\[Om]") ; _o ordmasculine
(beginning-of-buffer)
(replace-string "\\u2227" "\\[AN]") ; ^ logicaland
(beginning-of-buffer)
(replace-string "\\u2228" "\\[OR]") ; v logicalor
(beginning-of-buffer)
(replace-string "\\u00AC" "\\[no]") ; ~ logicalnot
(beginning-of-buffer)
(replace-string "\\u00AC" "\\[tno]") ; ~ logicalnot
(beginning-of-buffer)
(replace-string "\\u2203" "\\[te]") ; 3 existential
(beginning-of-buffer)
(replace-string "\\u2200" "\\[fa]") ; -V universal
(beginning-of-buffer)
(replace-string "\\u220B" "\\[st]") ; -) suchthat
(beginning-of-buffer)
(replace-string "\\u2234" "\\[3d]") ; .:. therefore
(beginning-of-buffer)
(replace-string "\\u2234" "\\[tf]") ; .:. therefore
(beginning-of-buffer)
(replace-string "\\u007C" "\\[or]") ; | bar
(beginning-of-buffer)
(replace-string "\\u00BD" "\\[12]") ; 1/2 onehalf
(beginning-of-buffer)
(replace-string "\\u00BC" "\\[14]") ; 1/4 onequarter
(beginning-of-buffer)
(replace-string "\\u00BE" "\\[34]") ; 3/4 threequarters
(beginning-of-buffer)
(replace-string "\\u215B" "\\[18]") ; 1/8 oneeighth
(beginning-of-buffer)
(replace-string "\\u215C" "\\[38]") ; 3/8 threeeighths
(beginning-of-buffer)
(replace-string "\\u215D" "\\[58]") ; 5/8 fiveeighths
(beginning-of-buffer)
(replace-string "\\u215E" "\\[78]") ; 7/8 seveneighths
(beginning-of-buffer)
(replace-string "\\u00B9" "\\[S1]") ; 1 onesuperior
(beginning-of-buffer)
(replace-string "\\u00B2" "\\[S2]") ; 2 twosuperior
(beginning-of-buffer)
(replace-string "\\u00B3" "\\[S3]") ; 3 threesuperior
(beginning-of-buffer)
(replace-string "\\u002B" "\\[pl]") ; + plus
(beginning-of-buffer)
(replace-string "\\u2212" "\\[mi]") ; - minus
(beginning-of-buffer)
(replace-string "\\u2213" "\\[-+]") ; -+ uni2213
(beginning-of-buffer)
(replace-string "\\u00B1" "\\[+-]") ; +- plusminus
(beginning-of-buffer)
(replace-string "\\u00B1" "\\[t+-]") ; +- plusminus
(beginning-of-buffer)
(replace-string "\\u00B7" "\\[pc]") ; . periodcentered
(beginning-of-buffer)
(replace-string "\\u22C5" "\\[md]") ; . dotmath
(beginning-of-buffer)
(replace-string "\\u00D7" "\\[mu]") ; x multiply
(beginning-of-buffer)
(replace-string "\\u00D7" "\\[tmu]") ; x multiply
(beginning-of-buffer)
(replace-string "\\u2297" "\\[c*]") ; Ox circlemultiply
(beginning-of-buffer)
(replace-string "\\u2295" "\\[c+]") ; O+ circleplus
(beginning-of-buffer)
(replace-string "\\u00F7" "\\[di]") ; -:- divide
(beginning-of-buffer)
(replace-string "\\u00F7" "\\[tdi]") ; -:- divide
(beginning-of-buffer)
(replace-string "\\u2044" "\\[f/]") ; / fraction
(beginning-of-buffer)
(replace-string "\\u2217" "\\[**]") ; * asteriskmath
(beginning-of-buffer)
(replace-string "\\u2264" "\\[<=]") ; <= lessequal
(beginning-of-buffer)
(replace-string "\\u2265" "\\[>=]") ; >= greaterequal
(beginning-of-buffer)
(replace-string "\\u226A" "\\[<<]") ; << uni226A
(beginning-of-buffer)
(replace-string "\\u226B" "\\[>>]") ; >> uni226B
(beginning-of-buffer)
(replace-string "\\u003D" "\\[eq]") ; = equal
(beginning-of-buffer)
(replace-string "\\u003D_0338" "\\[!=]") ; != notequal
(beginning-of-buffer)
(replace-string "\\u2261" "\\[==]") ; == equivalence
(beginning-of-buffer)
(replace-string "\\u2261_0338" "\\[ne]") ; !== uni2262
(beginning-of-buffer)
(replace-string "\\u2245" "\\[=~]") ; =~ congruent
(beginning-of-buffer)
(replace-string "\\u2243" "\\[|=]") ; -~ uni2243
(beginning-of-buffer)
(replace-string "\\u223C" "\\[ap]") ; ~ similar
(beginning-of-buffer)
(replace-string "\\u2248" "\\[~~]") ; ~~ approxequal
(beginning-of-buffer)
(replace-string "\\u2248" "\\[~=]") ; ~= approxequal
(beginning-of-buffer)
(replace-string "\\u221D" "\\[pt]") ; oc proportional
(beginning-of-buffer)
(replace-string "\\u2205" "\\[es]") ; {} emptyset
(beginning-of-buffer)
(replace-string "\\u2208" "\\[mo]") ; E element
(beginning-of-buffer)
(replace-string "\\u2208_0338" "\\[nm]") ; /E notelement
(beginning-of-buffer)
(replace-string "\\u2282" "\\[sb]") ; (= propersubset
(beginning-of-buffer)
(replace-string "\\u2282_0338" "\\[nb]") ; (N/A) notsubset
(beginning-of-buffer)
(replace-string "\\u2283" "\\[sp]") ; =) propersuperset
(beginning-of-buffer)
(replace-string "\\u2283_0338" "\\[nc]") ; (N/A) uni2285
(beginning-of-buffer)
(replace-string "\\u2286" "\\[ib]") ; (=_ reflexsubset
(beginning-of-buffer)
(replace-string "\\u2287" "\\[ip]") ; =_) reflexsuperset
(beginning-of-buffer)
(replace-string "\\u2229" "\\[ca]") ; (^) intersection
(beginning-of-buffer)
(replace-string "\\u222A" "\\[cu]") ; U union
(beginning-of-buffer)
(replace-string "\\u2220" "\\[/_]") ; _/ angle
(beginning-of-buffer)
(replace-string "\\u22A5" "\\[pp]") ; _| perpendicular
(beginning-of-buffer)
(replace-string "\\u222B" "\\[is]") ; ',I integral
(beginning-of-buffer)
(replace-string "\\u2207" "\\[gr]") ; V gradient
(beginning-of-buffer)
(replace-string "\\u221A" "\\[sr]") ; "\/" radical
(beginning-of-buffer)
(replace-string "\\u2308" "\\[lc]") ; |~ uni2308
(beginning-of-buffer)
(replace-string "\\u2309" "\\[rc]") ; ~| uni2309
(beginning-of-buffer)
(replace-string "\\u230A" "\\[lf]") ; |_ uni230A
(beginning-of-buffer)
(replace-string "\\u230B" "\\[rf]") ; _| uni230B
(beginning-of-buffer)
(replace-string "\\u221E" "\\[if]") ; oo infinity
(beginning-of-buffer)
(replace-string "\\u2135" "\\[Ah]") ; N aleph
(beginning-of-buffer)
(replace-string "\\u2111" "\\[Im]") ; I Ifraktur
(beginning-of-buffer)
(replace-string "\\u211C" "\\[Re]") ; R Rfraktur
(beginning-of-buffer)
(replace-string "\\u2118" "\\[wp]") ; p weierstrass
(beginning-of-buffer)
(replace-string "\\u2202" "\\[pd]") ; a partialdiff
(beginning-of-buffer)
(replace-string "\variant." "\the") ; `\[+f]' curly
(beginning-of-buffer)
(replace-string "\\u0391" "\\[*A]") ; A Alpha
(beginning-of-buffer)
(replace-string "\\u0392" "\\[*B]") ; B Beta
(beginning-of-buffer)
(replace-string "\\u0393" "\\[*G]") ; | Gamma
(beginning-of-buffer)
(replace-string "\\u0394" "\\[*D]") ; _/_\ Delta
(beginning-of-buffer)
(replace-string "\\u0395" "\\[*E]") ; E Epsilon
(beginning-of-buffer)
(replace-string "\\u0396" "\\[*Z]") ; Z Zeta
(beginning-of-buffer)
(replace-string "\\u0397" "\\[*Y]") ; H Eta
(beginning-of-buffer)
(replace-string "\\u0398" "\\[*H]") ; -O Theta
(beginning-of-buffer)
(replace-string "\\u0399" "\\[*I]") ; I Iota
(beginning-of-buffer)
(replace-string "\\u039A" "\\[*K]") ; K Kappa
(beginning-of-buffer)
(replace-string "\\u039B" "\\[*L]") ; /\ Lambda
(beginning-of-buffer)
(replace-string "\\u039C" "\\[*M]") ; M Mu
(beginning-of-buffer)
(replace-string "\\u039D" "\\[*N]") ; N Nu
(beginning-of-buffer)
(replace-string "\\u039E" "\\[*C]") ; _H Xi
(beginning-of-buffer)
(replace-string "\\u039F" "\\[*O]") ; O Omicron
(beginning-of-buffer)
(replace-string "\\u03A0" "\\[*P]") ; TT Pi
(beginning-of-buffer)
(replace-string "\\u03A1" "\\[*R]") ; P Rho
(beginning-of-buffer)
(replace-string "\\u03A3" "\\[*S]") ; _> Sigma
(beginning-of-buffer)
(replace-string "\\u03A4" "\\[*T]") ; T Tau
(beginning-of-buffer)
(replace-string "\\u03A5" "\\[*U]") ; Y Upsilon
(beginning-of-buffer)
(replace-string "\\u03A6" "\\[*F]") ; IO Phi
(beginning-of-buffer)
(replace-string "\\u03A7" "\\[*X]") ; X Chi
(beginning-of-buffer)
(replace-string "\\u03A8" "\\[*Q]") ; IY Psi
(beginning-of-buffer)
(replace-string "\\u03A9" "\\[*W]") ; _O Omega
(beginning-of-buffer)
(replace-string "\\u03B1" "\\[*a]") ; a alpha
(beginning-of-buffer)
(replace-string "\\u03B2" "\\[*b]") ; B beta
(beginning-of-buffer)
(replace-string "\\u03B3" "\\[*g]") ; y gamma
(beginning-of-buffer)
(replace-string "\\u03B4" "\\[*d]") ; d delta
(beginning-of-buffer)
(replace-string "\\u03B5" "\\[*e]") ; e epsilon
(beginning-of-buffer)
(replace-string "\\u03B6" "\\[*z]") ; ,C zeta
(beginning-of-buffer)
(replace-string "\\u03B7" "\\[*y]") ; n eta
(beginning-of-buffer)
(replace-string "\\u03B8" "\\[*h]") ; -0 theta
(beginning-of-buffer)
(replace-string "\\u03B9" "\\[*i]") ; i iota
(beginning-of-buffer)
(replace-string "\\u03BA" "\\[*k]") ; k kappa
(beginning-of-buffer)
(replace-string "\\u03BB" "\\[*l]") ; >\ lambda
(beginning-of-buffer)
(replace-string "\\u03BC" "\\[*m]") ; ,u mu
(beginning-of-buffer)
(replace-string "\\u03BD" "\\[*n]") ; v nu
(beginning-of-buffer)
(replace-string "\\u03BE" "\\[*c]") ; ,E xi
(beginning-of-buffer)
(replace-string "\\u03BF" "\\[*o]") ; o omicron
(beginning-of-buffer)
(replace-string "\\u03C0" "\\[*p]") ; -n pi
(beginning-of-buffer)
(replace-string "\\u03C1" "\\[*r]") ; p rho
(beginning-of-buffer)
(replace-string "\\u03C2" "\\[ts]") ; s sigma1
(beginning-of-buffer)
(replace-string "\\u03C3" "\\[*s]") ; -o sigma
(beginning-of-buffer)
(replace-string "\\u03C4" "\\[*t]") ; ~t tau
(beginning-of-buffer)
(replace-string "\\u03C5" "\\[*u]") ; u upsilon
(beginning-of-buffer)
(replace-string "\\u03D5" "\\[*f]") ; |o phi
(beginning-of-buffer)
(replace-string "\\u03C7" "\\[*x]") ; x chi
(beginning-of-buffer)
(replace-string "\\u03C8" "\\[*q]") ; |u psi
(beginning-of-buffer)
(replace-string "\\u03C9" "\\[*w]") ; w omega
(beginning-of-buffer)
(replace-string "\\u03D1" "\\[+h]") ; -0 theta1
(beginning-of-buffer)
(replace-string "\\u03C6" "\\[+f]") ; |o phi1
(beginning-of-buffer)
(replace-string "\\u03D6" "\\[+p]") ; -w omega1
(beginning-of-buffer)
(replace-string "\\u03F5" "\\[+e]") ; e uni03F5
(beginning-of-buffer)
(replace-string "\\u2663" "\\[CL]") ; (N/A) club
(beginning-of-buffer)
(replace-string "\\u2660" "\\[SP]") ; (N/A) spade
(beginning-of-buffer)
(replace-string "\\u2665" "\\[HE]") ; (N/A) heart
(beginning-of-buffer)
(replace-string "\\u2662" "\\[u2662]") ; (N/A) uni2662
(beginning-of-buffer)
(replace-string "\\u2666" "\\[DI]") ; (N/A) diamond
(beginning-of-buffer)
(replace-string "\\u2661" "\\[u2661]") ; (N/A) uni2661
)
)
(mouse-avoidance-mode 'cat-and-mouse)
;; (require 'erc-auto)
(defun erc ()
(interactive)
(require 'erc-auto)
(erc-select) )
(defun kill-and-close ()
(interactive)
(kill-buffer nil)
(delete-frame) )
(global-set-key (quote [M-f6]) (quote kill-and-close))
; XXX (re)move this when we fix C indent macros
(defun insert-function-synopsis ()
"Insert a synopsis skeleton for MySQL function description"
(interactive)
(insert "
/*
XXXSHORT DESCRIPTION
SYNOPSIS
XXXFUNCTION()
XXXParm in/out XXXParameter description
DESCRIPTION
XXXDescribe
RETURN VALUE
XXXSUCCESS OK
XXXFAILURE not OK
*/"))
(global-set-key "\363" (quote insert-function-synopsis))
(setq case-fold-search t)
(defun insert-timestamp ()
(interactive)
(insert (format-time-string "%a, %e %b %Y %R:%S %z")) )
;; convert /etc/fstab entries into a series of commands to Apple's "Nentinfo"
;; to create automounts.
(defun make-apple-fstab-crap ()
(query-replace-regexp
"^\\([^:]+:\\)\\([^ ]+\\)[ ]+\\([^ ]+\\).*nfs[ ]+\\([^ ]+\\).*"
"nicl . -create /mounts/\\1\\\\\\\\\\2
nicl . -append /mounts/\\1\\\\\\\\\\2 opts \\4
nicl . -append /mounts/\\1\\\\\\\\\\2 type nfs
nicl . -append /mounts/\\1\\\\\\\\\\2 dir \\3" nil nil nil) )
;; PHP mode
(autoload 'php-mode "php-mode" "Mode for editing PHP source files")
(add-to-list 'auto-mode-alist '("\\.\\(inc\\|php[s34]?\\)" . php-mode))
;; SES
(autoload 'ses-mode "ses.el" "Spreadsheet mode" t)
(add-to-list 'auto-mode-alist '("\\.ses$" . ses-mode))
;; esheet (http://esheet.sourceforge.net/esheet-documentation.html)
;; calc mode
(autoload 'calc-dispatch "calc" "Calculator Options" t)
(autoload 'full-calc "calc" "Full-screen Calculator" t)
(autoload 'full-calc-keypad "calc" "Full-screen X Calculator" t)
(autoload 'calc-eval "calc" "Use Calculator from Lisp")
(autoload 'defmath "calc" nil t t)
(autoload 'calc "calc" "Calculator Mode" t)
(autoload 'quick-calc "calc" "Quick Calculator" t)
(autoload 'calc-keypad "calc" "X windows Calculator" t)
(autoload 'calc-embedded "calc" "Use Calc from any buffer" t)
(autoload 'calc-embedded-activate "calc" "Activate =>'s in buffer" t)
(autoload 'calc-grab-region "calc" "Grab region of Calc data" t)
(autoload 'calc-grab-rectangle "calc" "Grab rectangle of data" t)
(setq load-path (append load-path (list "/usr/local/share/emacs/site-lisp/calc")))
(defun sgml-to-nxml ()
"Convert Mikal's output to DocBook"
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-string "sgml-fill" "nxml") ; mode (first line only)
(beginning-of-buffer)
(replace-regexp "\\\\\\[[lr]q\\]" "\"")
(beginning-of-buffer)
(replace-string "\\\[em]" "—")
(beginning-of-buffer)
(replace-regexp "\\\\[/|]" "")
(beginning-of-buffer)
(replace-string "\\e" "\\")
(beginning-of-buffer)
(replace-string "" "")
(beginning-of-buffer)
(beginning-of-buffer)
(beginning-of-buffer)
(beginning-of-buffer) ) )
;; Stuff for nXML
;; path to where nxml is
(setq nxml-path "/usr/local/share/emacs/22.2/site-lisp/nxml/")
(load (concat nxml-path "rng-auto.el"))
(add-to-list 'auto-mode-alist
(cons (concat "\\." (regexp-opt '("xml" "xsd" "sch" "rng" "xslt" "svg" "rss") t) "\\'")
'nxml-mode))
(unify-8859-on-decoding-mode)
(setq magic-mode-alist
(cons '("
")
(replace-regexp "\\\\\\[[lr]q\\]" "\"")
(beginning-of-buffer)
(replace-regexp "^\\.Chapter [^ ]+ \\(.*\\)" "
\\1
")
(beginning-of-buffer)
;; Somehow the font conversions trigger on this one, so fix first.
(replace-regexp "\\.\\\\\"?\\ \\(.*\\)" "")
(beginning-of-buffer)
(replace-string "\\\[em]" "—")
(beginning-of-buffer)
(replace-regexp "\\\\[/|]" "")
(beginning-of-buffer)
(replace-string "\\e" "\\")
;; This is a mess. We can have unrleated backslashes at the beginning. Do it twice.
(beginning-of-buffer)
(replace-regexp "\\\\f\\[CW\\]\\([^\\\\]+\\)" "\\1 ")
(beginning-of-buffer)
(replace-regexp "\\\\fI\\([^\\\\]+\\)" "\\1 ")
;; Now check for \f at the end
(beginning-of-buffer)
(replace-regexp "\\\\f\\[CW\\]\\(.+\\)\\\\fP" "\\1 ")
(beginning-of-buffer)
(replace-regexp "\\\\fI\\(.+\\)\\\\fP" "\\1 ")
(beginning-of-buffer)
(replace-regexp "\\\\fP" "")
(beginning-of-buffer)
(replace-regexp "^\\.H2 \\(.*\\)" "
\\1
" )
(beginning-of-buffer)
(replace-regexp "^\\.H3 \\(.*\\)" "
\\1
" )
(beginning-of-buffer)
(replace-string ".P
" "
" )
(beginning-of-buffer)
(replace-regexp "^\\.H4 \\(.*\\)" "
\\1
" )
(beginning-of-buffer)
(replace-string ".P
" "
" )
(beginning-of-buffer)
;; Fix this (Ls and Ls B)
(replace-string "
.Ls B
" "
" )
(beginning-of-buffer)
(replace-string ".LI
" "
" )
(beginning-of-buffer)
(replace-string ".Le
" "
" )
(beginning-of-buffer)
(replace-string "
" "")
(beginning-of-buffer)
(replace-string ".FS
" "
" )
(beginning-of-buffer)
(replace-string ".FE
" "
" )
(beginning-of-buffer)
(replace-string ".Dx
" "
" )
(beginning-of-buffer)
(replace-string ".De
" "
" )
(beginning-of-buffer)
(replace-string "
,highlight
" "
" )
(beginning-of-buffer)
(replace-string "
,/highlight
" "
" )
;; Placeholders for things we can't convert
(beginning-of-buffer)
(replace-regexp "^\\.Pic \\(.*\\)
" "
Insert picture \\1 here
" )
(beginning-of-buffer)
(replace-string ".PS
" "
Start of pic diagram
" )
(beginning-of-buffer)
(replace-string ".PE
" "
End of pic diagram
" )
(beginning-of-buffer)
(replace-string ".TS
" "
Start of table
" )
(beginning-of-buffer)
(replace-string ".TE
" "
End of table
" )
;; Stuff that DocBook doesn't believe in
(beginning-of-buffer)
(replace-regexp "^\\.br\\|^\\.ne .*\\|^\\.na\\|^\\.ad" "")
;; Keep this at the end
(end-of-buffer)
(insert "
") ) )
(defun diary-convert ()
"Convert diary entry to PHP"
(interactive)
(save-excursion
(setq month (read-from-minibuffer "Month: "))
(setq monthno (read-from-minibuffer "Month number (sorry, will be fixed): "))
(setq year (read-from-minibuffer "Year: "))
;; Title with location
;; single digit days
(beginning-of-buffer)
(query-replace-regexp (concat
"
*
*\\(.*\\)
* ")
(concat "
" ) )
;; dual digit days
(beginning-of-buffer)
(query-replace-regexp (concat
"
*
*\\(.*\\)
* ")
(concat
"
" ) )
;; Title without location
;; single digit days
(beginning-of-buffer)
(query-replace-regexp (concat
"")
(concat
"
" ) )
;; double digit days
(beginning-of-buffer)
(query-replace-regexp (concat
"")
(concat
"
" ) )
;; rename small images
(beginning-of-buffer)
(query-replace-regexp "/small/" "/tiny/")
;;; convert the guts to showphoto
(beginning-of-buffer)
(query-replace-regexp " src=\"\\(.*\\)/tiny\\([^\"]+\\)\".*" "
")
;;; Remove crap before a showphoto
(beginning-of-buffer)
(query-replace-regexp ".*\">" nil)
;; Characters
(beginning-of-buffer)
(query-replace-regexp "``" "“")
(beginning-of-buffer)
(query-replace-regexp "--" "—")
(beginning-of-buffer)
(query-replace-regexp "''" "”")
;; Tidy up left-over junk
(beginning-of-buffer)
(query-replace-regexp " " "")
(if nil
(progn
(beginning-of-buffer)
(query-replace-regexp "\\([^>
]\\) *
+\\([ ]*<\\?php daytit\\)" "\\1
\\2")
(beginning-of-buffer)
(query-replace-regexp "
\\([ ]*\\)\\([A-z]\\)" "
\\1
\\1\\2")
(beginning-of-buffer)
(query-replace-regexp " *
*
*
" "" ) )) ;;;; XXX (if nil
(beginning-of-buffer)
(query-replace-regexp "
+" "
")
(headerpara)
;; Add new headers and footers
(beginning-of-buffer)
(insert "
")
(end-of-buffer)
(insert "
")
(beginning-of-buffer)
(query-replace-regexp "
+" "
")
) )
(defun makepara ()
(interactive)
;;; add a before a paragraph
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "
+\\([ ]*\\)\\([^>
]*\\)" "
\\1
\\1\\2")
;;; Add a
after a paragraph
(beginning-of-buffer)
(query-replace-regexp "\\([^>
]\\)
" "\\1
")
) )
(defun headerpara ()
"Put paragraphs round daytitle headers"
(interactive)
(save-excursion
(beginning-of-buffer)
(query-replace-regexp "\\(.*daytit.*\\)" "
\\1
") ) )
(defun fixphotos ()
"Convert photos in web pages to use showphoto()"
(interactive)
(save-excursion
(beginning-of-buffer)
;; References to web pages with tag
(query-replace-regexp
"\\([^<]+\\) "
"")
(beginning-of-buffer)
;; References to web pages without tag
(query-replace-regexp
"\\([^<]+\\) "
"")
(beginning-of-buffer)
(query-replace-regexp "/small/" "/tiny/")
;; convert the guts to showphoto
(beginning-of-buffer)
(query-replace-regexp " src=\"\\(.*\\)/tiny\\([^\"]+\\)\".*" "
")
;; Remove crap before a showphoto
(beginning-of-buffer)
(query-replace-regexp ".*\">
")
(beginning-of-buffer)
(query-replace-regexp "href=\"Photos-\\(.*\\).html\">\\([^<]+\\)" "")
) )
;; WRITEME
(defun makevalues ()
"Convert line with double space delimiters into a list suitable for SQL insert commands"
(interactive)
(message "FOO") )