yatex
changeset 3:191610912c8b
Add comment out region/paragraph.
Add YaTeX-goto-corresponding-environment.
author | yuuji |
---|---|
date | Thu, 19 Nov 1992 02:27:25 +0000 |
parents | a61027172238 |
children | 78dfe28b6a35 |
files | yatex.el yatex.new |
diffstat | 2 files changed, 178 insertions(+), 17 deletions(-) [+] |
line diff
1.1 --- a/yatex.el Wed Jul 22 19:45:22 1992 +0000 1.2 +++ b/yatex.el Thu Nov 19 02:27:25 1992 +0000 1.3 @@ -1,11 +1,12 @@ 1.4 ;;; -*- Emacs-Lisp -*- 1.5 ;;; Yet Another tex-mode for emacs. 1.6 -;;; yatex.el rev.1.28 1.7 +;;; yatex.el rev.1.32 1.8 ;;; (c)1991 by Hirose Yuuji.[yuuji@ae.keio.ac.jp] 1.9 -;;; Last modified Mon Jul 20 21:46:13 1992 on figaro 1.10 +;;; Last modified Tue Nov 17 01:01:12 1992 on 98fa 1.11 1.12 (provide 'yatex-mode) 1.13 -(defconst YaTeX-revision-number "1.28" 1.14 +(require 'comment) 1.15 +(defconst YaTeX-revision-number "1.32" 1.16 "Revision number of running yatex.el" 1.17 ) 1.18 1.19 @@ -51,8 +52,7 @@ 1.20 command stops at this error message with line number of LaTeX source text." 1.21 ) 1.22 (defvar latex-dos-emergency-message 1.23 - ;;"Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 1.24 - "No pages of output." ;<- for ASCII-pTeX 1.7 1.25 + "Emergency stop" ;<- for Micro tex, ASCII-pTeX 1.6 1.26 "Because Demacs (GNU Emacs on DOS) cannot have pararell process, the 1.27 latex command which is stopping on a LaTeX error, is terminated by Demacs. 1.28 Many latex command on DOS display some message when it is terminated by 1.29 @@ -69,7 +69,7 @@ 1.30 ("author") ("documentstyle") ("pagestyle") 1.31 ("documentstyle[10pt]") ("documentstyle[11pt]") 1.32 ("documentstyle[12pt]") 1.33 - ("item[]") ("title") ("chapter") ("part") ("paragraph") 1.34 + ("title") ("chapter") ("part") ("paragraph") 1.35 ("subparagraph") ("underline") ("label") ("footnote") 1.36 ("hspace*") ("vspace*") ("bibliography") ("bibitem[]") ("cite[]") 1.37 ("nocite") ("input") ("include") ("includeonly") ("mbox") ("hbox") 1.38 @@ -117,7 +117,7 @@ 1.39 ("sigma") ("varsigma") ("tau") ("upsilon") ("phi") ("varphi") 1.40 ("chi") ("psi") ("omega") ("Gamma") ("Delta") ("Theta") ("Lambda") 1.41 ("Xi") ("Pi") ("Sigma") ("Upsilon") ("Phi") ("Psi") ("Omega") 1.42 - ("LaTeX") ("TeX") 1.43 + ("LaTeX") ("TeX") ("item[]") 1.44 )) 1.45 (defvar user-singlecmd-table nil) 1.46 1.47 @@ -213,10 +213,20 @@ 1.48 (define-key YaTeX-mode-map (concat YaTeX-prefix "BQ") 1.49 '(lambda () (interactive) 1.50 (YaTeX-insert-begin-end "quotation" t))) 1.51 + (define-key YaTeX-mode-map (concat YaTeX-prefix ".") 1.52 + 'YaTeX-comment-paragraph) 1.53 + (define-key YaTeX-mode-map (concat YaTeX-prefix ",") 1.54 + 'YaTeX-uncomment-paragraph) 1.55 + (define-key YaTeX-mode-map (concat YaTeX-prefix ">") 1.56 + '(lambda () (interactive) (comment-region "%"))) 1.57 + (define-key YaTeX-mode-map (concat YaTeX-prefix "<") 1.58 + '(lambda () (interactive) (uncomment-region "%"))) 1.59 (define-key YaTeX-mode-map (concat YaTeX-prefix "b ") 1.60 'YaTeX-make-begin-end) 1.61 (define-key YaTeX-mode-map (concat YaTeX-prefix "B ") 1.62 'YaTeX-make-begin-end-region) 1.63 + (define-key YaTeX-mode-map (concat YaTeX-prefix "e") 1.64 + 'YaTeX-end-environment) 1.65 (define-key YaTeX-mode-map (concat YaTeX-prefix "s") 1.66 'YaTeX-make-section) 1.67 (define-key YaTeX-mode-map (concat YaTeX-prefix "l") 1.68 @@ -225,12 +235,14 @@ 1.69 'YaTeX-make-fontsize-region) 1.70 (define-key YaTeX-mode-map (concat YaTeX-prefix "m") 1.71 'YaTeX-make-singlecmd) 1.72 + (define-key YaTeX-mode-map (concat YaTeX-prefix "g") 1.73 + 'YaTeX-goto-corresponding-environment) 1.74 (define-key YaTeX-mode-map (concat YaTeX-prefix "\C-m") 1.75 '(lambda () (interactive) (YaTeX-insert-string "\\\\"))) 1.76 (if (eq system-type 'ms-dos) 1.77 (define-key YaTeX-mode-map (concat YaTeX-prefix "\^L") 1.78 '(lambda () (interactive) 1.79 - (set-screen-height 24) (recenter)))) 1.80 + (set-screen-height YaTeX-saved-screen-height) (recenter)))) 1.81 ) 1.82 1.83 (if YaTeX-compilation-mode-map nil 1.84 @@ -277,7 +289,7 @@ 1.85 fill-prefix YaTeX-fill-prefix) 1.86 (use-local-map YaTeX-mode-map) 1.87 (if (eq system-type 'ms-dos) 1.88 - (set-screen-height 24)) 1.89 + (setq YaTeX-saved-screen-height (screen-height))) 1.90 (if YaTeX-user-table-has-read nil 1.91 (YaTeX-read-user-completion-table) 1.92 (setq YaTeX-user-table-has-read t)) 1.93 @@ -339,6 +351,51 @@ 1.94 (YaTeX-make-begin-end t) 1.95 ) 1.96 1.97 +(defun YaTeX-end-environment () 1.98 + "Close opening environment" 1.99 + (interactive) 1.100 + (let ((curp (point)) 1.101 + (s)(env nil)(nest 0)) 1.102 + (save-excursion 1.103 + (while 1.104 + (and 1.105 + (>= nest 0) 1.106 + (re-search-backward 1.107 + "^[^\\%]*\\(\\\\begin{.*}\\)\\|\\(\\\\end{.*}\\)" (point-min) t)) 1.108 + (setq nest (if (re-search-forward "begin{" (match-end 0) t) 1.109 + (1- nest) (1+ nest)))) 1.110 + (if (>= nest 0) 1.111 + (message "No premature environment") 1.112 + (goto-char (match-end 0)) 1.113 + (setq s (point)) 1.114 + (skip-chars-forward "0-9_A-z") 1.115 + (setq env (buffer-substring s (point))) 1.116 + ;;(recursive-edit) 1.117 + )) 1.118 + (if (null env) nil 1.119 + (save-excursion 1.120 + (if (and (re-search-forward "^[^\\%]*\\\\end{.*}" (point-max) t) 1.121 + (progn (goto-char (match-beginning 0)) 1.122 + (re-search-forward env (match-end 0) t))) 1.123 + (if (y-or-n-p 1.124 + (concat "Environment `" env 1.125 + "' was already closed. Force close?")) 1.126 + nil 1.127 + (setq env nil)))) 1.128 + (message "") ;Erase (y or n) message. 1.129 + (if (null env) nil 1.130 + (insert "\\end{" env "}") 1.131 + (setq curp (point)) 1.132 + (goto-char s) 1.133 + (if (pos-visible-in-window-p) 1.134 + (sit-for 1) 1.135 + (message (concat "Matches \\begin{" env 1.136 + (format "} at line %d" 1.137 + (count-lines (point-min) s))))) 1.138 + (goto-char curp))) 1.139 + ) 1.140 +) 1.141 + 1.142 (defun YaTeX-make-section (arg) 1.143 "Make LaTeX \\section{} type command with completing read. 1.144 With ARG of numeric, you can specify the number of argument of 1.145 @@ -633,7 +690,8 @@ 1.146 (interactive 1.147 (list (read-string "Preview command: " dvi2-command) 1.148 (read-string "Prefiew file[.dvi]: " 1.149 - (substring (buffer-name) 0 -4) 1.150 + ;;(substring (buffer-name) 0 -4) 1.151 + (YaTeX-get-preview-file-name) ;ver 1.31 1.152 ))) 1.153 (setq dvi2-command preview-command) 1.154 (with-output-to-temp-buffer "*dvi-preview*" 1.155 @@ -748,6 +806,18 @@ 1.156 (widen))) 1.157 ) 1.158 1.159 +(defun YaTeX-get-preview-file-name () 1.160 + "Get file name to preview by inquiring YaTeX-get-latex-command" 1.161 + (let* ((latex-cmd (YaTeX-get-latex-command)) 1.162 + (fname (substring latex-cmd (1+ (rindex latex-cmd ? )))) 1.163 + (period)) 1.164 + (if (eq fname "") 1.165 + (setq fname (substring (buffer-name) 0 -4)) 1.166 + (setq period (rindex fname ?.)) 1.167 + (setq fname (substring fname 0 (if (eq -1 period) nil period))) 1.168 + )) 1.169 +) 1.170 + 1.171 (defun YaTeX-get-latex-command () 1.172 "Specify the latex-command name and its argument. 1.173 If there is a line which begins by string: \"%#!\", the following 1.174 @@ -781,6 +851,51 @@ 1.175 )))) 1.176 ) 1.177 1.178 +(defun YaTeX-goto-corresponding-environment () 1.179 + "Go to corresponding begin/end enclosure." 1.180 + (interactive) 1.181 + (beginning-of-line) 1.182 + (if (not (re-search-forward 1.183 + "\\(begin{\\)\\|\\(end{\\)" (point-end-of-line) t)) 1.184 + (error "No environment declaration")) 1.185 + (let ((p (point) env) 1.186 + (m0 (match-beginning 0)) 1.187 + (m1 (match-beginning 1)) 1.188 + (m2 (match-beginning 2))) 1.189 + (if (not (re-search-forward "}" (point-end-of-line) t)) 1.190 + (error "Unterminated brackets for begin/end")) 1.191 + (setq env (buffer-substring p (match-beginning 0))) ;get current env 1.192 + (cond 1.193 + ((equal m0 m1) ;if begin{xxx} 1.194 + (re-search-forward (concat "end{" env "}"))) 1.195 + ((equal m0 m2) ;if end{xxx} 1.196 + (re-search-backward (concat "begin{" env "}"))) 1.197 + ) 1.198 + (beginning-of-line) 1.199 + );let 1.200 +) 1.201 + 1.202 +(defun YaTeX-comment-paragraph () 1.203 + "Comment out current paragraph." 1.204 + (interactive) 1.205 + (save-excursion 1.206 + (mark-paragraph) 1.207 + (if (not (bobp)) (forward-line 1)) 1.208 + (comment-region "%")) 1.209 +) 1.210 + 1.211 +(defun YaTeX-uncomment-paragraph () 1.212 + "Uncomment current paragraph." 1.213 + (interactive) 1.214 + (save-excursion 1.215 + (let ((prefix fill-prefix)) 1.216 + (setq fill-prefix "") 1.217 + (mark-paragraph) 1.218 + (if (not (bobp)) (forward-line 1)) 1.219 + (uncomment-region "%") 1.220 + (setq fill-prefix prefix))) 1.221 +) 1.222 + 1.223 (defun YaTeX-read-user-completion-table () 1.224 "Append user completion table of LaTeX word" 1.225 (message "Loading personal completion table") 1.226 @@ -837,6 +952,38 @@ 1.227 (message "") 1.228 ) 1.229 1.230 +;; --------------- General sub functions --------------- 1.231 + 1.232 +;(defun index (string char) 1.233 +; (let ((pos 0)(len (1- (length string)))(index -1)) 1.234 +; (while (<= pos len) 1.235 +; (cond 1.236 +; ((= (aref string pos) char) 1.237 +; (setq index pos) (setq pos len)) 1.238 +; (t (setq pos (1+ pos)))) 1.239 +; ) 1.240 +; index) 1.241 +;) 1.242 + 1.243 +(defun rindex (string char) 1.244 + (let ((pos (1- (length string)))(index -1)) 1.245 + (while (>= pos 0) 1.246 + (cond 1.247 + ((= (aref string pos) char) 1.248 + (setq index pos) (setq pos -1)) 1.249 + (t (setq pos (1- pos)))) 1.250 + ) 1.251 + index) 1.252 +) 1.253 + 1.254 +(defun point-beginning-of-line () 1.255 + (save-excursion (beginning-of-line)(point)) 1.256 +) 1.257 + 1.258 +(defun point-end-of-line () 1.259 + (save-excursion (end-of-line)(point)) 1.260 +) 1.261 + 1.262 (defun append-to-hook (hook hook-list) 1.263 "Add hook-list to certain emacs's hook correctly. 1.264 Argument hook-list is the list of function int the form to be called 1.265 @@ -883,13 +1030,18 @@ 1.266 ; 1.23 | 92/ 1/ 8 | Enable latex and preview command on DOS. 1.267 ; 1.24 | 1/ 9 | Add YaTeX-save-table to kill-emacs-hook automatically. 1.268 ; 1.25 | 1/16 | YaTeX-do-completion (prefix+SPC) and argument 1.269 -; | | acceptable YaTeX-make-section work. Put region into 1.270 +; | | acceptable YaTeX-make-section works. Put region into 1.271 ; | | \begin...\end by calling YaTeX-make-begin-end with ARG. 1.272 ; | | append-kill-emacs-hook was revised to append-to-hook. 1.273 ; 1.26 | 1/18 | Region mode is added to {\large }. Default fontsize. 1.274 -; 1.27 | 1/21 | Default name on completing-read, 1.275 +; 1.27 | 1/21 | Default name on completing-read. 1.276 ; 1.28 | 7/ 2 | Add \nonstopmode{} automatically on DOS. 1.277 ; | 7/20 | %#! usage to specify latex command and its arguments. 1.278 +; | | Change default fill-prefix from TAB to null string. 1.279 +; 1.29 | 7/21 | Add YaTeX-end-environment. 1.280 +; 1.30 | 9/26 | Support project 30 lines(other than 25 lines). 1.281 +; 1.31 | 10/28 | Variable argument for previewer from %#! usage. 1.282 +; 1.32 | 10/16 | YaTeX-goto-corresponding-environment. 1.283 ;------+----------+--------------------------------------------------------- 1.284 ; 1.285 ;----------------------------- End of yatex.el -----------------------------
2.1 --- a/yatex.new Wed Jul 22 19:45:22 1992 +0000 2.2 +++ b/yatex.new Thu Nov 19 02:27:25 1992 +0000 2.3 @@ -1,8 +1,17 @@ 2.4 2.5 - Yet Another tex-mode for Emacs. 2.6 - yatex.el $@3F%P!<%8%g%s$NJQ99E@(J 2.7 + Yet Another tex-mode for Emacs 2.8 + yatex.el 各バージョンの変更点について。 2.9 2.10 -1.28: %#! $@$K$h$j!"5/F0$9$k(J latex $@%3%^%s%I$r;XDj$G$-$k$h$&$K$7$?!#(J 2.11 - $@%G%U%)%k%H$N(J fill-prefix $@$r(J "" (null strings) $@$K$7$?!#(J 2.12 +1.32: リジョン/パラグラフをコメントアウトする機能を追加 2.13 + 対応する \begin{}/\end{} 間でジャンプする機能を追加 2.14 2.15 -1.27: $@@5<0%j%j!<%9(J 2.16 +1.31: Previewer に渡すデフォルトのファイル名も %#! に指定したものを使用 2.17 + 2.18 +1.30: 30行計画に対応(要するに行数可変にした) 2.19 + 2.20 +1.29: 現在開いている環境名を閉じる YaTeX-end-environment を追加 2.21 + 2.22 +1.28: %#! に続くコマンド名を latex コマンドとして実行するようにした 2.23 + fill-prefix を null にした。 2.24 + 2.25 +1.27: 最初の正式リリース版