yatex

diff yatexmth.el @ 100:948655c12676

Remove ancient expresisons
author yuuji@gentei.org
date Mon, 28 Sep 2009 13:07:05 +0900
parents 1b172d26b55e
children d5e19b856ca1
line diff
     1.1 --- a/yatexmth.el	Thu May 01 13:38:27 2003 +0000
     1.2 +++ b/yatexmth.el	Mon Sep 28 13:07:05 2009 +0900
     1.3 @@ -1,8 +1,8 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; YaTeX math-mode-specific functions.
     1.6  ;;; yatexmth.el
     1.7 -;;; (c)1993-2003 by HIROSE Yuuji [yuuji@yatex.org]
     1.8 -;;; Last modified Sun Mar 30 19:56:00 2003 on firestorm
     1.9 +;;; (c)1993-2006 by HIROSE Yuuji [yuuji@yatex.org]
    1.10 +;;; Last modified Sun Dec 24 15:13:15 2006 on firestorm
    1.11  ;;; $Id$
    1.12  
    1.13  ;;; [Customization guide]
    1.14 @@ -107,6 +107,11 @@
    1.15  (YaTeX-setq-math-sym YaTeX-image-neg		""		"")
    1.16  (YaTeX-setq-math-sym YaTeX-image-flat		""		"")
    1.17  (YaTeX-setq-math-sym YaTeX-image-sqrt		""		"")
    1.18 +(defvar YaTeX-image-nearrow '("__\n /|\n/" "  Q\n  ^|\n^" ))
    1.19 +(defvar YaTeX-image-nwarrow '(" __\n|\\\n  \\" " Q\n|_\n   _"))
    1.20 +(defvar YaTeX-image-searrow '("\\\n \\|\n--`" "_\n  _|\n  P"))
    1.21 +(defvar YaTeX-image-swarrow '("  /\n|/\n'~~" "   ^\n|^\n P"))
    1.22 +
    1.23  
    1.24  (defvar
    1.25   YaTeX-math-sign-alist-default
    1.26 @@ -202,6 +207,7 @@
    1.27     ("-<"	"prec"		("-<"		""))
    1.28     ("-<="	"preceq"	("-<\n-"	"\n="))
    1.29     ("<<"	"ll"		("<<"		"s"))
    1.30 +   (">>"	"gg"		(">>"		"t"))
    1.31     ;	:
    1.32     ;;arrows
    1.33     ("<-"	"leftarrow"	("<-"		""))
    1.34 @@ -224,6 +230,18 @@
    1.35     ("\C-n"	"downarrow"	("|\nv" ""))
    1.36     ("v|"	"downarrow"	("|\nv" ""))
    1.37     ("v||"	"Downarrow"	"||\n\\/")
    1.38 +   ("\C-p\C-f"	"nearrow"	YaTeX-image-nearrow)
    1.39 +   ("\C-f\C-p"	"nearrow"	YaTeX-image-nearrow)
    1.40 +   ("ne"	"nearrow"	YaTeX-image-nearrow)
    1.41 +   ("\C-p\C-b"	"nwarrow"	YaTeX-image-nwarrow)
    1.42 +   ("\C-b\C-p"	"nwarrow"	YaTeX-image-nwarrow)
    1.43 +   ("nw"	"nwarrow"	YaTeX-image-nwarrow)
    1.44 +   ("\C-n\C-f"	"searrow"	YaTeX-image-searrow)
    1.45 +   ("\C-f\C-n"	"searrow"	YaTeX-image-searrow)
    1.46 +   ("se"	"searrow"	YaTeX-image-searrow)
    1.47 +   ("\C-n\C-b"	"swarrow"       YaTeX-image-swarrow)
    1.48 +   ("\C-b\C-n"	"swarrow"	YaTeX-image-swarrow)
    1.49 +   ("sw"	"swarrow"	YaTeX-image-swarrow)
    1.50     ("|->"	"mapsto"	("|->"		"|"))
    1.51     ("<-)"	"hookleftarrow"	("   ,\n<--+"	"   R\n<--/"))
    1.52     ("(->"	"hookrightarrow" ("`\n+-->"	"^\n_-->"))
    1.53 @@ -259,6 +277,8 @@
    1.54     ("O+"	"bigoplus"	"/~~~\\\n| + |\n\\___/")
    1.55     ("Ox"	"bigotimes"	"/~~~\\\n| X |\n\\___/")
    1.56     ;;other marks
    1.57 +   ("angle"	"angle"		("/\n~" ""))
    1.58 +   ("/_"	"angle"		("/\n~" ""))
    1.59     ("Z"		"aleph"		"|\\|")
    1.60     ("|\\|"	"aleph"		"|\\|")
    1.61     ("h-"	"hbar"		"_\nh")
    1.62 @@ -282,6 +302,8 @@
    1.63     ("partial"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
    1.64     ("round"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
    1.65     ("[]"	"Box"		"[]")
    1.66 +   ("no"	"notag"		"\\notag")
    1.67 +   (":"		"colon"		":")
    1.68     ("Diamond"	"Diamond"	"/\\\n\\/")
    1.69     ("3"		"triangle"	"/\\\n~~")
    1.70     ("C"		"clubsuit"	" o\no+o\n |")
    1.71 @@ -380,8 +402,8 @@
    1.72  (defvar YaTeX-math-display-width
    1.73    (* 8 (1+ (/ YaTeX-math-sign-width 8))))
    1.74  (defvar YaTeX-math-menu-map nil
    1.75 -  "Keymap used in YaTeX mathematical sign menu mode."
    1.76 -)
    1.77 +  "Keymap used in YaTeX mathematical sign menu mode.")
    1.78 +
    1.79  (if YaTeX-math-menu-map nil
    1.80    (setq YaTeX-math-menu-map (make-sparse-keymap))
    1.81    (define-key YaTeX-math-menu-map "n"	'next-line)
    1.82 @@ -400,8 +422,7 @@
    1.83    (define-key YaTeX-math-menu-map "q"	'abort-recursive-edit))
    1.84  
    1.85  (defvar YaTeX-math-exit-key "\e"
    1.86 -  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode."
    1.87 -)
    1.88 +  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
    1.89  
    1.90  (defmacro YaTeX-math-japanese-sign (list)
    1.91    (list 'nth 1 list))
    1.92 @@ -438,8 +459,7 @@
    1.93  		   " $'")))
    1.94        (setq YaTeX-math-mode nil)
    1.95        (message "Exit from math mode."))
    1.96 -    (set-buffer-modified-p (buffer-modified-p)))
    1.97 -)
    1.98 +    (set-buffer-modified-p (buffer-modified-p))))
    1.99  
   1.100  (defun YaTeX-math-forward (arg)
   1.101    (interactive "p")
   1.102 @@ -460,77 +480,81 @@
   1.103      (YaTeX-math-gets sign))
   1.104     ((symbolp sign)
   1.105      (YaTeX-math-gets (symbol-value sign)))
   1.106 -   (t sign))
   1.107 -)
   1.108 +   (t sign)))
   1.109  
   1.110  (defun YaTeX-math-get-sign (list)
   1.111 -  (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
   1.112 -)
   1.113 +  (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
   1.114 +
   1.115  (defvar YaTeX-math-section-type-regexp
   1.116    "eqn\\\\\\sw+\\b"
   1.117    "*Regexp of section-type math-mode macro")
   1.118  
   1.119  (defun YaTeX-in-math-mode-p ()
   1.120 -  "If current position is supposed to be in LaTeX-math-mode, return t."
   1.121 -  (or (YaTeX-quick-in-environment-p
   1.122 -       (append
   1.123 -	'("math" "eqnarray" "equation" "eqnarray*" "displaymath");LaTeX
   1.124 -	(if YaTeX-use-AMS-LaTeX
   1.125 -	    ;; And math modes of AMS-LaTeX
   1.126 -	    '("align" "align*" "split" "multline" "multline*" "gather"
   1.127 -	      "gather*" "aligned*" "gathered" "gathered*" "alignat"
   1.128 -	      "equation*" "cases" 
   1.129 -	      "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"))))
   1.130 -      (let*((p (point)) (nest 0) me0 r
   1.131 -	    (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
   1.132 -	    (boundary
   1.133 -	     (save-excursion
   1.134 -	       (if (looking-at delim)
   1.135 -		   (goto-char (max (point-min) (1- (point)))))
   1.136 -	       (re-search-backward delim nil 1)
   1.137 -	       (point))))
   1.138 -	(save-excursion
   1.139 -	  (cond
   1.140 -	   ((catch 'open
   1.141 -	      (save-excursion
   1.142 -		(while (and (>= nest 0)
   1.143 -			    (re-search-backward
   1.144 -			     (concat YaTeX-ec-regexp	;\
   1.145 -				     "\\([()]\\|[][]\\)") boundary t))
   1.146 -		  (setq me0 (match-end 0))
   1.147 -		  (if (or (YaTeX-on-comment-p)
   1.148 -			  (YaTeX-literal-p)) nil
   1.149 -		    (if (or (= (char-after (1- me0)) ?\))
   1.150 -			    (= (char-after (1- me0)) ?\]))
   1.151 -			(setq nest (1+ nest))
   1.152 -		      (if (= (preceding-char) ?\\ ) nil;;\\[5pt]
   1.153 -			(setq nest (1- nest))))))
   1.154 -		(if (< nest 0) (throw 'open t))))
   1.155 -	    t)
   1.156 -	   ((and (setq r (YaTeX-on-section-command-p
   1.157 -			  YaTeX-math-section-type-regexp))
   1.158 -		 (numberp r)
   1.159 -		 (> r 0))
   1.160 -	    t)
   1.161 -	   (t (catch 'dollar
   1.162 -		(while ;(search-backward "$" boundary t);little bit fast.
   1.163 -		    (YaTeX-re-search-active-backward ;;;;;; Too slow???
   1.164 -		     "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
   1.165 -		  (cond
   1.166 -		   ((equal (char-after (1- (point))) ?$) ; $$ equation $$
   1.167 -		    (backward-char 1)
   1.168 -		    (setq nest (1+ nest)))
   1.169 -		   ((let ((YaTeX-verbatim-environments
   1.170 -			   (append YaTeX-math-verbatim-environments
   1.171 -				   YaTeX-verbatim-environments)))
   1.172 -		      (YaTeX-literal-p))
   1.173 -		    nil)
   1.174 -		   ((and (equal (char-after (1- (point))) ?\\ )
   1.175 -			 (not (equal (char-after (- (point) 3)) ?\\ )))
   1.176 -		    nil)		;\$
   1.177 -		   (t (setq nest (1+ nest)))))
   1.178 -		(if (= (% nest 2) 1) (throw 'dollar t))))))))
   1.179 -)
   1.180 +  "If current position is supposed to be in LaTeX-math-mode, return t.
   1.181 +This function refers a local variable `source-window' in YaTeX-make-section."
   1.182 +  (save-excursion
   1.183 +    (and (boundp 'source-window) source-window
   1.184 +	 (set-buffer (window-buffer source-window)))
   1.185 +    (or (YaTeX-quick-in-environment-p
   1.186 +	 (append
   1.187 +	  '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX
   1.188 +	  (if YaTeX-use-AMS-LaTeX
   1.189 +	      ;; And math modes of AMS-LaTeX
   1.190 +	      ;;'("align" "align*" "split" "multline" "multline*" "gather"
   1.191 +	      ;;  "gather*" "aligned*" "gathered" "gathered*" "alignat"
   1.192 +	      ;;  "equation*" "cases" "flalign" "flalign*"
   1.193 +	      ;;  "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"
   1.194 +	      YaTeX-math-begin-list
   1.195 +	    )))
   1.196 +	(let*((p (point)) (nest 0) me0 r
   1.197 +	      (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
   1.198 +	      (boundary
   1.199 +	       (save-excursion
   1.200 +		 (if (looking-at delim)
   1.201 +		     (goto-char (max (point-min) (1- (point)))))
   1.202 +		 (re-search-backward delim nil 1)
   1.203 +		 (point))))
   1.204 +	  (save-excursion
   1.205 +	    (cond
   1.206 +	     ((catch 'open
   1.207 +		(save-excursion
   1.208 +		  (while (and (>= nest 0)
   1.209 +			      (re-search-backward
   1.210 +			       (concat YaTeX-ec-regexp ;\
   1.211 +				       "\\([()]\\|[][]\\)") boundary t))
   1.212 +		    (setq me0 (match-end 0))
   1.213 +		    (if (or (YaTeX-on-comment-p)
   1.214 +			    (YaTeX-literal-p)) nil
   1.215 +		      (if (or (= (char-after (1- me0)) ?\))
   1.216 +			      (= (char-after (1- me0)) ?\]))
   1.217 +			  (setq nest (1+ nest))
   1.218 +			(if (= (preceding-char) ?\\ ) nil ;;\\[5pt]
   1.219 +			  (setq nest (1- nest))))))
   1.220 +		  (if (< nest 0) (throw 'open t))))
   1.221 +	      t)
   1.222 +	     ((and (setq r (YaTeX-on-section-command-p
   1.223 +			    YaTeX-math-section-type-regexp))
   1.224 +		   (numberp r)
   1.225 +		   (> r 0))
   1.226 +	      t)
   1.227 +	     (t (catch 'dollar
   1.228 +		  (while ;(search-backward "$" boundary t);little bit fast.
   1.229 +		      (YaTeX-re-search-active-backward ;;;;;; Too slow???
   1.230 +		       "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
   1.231 +		    (cond
   1.232 +		     ((equal (char-after (1- (point))) ?$) ; $$ equation $$
   1.233 +		      (backward-char 1)
   1.234 +		      (setq nest (1+ nest)))
   1.235 +		     ((let ((YaTeX-verbatim-environments
   1.236 +			     (append YaTeX-math-verbatim-environments
   1.237 +				     YaTeX-verbatim-environments)))
   1.238 +			(YaTeX-literal-p))
   1.239 +		      nil)
   1.240 +		     ((and (equal (char-after (1- (point))) ?\\ )
   1.241 +			   (not (equal (char-after (- (point) 3)) ?\\ )))
   1.242 +		      nil)		;\$
   1.243 +		     (t (setq nest (1+ nest)))))
   1.244 +		  (if (= (% nest 2) 1) (throw 'dollar t))))))))))
   1.245  
   1.246  (defun YaTeX-math-display-list (list cols)
   1.247    (goto-char (point-max))
   1.248 @@ -589,8 +613,7 @@
   1.249  		   (prog2 (skip-chars-forward "^ \t\n") (point)))
   1.250  		nil))
   1.251  	(kill-buffer YaTeX-math-menu-buffer))
   1.252 -      command))
   1.253 -)
   1.254 +      command)))
   1.255  
   1.256  ;
   1.257  (defun YaTeX-math-show-image (image &optional exit-char)
   1.258 @@ -702,8 +725,8 @@
   1.259  
   1.260  	      (if match
   1.261  		  (progn (delete-region beg (point))
   1.262 -			 (setq single-command (car (cdr match)))
   1.263 -			 (insert YaTeX-ec single-command)
   1.264 +			 (setq YaTeX-single-command (car (cdr match)))
   1.265 +			 (insert YaTeX-ec YaTeX-single-command)
   1.266  			 (if (and YaTeX-math-need-image
   1.267  				  (setq sign (YaTeX-math-get-sign match)))
   1.268  			     (YaTeX-math-show-image (concat sign "\n")))
   1.269 @@ -716,14 +739,14 @@
   1.270        (if (eq result t)
   1.271  	  (setq unread-command-char last-char)
   1.272  	(message "Done."))
   1.273 -      (if (assoc single-command section-table)
   1.274 -	  (YaTeX-make-section nil nil nil single-command)
   1.275 +      (if (assoc YaTeX-single-command section-table)
   1.276 +	  (YaTeX-make-section nil nil nil YaTeX-single-command)
   1.277  	(setq YaTeX-current-completion-type 'maketitle)
   1.278 -	(YaTeX-make-singlecmd single-command)))
   1.279 +	(YaTeX-make-singlecmd YaTeX-single-command)))
   1.280       ((eq result 'abort)
   1.281        (message "Abort."))
   1.282       ((eq result 'escape)
   1.283 -      (call-interactively (global-key-binding this-key)))
   1.284 +      (call-interactively (lookup-key global-map this-key)))
   1.285       ((eq result 'exit)
   1.286        (YaTeX-toggle-math-mode))
   1.287       ((eq result 'menu)
   1.288 @@ -782,7 +805,7 @@
   1.289  				       (+ (point) 3 longest) t))
   1.290  	  (progn
   1.291  	    (setq move (- (point) point))
   1.292 -	    (setq paren (match-string 0))
   1.293 +	    (setq paren (YaTeX-match-string 0))
   1.294  	    (setq list YaTeX-ams-paren-modifier)
   1.295  	    ;; criterion for whether on [] () \{\} or not.
   1.296  	    (if (string-match YaTeX-left-paren paren)
   1.297 @@ -830,8 +853,8 @@
   1.298  						 paren-regexp "\\)")))
   1.299  			(setq flag nil)))
   1.300  		  (setq list (cdr list)))))
   1.301 -	    (if (<= move (length (match-string 0)))
   1.302 -		(match-string 0)))))))
   1.303 +	    (if (<= move (length (YaTeX-match-string 0)))
   1.304 +		(YaTeX-match-string 0)))))))
   1.305  
   1.306  (defun YaTeX-goto-open-paren (&optional jumpto-co)
   1.307    "Jump to the exact position of open parenthesis.
   1.308 @@ -872,8 +895,8 @@
   1.309    (interactive)
   1.310    (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p)))
   1.311        nil
   1.312 -    (let* ((mod (match-string 1)) ;; modifier
   1.313 -	   (paren (if mod (match-string 2) (match-string 0))) ;; paren
   1.314 +    (let* ((mod (YaTeX-match-string 1)) ;; modifier
   1.315 +	   (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
   1.316  	   (mod-length (if (or (string= mod "\\left") (string= mod "\\right"))
   1.317  			   5            ;; 5 in case left or right
   1.318  			 (length mod))) ;; length of modifier