yatex

annotate yatex19.el @ 46:cd1b63102eed

Support Mule2
author yuuji
date Mon, 19 Sep 1994 16:54:19 +0000
parents
children d7e7b4654058
rev   line source
yuuji@46 1 ;;; -*- Emacs-Lisp -*-
yuuji@46 2 ;;; YaTeX facilities for Emacs 19
yuuji@46 3 ;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
yuuji@46 4 ;;; Last modified Sat Sep 17 12:53:23 1994 on figaro
yuuji@46 5 ;;; $Id$
yuuji@46 6
yuuji@46 7 ;;; $B$H$j$"$($:(B hilit19 $B$r;H$C$F$$$k;~$K?'$,IU$/$h$&$K$7$F(B
yuuji@46 8 ;;; $B%a%K%e!<%P!<$G$4$K$g$4$K$g$G$-$k$h$&$K$7$?$@$1!#(B
yuuji@46 9 ;;; $B$$$C$?$$C/$,%a%K%e!<%P!<;H$C$F(BLaTeX$B%=!<%9=q$/$s$@$m$&$+(B?
yuuji@46 10 ;;; $B$^$"$$$$$dN}=,N}=,!#8e$m$NJ}$K$A$g$C$H%3%a%s%H$"$j!#(B
yuuji@46 11
yuuji@46 12 (defun YaTeX-19-define-sub-menu (map vec &rest bindings)
yuuji@46 13 "Define sub-menu-item in MAP at vector VEC as BINDINGS.
yuuji@46 14 BINDINGS is a form with optional length: (symbol title binding).
yuuji@46 15 When you defined menu-bar keymap such like:
yuuji@46 16 (define-key foo-map [menu-bar foo] (make-sparse-keymap \"foo menu\"))
yuuji@46 17 and you want to define sub menu for `foo menu' as followings.
yuuji@46 18 foo -> menu1 (calling function `func1')
yuuji@46 19 menu2 (doing interactive call `(func2 ...)'
yuuji@46 20 Call this function like this:
yuuji@46 21 (YaTeX-19-define-sub-menu foo-map [menu-bar foo]
yuuji@46 22 '(m1 \"Function 1\" func1)
yuuji@46 23 '(m2 \"Function 2\" (lambda () (interactive) (func2 ...))))
yuuji@46 24 where
yuuji@46 25 `m1' and `m2' are the keymap symbol for sub-menu of `[menu-bar foo].
yuuji@46 26 `Funtion 1' and `Function 2' are the title strings for sub-menu.
yuuji@46 27 "
yuuji@46 28 (let ((i 0) (vec2 (make-vector (1+ (length vec)) nil)))
yuuji@46 29 (while (< i (length vec))
yuuji@46 30 (aset vec2 i (aref vec i))
yuuji@46 31 (setq i (1+ i)))
yuuji@46 32 (setq bindings (reverse bindings))
yuuji@46 33 (mapcar
yuuji@46 34 (function
yuuji@46 35 (lambda (bind)
yuuji@46 36 (aset vec2 (1- (length vec2)) (car bind)) ;set menu-symbol
yuuji@46 37 (define-key map vec2
yuuji@46 38 (cons (car (cdr bind))
yuuji@46 39 (car (cdr (cdr bind)))))))
yuuji@46 40 bindings)))
yuuji@46 41
yuuji@46 42 ;; Menu for Typeset relating processes ----------------------------------------
yuuji@46 43 (define-key YaTeX-mode-map [menu-bar yatex]
yuuji@46 44 (cons "YaTeX" (make-sparse-keymap "YaTeX")))
yuuji@46 45 (define-key YaTeX-mode-map [menu-bar yatex process]
yuuji@46 46 (cons "Process" (make-sparse-keymap "Process")))
yuuji@46 47 (YaTeX-19-define-sub-menu
yuuji@46 48 YaTeX-mode-map [menu-bar yatex process]
yuuji@46 49 '(buffer "LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?j)))
yuuji@46 50 '(kill "Kill LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?k)))
yuuji@46 51 '(bibtex "BibTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?b)))
yuuji@46 52 '(makeindex "makeindex" (lambda () (interactive) (YaTeX-typeset-menu nil ?i)))
yuuji@46 53 '(preview "Preview" (lambda () (interactive) (YaTeX-typeset-menu nil ?p)))
yuuji@46 54 '(lpr "lpr" (lambda () (interactive) (YaTeX-typeset-menu nil ?l)))
yuuji@46 55 '(lpq "lpq" (lambda () (interactive) (YaTeX-typeset-menu nil ?q)))
yuuji@46 56 )
yuuji@46 57
yuuji@46 58 ;; Help for LaTeX ------------------------------------------------------------
yuuji@46 59 (YaTeX-19-define-sub-menu
yuuji@46 60 YaTeX-mode-map [menu-bar yatex]
yuuji@46 61 '(sephelp "--")
yuuji@46 62 '(help "Help on LaTeX commands" YaTeX-help)
yuuji@46 63 '(apropos "Apropos on LaTeX commands" YaTeX-apropos))
yuuji@46 64
yuuji@46 65 ;; Switch modes --------------------------------------------------------------
yuuji@46 66 (define-key YaTeX-mode-map [menu-bar yatex switch]
yuuji@46 67 (cons "Switching YaTeX's modes" (make-sparse-keymap "modes")))
yuuji@46 68 (or YaTeX-auto-math-mode
yuuji@46 69 (define-key YaTeX-mode-map [menu-bar yatex switch math]
yuuji@46 70 '("Toggle math mode" . (lambda () (interactive)
yuuji@46 71 (YaTeX-switch-mode-menu nil ?t)))))
yuuji@46 72 (define-key YaTeX-mode-map [menu-bar yatex switch mod]
yuuji@46 73 '("Toggle modify mode" . (lambda () (interactive)
yuuji@46 74 (YaTeX-switch-mode-menu nil ?m))))
yuuji@46 75
yuuji@46 76 ;; % menu --------------------------------------------------------------------
yuuji@46 77 (define-key YaTeX-mode-map [menu-bar yatex percent]
yuuji@46 78 (cons "Edit %# notation" (make-sparse-keymap "Edit %# notation")))
yuuji@46 79 (YaTeX-19-define-sub-menu
yuuji@46 80 YaTeX-mode-map [menu-bar yatex percent]
yuuji@46 81 '(! "Change LaTeX typesetter(%#!)"
yuuji@46 82 (lambda () (interactive) (YaTeX-%-menu nil nil ?!)))
yuuji@46 83 '(begend "Set %#BEGIN-%#END on region"
yuuji@46 84 (lambda () (interactive) (YaTeX-%-menu nil nil ?b)))
yuuji@46 85 '(lpr "Change LPR format"
yuuji@46 86 (lambda () (interactive) (YaTeX-%-menu nil nil ?l))))
yuuji@46 87
yuuji@46 88 ;; What position -------------------------------------------------------------
yuuji@46 89 (YaTeX-19-define-sub-menu
yuuji@46 90 YaTeX-mode-map [menu-bar yatex]
yuuji@46 91 '(what "What column in tabular" YaTeX-what-column))
yuuji@46 92
yuuji@46 93 ;; Jump cursor ---------------------------------------------------------------
yuuji@46 94 (define-key YaTeX-mode-map [menu-bar yatex jump]
yuuji@46 95 (cons "Jump cursor"
yuuji@46 96 (make-sparse-keymap "Jump cursor")))
yuuji@46 97 (YaTeX-19-define-sub-menu
yuuji@46 98 YaTeX-mode-map [menu-bar yatex jump]
yuuji@46 99 '(corres "Goto corersponding position" YaTeX-goto-corresponding-*)
yuuji@46 100 '(main "Visit main source" (lambda () (interactive) (YaTeX-visit-main)))
yuuji@46 101 '(main-other "Visit main source other window" YaTeX-visit-main-other-window)
yuuji@46 102 )
yuuji@46 103
yuuji@46 104 ;; ===========================================================================
yuuji@46 105 (define-key YaTeX-mode-map [menu-bar yatex sepcom]
yuuji@46 106 '("---" . nil))
yuuji@46 107
yuuji@46 108 ;; Comment/Uncomment ---------------------------------------------------------
yuuji@46 109 (YaTeX-19-define-sub-menu
yuuji@46 110 YaTeX-mode-map [menu-bar yatex]
yuuji@46 111 '(comment "Comment region or environment" YaTeX-comment-region)
yuuji@46 112 '(uncomment "Unomment region or environment" YaTeX-uncomment-region)
yuuji@46 113 '(commentp "Comment paragraph" YaTeX-comment-paragraph)
yuuji@46 114 '(uncommentp "Unomment paragraph" YaTeX-uncomment-paragraph)
yuuji@46 115 '(sepcom "--" nil)
yuuji@46 116 )
yuuji@46 117
yuuji@46 118
yuuji@46 119 ;; ===========================================================================
yuuji@46 120 ;; Change/Kill/Fill
yuuji@46 121 (YaTeX-19-define-sub-menu
yuuji@46 122 YaTeX-mode-map [menu-bar yatex]
yuuji@46 123 '(change "Change macros" YaTeX-change-*)
yuuji@46 124 '(kill "Kill macros" YaTeX-kill-*)
yuuji@46 125 '(fillitem "Fill \\item" YaTeX-fill-item)
yuuji@46 126 '(newline "Newline" YaTeX-intelligent-newline)
yuuji@46 127 '(sepchg "--" nil)
yuuji@46 128 )
yuuji@46 129
yuuji@46 130 ;; Menu for completions ------------------------------------------------------
yuuji@46 131
yuuji@46 132
yuuji@46 133 ;;;(YaTeX-19-define-sub-menu
yuuji@46 134 ;;; YaTeX-mode-map [menu-bar yatex]
yuuji@46 135 ;;; '(secr "Section-type command on region" YaTeX-make-section-region)
yuuji@46 136 ;;; '(sec "Section-type command" YaTeX-make-section))
yuuji@46 137
yuuji@46 138 (define-key YaTeX-mode-map [menu-bar yatex sectionr]
yuuji@46 139 (cons "Section-type region(long name)"
yuuji@46 140 (make-sparse-keymap "Enclose region with section-type macro")))
yuuji@46 141 (define-key YaTeX-mode-map [menu-bar yatex section]
yuuji@46 142 (cons "Sectio-type(long name)"
yuuji@46 143 (make-sparse-keymap "Section-type macro")))
yuuji@46 144 (let ((sorted-section
yuuji@46 145 (sort
yuuji@46 146 (delq nil
yuuji@46 147 (mapcar (function (lambda (s)
yuuji@46 148 (if (> (length (car s)) 5)
yuuji@46 149 (car s))))
yuuji@46 150 (append section-table user-section-table)))
yuuji@46 151 'string<)))
yuuji@46 152 (apply 'YaTeX-19-define-sub-menu
yuuji@46 153 YaTeX-mode-map [menu-bar yatex section]
yuuji@46 154 (mapcar (function (lambda (secname)
yuuji@46 155 (list (intern secname) secname
yuuji@46 156 (list 'lambda ()
yuuji@46 157 (list 'interactive)
yuuji@46 158 (list 'YaTeX-make-section
yuuji@46 159 nil nil nil secname)))))
yuuji@46 160 sorted-section))
yuuji@46 161 (apply 'YaTeX-19-define-sub-menu
yuuji@46 162 YaTeX-mode-map [menu-bar yatex sectionr]
yuuji@46 163 (mapcar (function (lambda (secname)
yuuji@46 164 (list (intern secname) secname
yuuji@46 165 (list 'lambda ()
yuuji@46 166 (list 'interactive)
yuuji@46 167 (list 'YaTeX-make-section
yuuji@46 168 nil
yuuji@46 169 (list 'region-beginning)
yuuji@46 170 (list 'region-end)
yuuji@46 171 secname)))))
yuuji@46 172 sorted-section)))
yuuji@46 173
yuuji@46 174 (define-key YaTeX-mode-map [menu-bar yatex envr]
yuuji@46 175 (cons "Environment region" (make-sparse-keymap "Environment region")))
yuuji@46 176 (define-key YaTeX-mode-map [menu-bar yatex env]
yuuji@46 177 (cons "Environment" (make-sparse-keymap "Environment")))
yuuji@46 178 (let (prev envname)
yuuji@46 179 (mapcar
yuuji@46 180 (function
yuuji@46 181 (lambda (envalist)
yuuji@46 182 (setq envname (car envalist))
yuuji@46 183 (define-key-after
yuuji@46 184 (lookup-key YaTeX-mode-map [menu-bar yatex env])
yuuji@46 185 (vector (intern envname))
yuuji@46 186 (cons envname
yuuji@46 187 (list 'lambda () (list 'interactive)
yuuji@46 188 (list 'YaTeX-insert-begin-end
yuuji@46 189 envname nil)))
yuuji@46 190 prev)
yuuji@46 191 (define-key-after
yuuji@46 192 (lookup-key YaTeX-mode-map [menu-bar yatex envr])
yuuji@46 193 (vector (intern envname))
yuuji@46 194 (cons envname
yuuji@46 195 (list 'lambda () (list 'interactive)
yuuji@46 196 (list 'YaTeX-insert-begin-end
yuuji@46 197 envname t)))
yuuji@46 198 prev)
yuuji@46 199 (setq prev (intern envname))))
yuuji@46 200 (sort (append env-table user-env-table)
yuuji@46 201 '(lambda (x y) (string< (car x) (car y))))))
yuuji@46 202
yuuji@46 203 ;; Highlightening
yuuji@46 204 ;; $B%m!<%+%k$J%^%/%m$rFI$_9~$s$@8e(B redraw $B$9$k$H(B
yuuji@46 205 ;; $B%m!<%+%k%^%/%m$r(B keyword $B$H$7$F8w$i$;$k(B(keyword$B$8$c$^$:$$$+$J!D(B)$B!#(B
yuuji@46 206 (defvar YaTeX-hilit-pattern-adjustment
yuuji@46 207 (list
yuuji@46 208 ;;\def $B$,(B define $B$J$s$@$+$i(B new* $B$b(B define $B$G$7$g$&!#(B
yuuji@46 209 '("\\\\\\(re\\)?new\\(environment\\|command\\){" "}" define)
yuuji@46 210 '("\\\\new\\(length\\|theorem\\|counter\\){" "}" define)
yuuji@46 211 ;;$B%;%/%7%g%s%3%^%s%I$,C1$J$k%-!<%o!<%I$C$F$3$H$O$J$$$G$7$g$&!#(B
yuuji@46 212 (list
yuuji@46 213 (concat "\\\\\\(" YaTeX-sectioning-regexp "\\){") "}"
yuuji@46 214 'sectioning))
yuuji@46 215 "Adjustment for hilit19's LaTeX hilit pattern.")
yuuji@46 216 (defvar YaTeX-hilit-sectioning-face
yuuji@46 217 'yellow/cornflowerblue)
yuuji@46 218 (defun YaTeX-19-collect-macro ()
yuuji@46 219 (cond
yuuji@46 220 ((and (featurep 'hilit19) (fboundp 'hilit-translate))
yuuji@46 221 (hilit-translate sectioning YaTeX-hilit-sectioning-face)
yuuji@46 222 (setq hilit-patterns-alist ;Remove at the first time.
yuuji@46 223 (delq 'yatex-mode hilit-patterns-alist)
yuuji@46 224 hilit-patterns-alist
yuuji@46 225 (cons
yuuji@46 226 (cons 'yatex-mode
yuuji@46 227 (append
yuuji@46 228 YaTeX-hilit-pattern-adjustment
yuuji@46 229 (cdr (assq 'latex-mode hilit-patterns-alist))
yuuji@46 230 (list
yuuji@46 231 (list
yuuji@46 232 (concat "\\\\\\("
yuuji@46 233 (mapconcat
yuuji@46 234 (function (lambda (s) (regexp-quote (car s))))
yuuji@46 235 (append user-section-table tmp-section-table)
yuuji@46 236 "\\|")
yuuji@46 237 "\\){")
yuuji@46 238 "}" 'keyword))))
yuuji@46 239 hilit-patterns-alist)))))
yuuji@46 240 (YaTeX-19-collect-macro)
yuuji@46 241 (defun YaTeX-hilit-recenter (arg)
yuuji@46 242 "Collect current local macro and hilit-recenter."
yuuji@46 243 (interactive "P")
yuuji@46 244 (YaTeX-19-collect-macro)
yuuji@46 245 (hilit-recenter arg))
yuuji@46 246 (if (fboundp 'hilit-recenter) ;Replace hilit-recenter with
yuuji@46 247 (mapcar (function (lambda (key) ;YaTeX-hilit-recenter in yatex-mode
yuuji@46 248 (define-key YaTeX-mode-map key 'YaTeX-hilit-recenter)))
yuuji@46 249 (where-is-internal 'hilit-recenter)))
yuuji@46 250
yuuji@46 251 ;;; reverseVideo $B$K$7$F(B hilit-background-mode $B$r(B 'dark
yuuji@46 252 ;;; $B$K$7$F$$$k?M$O?t<0$J$I$,0E$/$J$j$9$.$F8+$E$i$$$+$b$7$l$J$$!#(B
yuuji@46 253 ;;; $B<!$N%3!<%I$r(B hilit19 $B$r%m!<%I$7$F$$$k>l=j$ND>8e$KCV$/$H$A$g$C(B
yuuji@46 254 ;;; $B$H$O$^$7!#(B
yuuji@46 255 ;;; (if (eq hilit-background-mode 'dark)
yuuji@46 256 ;;; (hilit-translate
yuuji@46 257 ;;; string 'mediumspringgreen
yuuji@46 258 ;;; formula 'khaki
yuuji@46 259 ;;; label 'yellow-underlined))
yuuji@46 260
yuuji@46 261 (provide 'yatex19)