(defun tex-bounce-backward nil "\ Bounce backward to check the open paren." (interactive) (byte-code "!!)" [nil backward-list 1 tex-bouncing-point] 3)) (defun tex-bounce-forward nil "\ Bounce forward to check the close paren." (interactive) (byte-code "! !)" [nil forward-list 1 backward-char tex-bouncing-point] 4)) (defun tex-toggle-boundary-check nil "\ Toggle the flag tex-boundary-check-on" (interactive) (byte-code "!‰!" [tex-boundary-check-on nil t message "Boundary checking in delemiter matching disabled." "Boundary checking in delemiter matching enabled."] 3)) (defconst tex-blank 32) (defconst tex-tab 9) (defconst tex-space " \\| ") (defun tex-zone-open nil "\ Open a TeX zone." (interactive) (byte-code "ˆ `\"B T \"" [tex-zone-marker-stack tex-zone-marker-count nil set-marker make-marker message "TeX zone #%d opened."] 5)) (defun tex-zone-close nil "\ Close a TeX zone explicitly." (interactive) (byte-code "È+@ \"A S !$ !'!).!" [tex-zone-marker-stack mark tex-zone-marker-count nil message "TeX zone #%d closed." markerp marker-position error "TeX zone marker stack contains non-markers...aborted (I'm confused)" "TeX zone marker stack is empty"] 6)) (defun tex-zone-inspect (&optional n) "\ Pek the Nth TeX zone marker." (interactive "p") (byte-code "ňM V  V$ \" S8 !F SZ # !b!)I!+P!" [tex-zone-marker-stack n m mark tex-zone-marker-count nil 0 1 error "TeX zone marker stack is only %d level deep" markerp message "TeX zone #%d (total %d)" tex-bouncing-point marker-position "TeX zone marker stack contains non-markers...aborted (I'm confused)" "TeX zone marker stack is empty"] 8)) (defun tex-zone-start nil (byte-code "n hU h U‚ !$!! !n5`7`T)!hUGh UO`SP`) `\"`\"Q\"rUz bUb!!," [tex-blank tex-tab nil tex-space tex-boundary-check-on lw rw word char t looking-at re-search-forward "[^ ]" backward-char 1 re-search-backward " \\| \\|^" " \\| \\|$" buffer-substring "|" message "Confirm position `%s' (l, r, else=yes)" 108 114] 11)) (defun tex-zone-end nil (byte-code "l!!!~ ~!n%`'`T)!h U7h U?`S@`) `\"` \"Q\"rUh b}U| b!!}," [tex-space tex-boundary-check-on lw rw tex-blank tex-tab word char t looking-at re-search-backward "[^ ]" forward-char 1 " \\| \\|^" re-search-forward " \\| \\|$" buffer-substring "|" nil message "Confirm position `%s' (l, r, else=yes)" 114 108] 11)) (defun tex-zone (l-sym r-sym) "\ Puts L-SYM and R-SYM around topmost zone marker and point." (byte-code " ` GG  V&  b ` c \\b c` [b b!)db !)." [start end swap nil ll l-sym rl r-sym lr rr tex-zone-close 0 tex-zone-start tex-zone-end tex-bouncing-point] 8)) (defun tex-zone-math nil "\ Embrace the innermost TeX zone with a pair of $'s. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "$"] 3)) (defun tex-zone-display-math nil "\ Embrace the innermost TeX zone with a pair of $$'s. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "$$"] 3)) (defun tex-zone-single-quote nil "\ Embrace the innermost TeX zone with a left single quote (`) and a right single quote ('). Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "`" "'"] 3)) (defun tex-zone-double-quote nil "\ Embrace the innermost TeX zone with a left double quote (``) and a right double quote (''). Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "``" "''"] 3)) (defun tex-zone-centerline nil "\ Embrace the innermost TeX zone by \\centerline{...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "\\centerline{" "}"] 3)) (defun tex-zone-hbox nil "\ Embrace the innermost TeX zone by \\hbox{...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "\\hbox{" "}"] 3)) (defun tex-zone-vbox nil "\ Embrace the innermost TeX zone by \\vbox{...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "\\vbox{" "}"] 3)) (defun tex-zone-bf nil "\ Embrace the innermost TeX zone by {\\bf ...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\bf " "}"] 3)) (defun tex-zone-it nil "\ Embrace the innermost TeX zone by {\\it ...\\/} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\it " "\\/}"] 3)) (defun tex-zone-rm nil "\ Embrace the innermost TeX zone by {\\rm ...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\rm " "}"] 3)) (defun tex-zone-sl nil "\ Embrace the innermost TeX zone by {\\sl ...\\/} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\sl " "\\/}"] 3)) (defun tex-zone-tt nil "\ Embrace the innermost TeX zone by {\\tt ...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\tt " "}"] 3)) (defun tex-zone-em nil "\ Embrace the innermost TeX zone by {\\em ...} with ... being the text between zone marker and point. Position confirmation is required if either end touches any non-blank symbol." (interactive) (byte-code "\"" [nil tex-zone "{\\em " "}"] 3)) (defun tex-word (l-sym r-sym &optional n) "\ Puts L-SYm and R-SYM around next N (default 1) words; previous N words if N is negative." (byte-code " G GV` ` c!!3ǂH!hUBh UH! c` bb !) ! `\\!nhUh Uǂ!gUg U!` !b b !)-" [n ll l-sym rl r-sym lr rr nil tex-blank tex-tab 1 0 tex-zone-start forward-word looking-at " \\|$\\| " re-search-forward backward-char tex-bouncing-point tex-zone-end insert-string re-search-backward " \\|^\\| " forward-char] 14)) (defun tex-word-math (&optional n) "\ Embrace the previous word with a pair of $'s. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "$" -1] 4)) (defun tex-word-display-math (&optional n) "\ Embrace the previous word with a pair of $$'s. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "$$" -1] 4)) (defun tex-word-single-quote (&optional n) "\ Embrace the previous word with a pair of left and right single quotes (|`...'|). With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "`" "'" -1] 4)) (defun tex-word-double-quote (&optional n) "\ Embrace the previous word with a pair of left and right double quotes (|``...''|). With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "``" "''" -1] 4)) (defun tex-word-centerline (&optional n) "\ Embrace the previous word by \\centerline{...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "\\centerline{" "}" -1] 4)) (defun tex-word-hbox (&optional n) "\ Embrace the previous word by \\hbox{...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "\\hbox{" "}" -1] 4)) (defun tex-word-vbox (&optional n) "\ Embrace the previous word by \\vbox{...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "\\vbox{" "}" -1] 4)) (defun tex-word-bf (&optional n) "\ Embrace the previous word by {\\bf ...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\bf " "}" -1] 4)) (defun tex-word-it (&optional n) "\ Embrace the previous word by {\\it ...\\/} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\it " "\\/}" -1] 4)) (defun tex-word-rm (&optional n) "\ Embrace the previous word by {\\rm ...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\rm " "}" -1] 4)) (defun tex-word-sl (&optional n) "\ Embrace the previous word by {\\sl ...\\/} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\sl " "\\/}" -1] 4)) (defun tex-word-tt (&optional n) "\ Embrace the previous word by {\\tt ...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\tt " "}" -1] 4)) (defun tex-word-em (&optional n) "\ Embrace the previous word by {\\em ...} with ... being the word. With positive prefix argument N, embrace previous N words; or with negative prefix argument N, embrace next N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "[#" [n nil tex-word "{\\em " "}" -1] 4)) (defun tex-word-forward-math (&optional n) "\ Embrace the previous word with a pair of $'s. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "$"] 4)) (defun tex-word-forward-display-math (&optional n) "\ Embrace the next word with a pair of $$'s. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "$$"] 4)) (defun tex-word-forward-single-quote (&optional n) "\ Embrace the next word with a pair of left and right single quotes (|`...'|). With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "`" "'"] 4)) (defun tex-word-forward-double-quote (&optional n) "\ Embrace the next word with a pair of left and right double quotes (|``...''|). With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "``" "''"] 4)) (defun tex-word-forward-centerline (&optional n) "\ Embrace the next word by \\centerline{...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "\\centerline{" "}"] 4)) (defun tex-word-forward-hbox (&optional n) "\ Embrace the next word by \\hbox{...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "\\hbox{" "}"] 4)) (defun tex-word-forward-vbox (&optional n) "\ Embrace the next word by \\vbox{...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "\\vbox{" "}"] 4)) (defun tex-word-forward-bf (&optional n) "\ Embrace the next word by {\\bf ...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\bf " "}"] 4)) (defun tex-word-forward-it (&optional n) "\ Embrace the next word by {\\it ...\\/} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\it " "\\/}"] 4)) (defun tex-word-forward-rm (&optional n) "\ Embrace the next word by {\\rm ...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\rm " "}"] 4)) (defun tex-word-forward-sl (&optional n) "\ Embrace the next word by {\\sl ...\\/} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\sl " "\\/}"] 4)) (defun tex-word-forward-tt (&optional n) "\ Embrace the next word by {\\tt ...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\tt " "}"] 4)) (defun tex-word-forward-em (&optional n) "\ Embrace the next word by {\\em ...} with ... being the word. With positive prefix argument N, embrace next N words; or with negative prefix argument N, embrace previous N words. Position confirmation is required if either end touches any non-blank symbol." (interactive "P") (byte-code "#" [n nil tex-word "{\\em " "}"] 4)) (defun tex-latex-open (env arg) "\ Open a new LaTeX environment. The user will be prompted for ENV and ARG." (interactive "sLaTeX \\begin{env}, specify env (RET if none): sArguments (RET if none): ") (byte-code "Ĉi \" c% # \"#Ă% c 2c7 # ! \\j*" [col empty-p env arg nil tex-latex-indentation string-equal "" "\\begin" insert "\\begin{" "}" newline-and-indent "\\end" "\\end{" beginning-of-line open-line 1] 9)) (defun tex-latex-close nil "\ Close LaTeX environment." (interactive) (byte-code "Èeb\"eb\")!`!`Vd`i#^!X!`S! `\")[׉a؉g؉)! V ! j \"  j)eb\"eb\") Vb ! !!!\"\")!+" [pos col env nil t begin ind tex-replace-string "\\begin" "(*****" "\\end" ")***" insert-string ")" backward-sexp 1 search-forward "*****" looking-at " *{" "{" "}" buffer-substring "" -1 delete-backward-char beginning-of-line "^\\W*$" end-of-line newline current-indentation pos-visible-in-window-p sit-for re-search-forward "^.*$" message "%s" match-beginning 0 match-end error "\\begin...\\end pair failed to match!"] 30)) (defun tex-replace-string (old new) "\ Replace OLD by NEW, both strings, quietly (i.e. with no minibuffer messages)." (byte-code "#!!\" !" [old nil t new search-forward delete-region match-beginning 0 match-end insert-string] 7)) (defun tex-latex-skip nil "\ Skip the next line (presumably \\end{env}) and indent properly." (interactive) (byte-code "! " [nil next-line 1 end-of-line tex-newline-indent] 4)) (defun tex-latex-putenv (n env &optional arg) (byte-code "i  Wł  \\ Q * Q!+ $j \" ! j," [col n tex-latex-indentation env arg 0 "{" "}" read-string "Arguments to environment " ": " "" insert "\\begin" " " "\\end" beginning-of-line open-line 1] 6)) (defun tex-latex-array (&optional n) (interactive "P") (byte-code "ˆ#" [n t nil tex-latex-putenv "array"] 4)) (defun tex-latex-center (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "center"] 3)) (defun tex-latex-document (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "document"] 3)) (defun tex-latex-description (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "description"] 3)) (defun tex-latex-enumerate (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "enumerate"] 3)) (defun tex-latex-figure (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "figure"] 3)) (defun tex-latex-flushleft (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "flushleft"] 3)) (defun tex-latex-flushright (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "flushright"] 3)) (defun tex-latex-itemize (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "itemize"] 3)) (defun tex-latex-picture (&optional n) (interactive "P") (byte-code "ˆ#" [n t nil tex-latex-putenv "picture"] 4)) (defun tex-latex-quotation (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "quotation"] 3)) (defun tex-latex-quote (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "quote"] 3)) (defun tex-latex-tabbing (&optional n) (interactive "P") (byte-code "ˆ#" [n t nil tex-latex-putenv "tabbing"] 4)) (defun tex-latex-table (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "table"] 3)) (defun tex-latex-tabular (&optional n) (interactive "P") (byte-code "ˆ#" [n t nil tex-latex-putenv "tabular"] 4)) (defun tex-latex-verbatim (&optional n) (interactive "P") (byte-code "\"" [n nil tex-latex-putenv "verbatim"] 3))