yatex
diff yatex19.el @ 46:cd1b63102eed
Support Mule2
author | yuuji |
---|---|
date | Mon, 19 Sep 1994 16:54:19 +0000 |
parents | |
children | d7e7b4654058 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/yatex19.el Mon Sep 19 16:54:19 1994 +0000 1.3 @@ -0,0 +1,261 @@ 1.4 +;;; -*- Emacs-Lisp -*- 1.5 +;;; YaTeX facilities for Emacs 19 1.6 +;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] 1.7 +;;; Last modified Sat Sep 17 12:53:23 1994 on figaro 1.8 +;;; $Id$ 1.9 + 1.10 +;;; $B$H$j$"$($:(B hilit19 $B$r;H$C$F$$$k;~$K?'$,IU$/$h$&$K$7$F(B 1.11 +;;; $B%a%K%e!<%P!<$G$4$K$g$4$K$g$G$-$k$h$&$K$7$?$@$1!#(B 1.12 +;;; $B$$$C$?$$C/$,%a%K%e!<%P!<;H$C$F(BLaTeX$B%=!<%9=q$/$s$@$m$&$+(B? 1.13 +;;; $B$^$"$$$$$dN}=,N}=,!#8e$m$NJ}$K$A$g$C$H%3%a%s%H$"$j!#(B 1.14 + 1.15 +(defun YaTeX-19-define-sub-menu (map vec &rest bindings) 1.16 + "Define sub-menu-item in MAP at vector VEC as BINDINGS. 1.17 +BINDINGS is a form with optional length: (symbol title binding). 1.18 +When you defined menu-bar keymap such like: 1.19 + (define-key foo-map [menu-bar foo] (make-sparse-keymap \"foo menu\")) 1.20 +and you want to define sub menu for `foo menu' as followings. 1.21 + foo -> menu1 (calling function `func1') 1.22 + menu2 (doing interactive call `(func2 ...)' 1.23 +Call this function like this: 1.24 + (YaTeX-19-define-sub-menu foo-map [menu-bar foo] 1.25 + '(m1 \"Function 1\" func1) 1.26 + '(m2 \"Function 2\" (lambda () (interactive) (func2 ...)))) 1.27 +where 1.28 + `m1' and `m2' are the keymap symbol for sub-menu of `[menu-bar foo]. 1.29 + `Funtion 1' and `Function 2' are the title strings for sub-menu. 1.30 +" 1.31 + (let ((i 0) (vec2 (make-vector (1+ (length vec)) nil))) 1.32 + (while (< i (length vec)) 1.33 + (aset vec2 i (aref vec i)) 1.34 + (setq i (1+ i))) 1.35 + (setq bindings (reverse bindings)) 1.36 + (mapcar 1.37 + (function 1.38 + (lambda (bind) 1.39 + (aset vec2 (1- (length vec2)) (car bind)) ;set menu-symbol 1.40 + (define-key map vec2 1.41 + (cons (car (cdr bind)) 1.42 + (car (cdr (cdr bind))))))) 1.43 + bindings))) 1.44 + 1.45 +;; Menu for Typeset relating processes ---------------------------------------- 1.46 +(define-key YaTeX-mode-map [menu-bar yatex] 1.47 + (cons "YaTeX" (make-sparse-keymap "YaTeX"))) 1.48 +(define-key YaTeX-mode-map [menu-bar yatex process] 1.49 + (cons "Process" (make-sparse-keymap "Process"))) 1.50 +(YaTeX-19-define-sub-menu 1.51 + YaTeX-mode-map [menu-bar yatex process] 1.52 + '(buffer "LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?j))) 1.53 + '(kill "Kill LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?k))) 1.54 + '(bibtex "BibTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?b))) 1.55 + '(makeindex "makeindex" (lambda () (interactive) (YaTeX-typeset-menu nil ?i))) 1.56 + '(preview "Preview" (lambda () (interactive) (YaTeX-typeset-menu nil ?p))) 1.57 + '(lpr "lpr" (lambda () (interactive) (YaTeX-typeset-menu nil ?l))) 1.58 + '(lpq "lpq" (lambda () (interactive) (YaTeX-typeset-menu nil ?q))) 1.59 +) 1.60 + 1.61 +;; Help for LaTeX ------------------------------------------------------------ 1.62 +(YaTeX-19-define-sub-menu 1.63 + YaTeX-mode-map [menu-bar yatex] 1.64 + '(sephelp "--") 1.65 + '(help "Help on LaTeX commands" YaTeX-help) 1.66 + '(apropos "Apropos on LaTeX commands" YaTeX-apropos)) 1.67 + 1.68 +;; Switch modes -------------------------------------------------------------- 1.69 +(define-key YaTeX-mode-map [menu-bar yatex switch] 1.70 + (cons "Switching YaTeX's modes" (make-sparse-keymap "modes"))) 1.71 +(or YaTeX-auto-math-mode 1.72 + (define-key YaTeX-mode-map [menu-bar yatex switch math] 1.73 + '("Toggle math mode" . (lambda () (interactive) 1.74 + (YaTeX-switch-mode-menu nil ?t))))) 1.75 +(define-key YaTeX-mode-map [menu-bar yatex switch mod] 1.76 + '("Toggle modify mode" . (lambda () (interactive) 1.77 + (YaTeX-switch-mode-menu nil ?m)))) 1.78 + 1.79 +;; % menu -------------------------------------------------------------------- 1.80 +(define-key YaTeX-mode-map [menu-bar yatex percent] 1.81 + (cons "Edit %# notation" (make-sparse-keymap "Edit %# notation"))) 1.82 +(YaTeX-19-define-sub-menu 1.83 + YaTeX-mode-map [menu-bar yatex percent] 1.84 + '(! "Change LaTeX typesetter(%#!)" 1.85 + (lambda () (interactive) (YaTeX-%-menu nil nil ?!))) 1.86 + '(begend "Set %#BEGIN-%#END on region" 1.87 + (lambda () (interactive) (YaTeX-%-menu nil nil ?b))) 1.88 + '(lpr "Change LPR format" 1.89 + (lambda () (interactive) (YaTeX-%-menu nil nil ?l)))) 1.90 + 1.91 +;; What position ------------------------------------------------------------- 1.92 +(YaTeX-19-define-sub-menu 1.93 + YaTeX-mode-map [menu-bar yatex] 1.94 + '(what "What column in tabular" YaTeX-what-column)) 1.95 + 1.96 +;; Jump cursor --------------------------------------------------------------- 1.97 +(define-key YaTeX-mode-map [menu-bar yatex jump] 1.98 + (cons "Jump cursor" 1.99 + (make-sparse-keymap "Jump cursor"))) 1.100 +(YaTeX-19-define-sub-menu 1.101 + YaTeX-mode-map [menu-bar yatex jump] 1.102 + '(corres "Goto corersponding position" YaTeX-goto-corresponding-*) 1.103 + '(main "Visit main source" (lambda () (interactive) (YaTeX-visit-main))) 1.104 + '(main-other "Visit main source other window" YaTeX-visit-main-other-window) 1.105 + ) 1.106 + 1.107 +;; =========================================================================== 1.108 +(define-key YaTeX-mode-map [menu-bar yatex sepcom] 1.109 + '("---" . nil)) 1.110 + 1.111 +;; Comment/Uncomment --------------------------------------------------------- 1.112 +(YaTeX-19-define-sub-menu 1.113 + YaTeX-mode-map [menu-bar yatex] 1.114 + '(comment "Comment region or environment" YaTeX-comment-region) 1.115 + '(uncomment "Unomment region or environment" YaTeX-uncomment-region) 1.116 + '(commentp "Comment paragraph" YaTeX-comment-paragraph) 1.117 + '(uncommentp "Unomment paragraph" YaTeX-uncomment-paragraph) 1.118 + '(sepcom "--" nil) 1.119 +) 1.120 + 1.121 + 1.122 +;; =========================================================================== 1.123 +;; Change/Kill/Fill 1.124 +(YaTeX-19-define-sub-menu 1.125 + YaTeX-mode-map [menu-bar yatex] 1.126 + '(change "Change macros" YaTeX-change-*) 1.127 + '(kill "Kill macros" YaTeX-kill-*) 1.128 + '(fillitem "Fill \\item" YaTeX-fill-item) 1.129 + '(newline "Newline" YaTeX-intelligent-newline) 1.130 + '(sepchg "--" nil) 1.131 +) 1.132 + 1.133 +;; Menu for completions ------------------------------------------------------ 1.134 + 1.135 + 1.136 +;;;(YaTeX-19-define-sub-menu 1.137 +;;; YaTeX-mode-map [menu-bar yatex] 1.138 +;;; '(secr "Section-type command on region" YaTeX-make-section-region) 1.139 +;;; '(sec "Section-type command" YaTeX-make-section)) 1.140 + 1.141 +(define-key YaTeX-mode-map [menu-bar yatex sectionr] 1.142 + (cons "Section-type region(long name)" 1.143 + (make-sparse-keymap "Enclose region with section-type macro"))) 1.144 +(define-key YaTeX-mode-map [menu-bar yatex section] 1.145 + (cons "Sectio-type(long name)" 1.146 + (make-sparse-keymap "Section-type macro"))) 1.147 +(let ((sorted-section 1.148 + (sort 1.149 + (delq nil 1.150 + (mapcar (function (lambda (s) 1.151 + (if (> (length (car s)) 5) 1.152 + (car s)))) 1.153 + (append section-table user-section-table))) 1.154 + 'string<))) 1.155 + (apply 'YaTeX-19-define-sub-menu 1.156 + YaTeX-mode-map [menu-bar yatex section] 1.157 + (mapcar (function (lambda (secname) 1.158 + (list (intern secname) secname 1.159 + (list 'lambda () 1.160 + (list 'interactive) 1.161 + (list 'YaTeX-make-section 1.162 + nil nil nil secname))))) 1.163 + sorted-section)) 1.164 + (apply 'YaTeX-19-define-sub-menu 1.165 + YaTeX-mode-map [menu-bar yatex sectionr] 1.166 + (mapcar (function (lambda (secname) 1.167 + (list (intern secname) secname 1.168 + (list 'lambda () 1.169 + (list 'interactive) 1.170 + (list 'YaTeX-make-section 1.171 + nil 1.172 + (list 'region-beginning) 1.173 + (list 'region-end) 1.174 + secname))))) 1.175 + sorted-section))) 1.176 + 1.177 +(define-key YaTeX-mode-map [menu-bar yatex envr] 1.178 + (cons "Environment region" (make-sparse-keymap "Environment region"))) 1.179 +(define-key YaTeX-mode-map [menu-bar yatex env] 1.180 + (cons "Environment" (make-sparse-keymap "Environment"))) 1.181 +(let (prev envname) 1.182 + (mapcar 1.183 + (function 1.184 + (lambda (envalist) 1.185 + (setq envname (car envalist)) 1.186 + (define-key-after 1.187 + (lookup-key YaTeX-mode-map [menu-bar yatex env]) 1.188 + (vector (intern envname)) 1.189 + (cons envname 1.190 + (list 'lambda () (list 'interactive) 1.191 + (list 'YaTeX-insert-begin-end 1.192 + envname nil))) 1.193 + prev) 1.194 + (define-key-after 1.195 + (lookup-key YaTeX-mode-map [menu-bar yatex envr]) 1.196 + (vector (intern envname)) 1.197 + (cons envname 1.198 + (list 'lambda () (list 'interactive) 1.199 + (list 'YaTeX-insert-begin-end 1.200 + envname t))) 1.201 + prev) 1.202 + (setq prev (intern envname)))) 1.203 + (sort (append env-table user-env-table) 1.204 + '(lambda (x y) (string< (car x) (car y)))))) 1.205 + 1.206 +;; Highlightening 1.207 +;; $B%m!<%+%k$J%^%/%m$rFI$_9~$s$@8e(B redraw $B$9$k$H(B 1.208 +;; $B%m!<%+%k%^%/%m$r(B keyword $B$H$7$F8w$i$;$k(B(keyword$B$8$c$^$:$$$+$J!D(B)$B!#(B 1.209 +(defvar YaTeX-hilit-pattern-adjustment 1.210 + (list 1.211 + ;;\def $B$,(B define $B$J$s$@$+$i(B new* $B$b(B define $B$G$7$g$&!#(B 1.212 + '("\\\\\\(re\\)?new\\(environment\\|command\\){" "}" define) 1.213 + '("\\\\new\\(length\\|theorem\\|counter\\){" "}" define) 1.214 + ;;$B%;%/%7%g%s%3%^%s%I$,C1$J$k%-!<%o!<%I$C$F$3$H$O$J$$$G$7$g$&!#(B 1.215 + (list 1.216 + (concat "\\\\\\(" YaTeX-sectioning-regexp "\\){") "}" 1.217 + 'sectioning)) 1.218 + "Adjustment for hilit19's LaTeX hilit pattern.") 1.219 +(defvar YaTeX-hilit-sectioning-face 1.220 + 'yellow/cornflowerblue) 1.221 +(defun YaTeX-19-collect-macro () 1.222 + (cond 1.223 + ((and (featurep 'hilit19) (fboundp 'hilit-translate)) 1.224 + (hilit-translate sectioning YaTeX-hilit-sectioning-face) 1.225 + (setq hilit-patterns-alist ;Remove at the first time. 1.226 + (delq 'yatex-mode hilit-patterns-alist) 1.227 + hilit-patterns-alist 1.228 + (cons 1.229 + (cons 'yatex-mode 1.230 + (append 1.231 + YaTeX-hilit-pattern-adjustment 1.232 + (cdr (assq 'latex-mode hilit-patterns-alist)) 1.233 + (list 1.234 + (list 1.235 + (concat "\\\\\\(" 1.236 + (mapconcat 1.237 + (function (lambda (s) (regexp-quote (car s)))) 1.238 + (append user-section-table tmp-section-table) 1.239 + "\\|") 1.240 + "\\){") 1.241 + "}" 'keyword)))) 1.242 + hilit-patterns-alist))))) 1.243 +(YaTeX-19-collect-macro) 1.244 +(defun YaTeX-hilit-recenter (arg) 1.245 + "Collect current local macro and hilit-recenter." 1.246 + (interactive "P") 1.247 + (YaTeX-19-collect-macro) 1.248 + (hilit-recenter arg)) 1.249 +(if (fboundp 'hilit-recenter) ;Replace hilit-recenter with 1.250 + (mapcar (function (lambda (key) ;YaTeX-hilit-recenter in yatex-mode 1.251 + (define-key YaTeX-mode-map key 'YaTeX-hilit-recenter))) 1.252 + (where-is-internal 'hilit-recenter))) 1.253 + 1.254 +;;; reverseVideo $B$K$7$F(B hilit-background-mode $B$r(B 'dark 1.255 +;;; $B$K$7$F$$$k?M$O?t<0$J$I$,0E$/$J$j$9$.$F8+$E$i$$$+$b$7$l$J$$!#(B 1.256 +;;; $B<!$N%3!<%I$r(B hilit19 $B$r%m!<%I$7$F$$$k>l=j$ND>8e$KCV$/$H$A$g$C(B 1.257 +;;; $B$H$O$^$7!#(B 1.258 +;;; (if (eq hilit-background-mode 'dark) 1.259 +;;; (hilit-translate 1.260 +;;; string 'mediumspringgreen 1.261 +;;; formula 'khaki 1.262 +;;; label 'yellow-underlined)) 1.263 + 1.264 +(provide 'yatex19)