yatex

diff yatexadd.el @ 34:c61405ef1bd1

Change the message of dictionary selection menu.
author yuuji
date Wed, 13 Jul 1994 16:11:27 +0000
parents adc2f1472409
children ef686a35472d
line diff
     1.1 --- a/yatexadd.el	Mon May 16 09:30:52 1994 +0000
     1.2 +++ b/yatexadd.el	Wed Jul 13 16:11:27 1994 +0000
     1.3 @@ -1,12 +1,10 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; YaTeX add-in functions.
     1.6 -;;; yatexadd.el rev.8
     1.7 +;;; yatexadd.el rev.9
     1.8  ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     1.9 -;;; Last modified Sun May 15 18:00:12 1994 on 98fa
    1.10 +;;; Last modified Mon Jun 27 17:00:19 1994 on figaro
    1.11  ;;; $Id$
    1.12  
    1.13 -(provide 'yatexadd)
    1.14 -
    1.15  ;;;
    1.16  ;;Sample functions for LaTeX environment.
    1.17  ;;;
    1.18 @@ -14,22 +12,53 @@
    1.19    "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}"
    1.20    "*Your favorite default rule format."
    1.21  )
    1.22 +(defvar YaTeX:tabular-thick-vrule "\\vrule width %s"
    1.23 +  "*Vertical thick line format (without @{}).  %s'll be replaced by its width."
    1.24 +)
    1.25 +(defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}"
    1.26 +  "*Horizontal thick line format.  %s will be replaced by its width."
    1.27 +)
    1.28  (defun YaTeX:tabular ()
    1.29    "YaTeX add-in function for tabular environment.
    1.30  Notice that this function refers the let-variable `env' in
    1.31  YaTeX-make-begin-end."
    1.32 -  (let ((width "") bars (rule "") (j 0) loc)
    1.33 +  (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline"))
    1.34      (if (string= env "tabular*")
    1.35  	(setq width (concat "{" (read-string "Width: ") "}")))
    1.36      (setq loc (YaTeX:read-position "tb")
    1.37 -	  bars (string-to-int (read-string "Number of `|': ")))
    1.38 -    (if (> bars 0)
    1.39 -	(while (< j bars) (setq rule (concat rule "|")) (setq j (1+ j)))
    1.40 -      (setq rule YaTeX:tabular-default-rule))
    1.41 +	  bars (string-to-int
    1.42 +		(read-string "Number of columns(0 for default format): " "3")))
    1.43 +    (if (<= bars 0)
    1.44 +	(setq				;if 0, simple format
    1.45 +	 rule YaTeX:tabular-default-rule
    1.46 +	 and "& &")
    1.47 +      (while (< j bars)			;repeat bars-1 times
    1.48 +	(setq rule (concat rule "c|")
    1.49 +	      and (concat and "& ")
    1.50 +	      j (1+ j)))
    1.51 +      (setq rule (concat rule "c"))
    1.52 +      (message "(N)ormal-frame or (T)hick frame? [nt]")
    1.53 +      (setq ans (read-char))
    1.54 +      (cond
    1.55 +       ((or (equal ans ?t) (equal ans ?T))
    1.56 +	(setq ans (read-string "Rule width: " "1pt")
    1.57 +	      rule (concat
    1.58 +		    "@{" (format YaTeX:tabular-thick-vrule ans) "}"
    1.59 +		    rule
    1.60 +		    "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}")
    1.61 +	      hline (format YaTeX:tabular-thick-hrule ans)))
    1.62 +       (t (setq rule (concat "|" rule "|")
    1.63 +		hline "\\hline"))))
    1.64 +
    1.65      (setq rule (read-string "rule format: " rule))
    1.66  
    1.67 -    (message "")
    1.68 -    (format "%s%s{%s}" width loc rule))
    1.69 +    (message "Dont forget to remove null line at the end of tabular.")
    1.70 +    (format "%s%s{%s}%s"
    1.71 +	    width loc rule
    1.72 +	    (if (and (boundp 'region-mode) region-mode)
    1.73 +		""		;do nothing in region-mode
    1.74 +	      (format "\n%s\n%s \\\\ \\hline\n%s\n\\\\ %s"
    1.75 +		      hline and and hline))))
    1.76  )
    1.77  (fset 'YaTeX:tabular* 'YaTeX:tabular)
    1.78  (defun YaTeX:array ()
    1.79 @@ -37,11 +66,13 @@
    1.80  	  "{" (read-string "Column format: ") "}")
    1.81  )
    1.82  
    1.83 -(defun YaTeX:read-position (oneof)
    1.84 -  (let ((pos "") loc)
    1.85 +(defun YaTeX:read-oneof (oneof)
    1.86 +  (let ((pos "") loc (guide ""))
    1.87 +    (and (boundp 'name) name (setq guide (format "%s " name)))
    1.88      (while (not (string-match
    1.89  		 (setq loc (read-key-sequence
    1.90 -			    (format "Position (`%s') [%s]: " oneof pos)))
    1.91 +			    (format "%s position (`%s') [%s]: "
    1.92 +				    guide oneof pos)));name is in YaTeX-addin
    1.93  		 "\r\^g\n"))
    1.94        (cond
    1.95         ((string-match loc oneof)
    1.96 @@ -54,8 +85,13 @@
    1.97  	(message "Please input one of `%s'." oneof)
    1.98  	(sit-for 3))))
    1.99      (message "")
   1.100 -    (if (string= pos "") ""
   1.101 -      (concat "[" pos "]")))
   1.102 +    pos)
   1.103 +)
   1.104 +
   1.105 +(defun YaTeX:read-position (oneof)
   1.106 +  "Read a LaTeX (optional) position format such as `[htbp]'."
   1.107 +  (let ((pos (YaTeX:read-oneof oneof)))
   1.108 +    (if (string= pos "")  "" (concat "[" pos "]")))
   1.109  )
   1.110  
   1.111  (defun YaTeX:table ()
   1.112 @@ -113,8 +149,17 @@
   1.113  )
   1.114  
   1.115  (defun YaTeX:makebox ()
   1.116 -  (concat (YaTeX:read-coordinates "Dimension")
   1.117 -	  (YaTeX:read-position "lrtb"))
   1.118 +  (cond
   1.119 +   ((YaTeX-in-environment-p "picture")
   1.120 +    (concat (YaTeX:read-coordinates "Dimension")
   1.121 +	    (YaTeX:read-position "lrtb")))
   1.122 +   (t
   1.123 +    (let ((width (read-string "Width: ")))
   1.124 +      (if (string< "" width)
   1.125 +	  (progn
   1.126 +	    (or (equal (aref width 0) ?\[)
   1.127 +		(setq width (concat "[" width "]")))
   1.128 +	    (concat width (YaTeX:read-position "lr")))))))
   1.129  )
   1.130  
   1.131  (defun YaTeX:framebox ()
   1.132 @@ -127,6 +172,19 @@
   1.133  	  (YaTeX:read-coordinates "Dimension"))
   1.134  )
   1.135  
   1.136 +(defun YaTeX:left ()
   1.137 +  (let (c)
   1.138 +    (while (not (string-match
   1.139 +		 (progn (message "Which parenthesis? One of [{(|)}]: ")
   1.140 +			(setq c (regexp-quote (char-to-string (read-char)))))
   1.141 +		 "[{(|)}]")))
   1.142 +    (setq single-command "right")
   1.143 +    (cond
   1.144 +     ((string-match c "[(|)]") c)
   1.145 +     (t (concat "\\" c))))
   1.146 +)
   1.147 +(fset 'YaTeX:right 'YaTeX:left)
   1.148 +
   1.149  (defun YaTeX:read-coordinates (&optional mes varX varY)
   1.150    (concat
   1.151     "("
   1.152 @@ -177,6 +235,7 @@
   1.153  	(contents (read-string "Quoted contents: ")))
   1.154      (concat quote-char contents quote-char))
   1.155  )
   1.156 +(fset 'YaTeX:verb* 'YaTeX:verb)
   1.157  
   1.158  ;;;
   1.159  ;;Subroutine
   1.160 @@ -202,6 +261,8 @@
   1.161  ;;
   1.162  (defvar YaTeX-label-menu-other
   1.163    (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n"))
   1.164 +(defvar YaTeX-label-menu-repeat
   1.165 +  (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n"))
   1.166  (defvar YaTeX-label-menu-any
   1.167    (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n"))
   1.168  (defvar YaTeX-label-buffer "*Label completions*")
   1.169 @@ -228,6 +289,7 @@
   1.170      (define-key YaTeX-label-select-map "/"	'isearch-forward)
   1.171      (define-key YaTeX-label-select-map "?"	'isearch-backward)
   1.172      (define-key YaTeX-label-select-map "'"	'YaTeX::label-search-tag)
   1.173 +    (define-key YaTeX-label-select-map "."	'YaTeX::label-search-tag)
   1.174      (define-key YaTeX-label-select-map "*"	'YaTeX::label-search-tag)
   1.175      (message "Setting up label selection mode map...Done")
   1.176      (let ((key ?A))
   1.177 @@ -244,15 +306,15 @@
   1.178    (interactive) (forward-line -1) (message YaTeX-label-guide-msg))
   1.179  (defun YaTeX::label-search-tag ()
   1.180    (interactive)
   1.181 -  (let ((case-fold-search t))
   1.182 +  (let ((case-fold-search t) (tag (regexp-quote (this-command-keys))))
   1.183      (cond
   1.184       ((save-excursion
   1.185  	(forward-char 1)
   1.186 -	(re-search-forward (concat "^" (this-command-keys)) nil t))
   1.187 +	(re-search-forward (concat "^" tag) nil t))
   1.188        (goto-char (match-beginning 0)))
   1.189       ((save-excursion
   1.190  	(goto-char (point-min))
   1.191 -	(re-search-forward (concat "^" (this-command-keys)) nil t))
   1.192 +	(re-search-forward (concat "^" tag) nil t))
   1.193        (goto-char (match-beginning 0))))
   1.194      (message YaTeX-label-guide-msg))
   1.195  )
   1.196 @@ -284,6 +346,7 @@
   1.197  		(message "Collecting \\label{}... %d" lnum))
   1.198  	      (goto-char e0))
   1.199  	    (princ YaTeX-label-menu-other)
   1.200 +	    (princ YaTeX-label-menu-repeat)
   1.201  	    (princ YaTeX-label-menu-any)
   1.202  	    );with
   1.203  	  (goto-char p)
   1.204 @@ -303,7 +366,15 @@
   1.205  		(setq line (count-lines (point-min)(point)))
   1.206  		(cond
   1.207  		 ((= line lnum) (setq label (YaTeX-label-other)))
   1.208 -		 ((>= line (1+ lnum ))
   1.209 +		 ((= line (1+ lnum))
   1.210 +		  (save-excursion
   1.211 +		    (switch-to-buffer buf)
   1.212 +		    (goto-char p)
   1.213 +		    (if (re-search-backward "\\\\ref{\\([^}]+\\)}" nil t)
   1.214 +			(setq label (buffer-substring
   1.215 +				     (match-beginning 1) (match-end 1)))
   1.216 +		      (setq label ""))))
   1.217 +		 ((>= line (+ lnum 2))
   1.218  		  (setq label (read-string "\\ref{???}: ")))
   1.219  		 (t (setq label (nth (- lnum line 1) label-list)))))
   1.220  	    (bury-buffer YaTeX-label-buffer)))
   1.221 @@ -408,24 +479,101 @@
   1.222     '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))
   1.223  )
   1.224  
   1.225 -;;;
   1.226 -;; global subroutines
   1.227 -;;;
   1.228 -(defun substitute-all-key-definition (olddef newdef keymap)
   1.229 -  "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now
   1.230 -defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF
   1.231 -where ever it appears."
   1.232 -  (if (arrayp keymap)
   1.233 -      (let ((len (length keymap))
   1.234 -	    (i 0))
   1.235 -	(while (< i len)
   1.236 -	  (let ((map (aref keymap i)))
   1.237 -	    (cond
   1.238 -	     ((arrayp map) (substitute-key-definition olddef newdef map))
   1.239 -	     ((equal map olddef)
   1.240 -	      (aset keymap i newdef)))
   1.241 -	    (setq i (1+ i)))))
   1.242 -    (while keymap
   1.243 -      (if (equal (cdr-safe (car-safe keymap)) olddef)
   1.244 -	  (setcdr (car keymap) newdef))
   1.245 -      (setq keymap (cdr keymap)))))
   1.246 +;;
   1.247 +; Length
   1.248 +;;
   1.249 +(defvar YaTeX:style-parameters-default
   1.250 +  '(("\\arraycolsep")
   1.251 +    ("\\arrayrulewidth")
   1.252 +    ("\\baselineskip")
   1.253 +    ("\\columnsep")
   1.254 +    ("\\columnseprule")
   1.255 +    ("\\doublerulesep")
   1.256 +    ("\\evensidemargin")
   1.257 +    ("\\footheight")
   1.258 +    ("\\footskip")
   1.259 +    ("\\headheight")
   1.260 +    ("\\headsep")
   1.261 +    ("\\itemindent")
   1.262 +    ("\\itemsep")
   1.263 +    ("\\labelsep")
   1.264 +    ("\\labelwidth")
   1.265 +    ("\\leftmargin")
   1.266 +    ("\\linewidth")
   1.267 +    ("\\listparindent")
   1.268 +    ("\\marginparsep")
   1.269 +    ("\\marginparwidth")
   1.270 +    ("\\mathindent")
   1.271 +    ("\\oddsidemargin")
   1.272 +    ("\\parindent")
   1.273 +    ("\\parsep")
   1.274 +    ("\\parskip")
   1.275 +    ("\\partopsep")
   1.276 +    ("\\rightmargin")
   1.277 +    ("\\tabcolsep")
   1.278 +    ("\\textheight")
   1.279 +    ("\\textwidth")
   1.280 +    ("\\topmargin")
   1.281 +    ("\\topsep")
   1.282 +    ("\\topskip")
   1.283 +    )
   1.284 +  "Alist of LaTeX style parameters.")
   1.285 +(defvar YaTeX:style-parameters-private nil
   1.286 +  "*User definable alist of style parameters.")
   1.287 +(defvar YaTeX:style-parameters-private nil
   1.288 +  "Holds the union of LaTeX style parameters.")
   1.289 +(setq YaTeX:style-parameters
   1.290 +      (append YaTeX:style-parameters-private YaTeX:style-parameters-default))
   1.291 +
   1.292 +(defvar YaTeX:length-history nil "Holds history of length.")
   1.293 +(defun YaTeX::setlength (&optional argp)
   1.294 +  "YaTeX add-in function for arguments of \\setlength."
   1.295 +  (cond
   1.296 +   ((equal 1 argp)
   1.297 +    (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\"))
   1.298 +   ((equal 2 argp)
   1.299 +    (let ((minibuffer-history-symbol 'YaTeX:length-history))
   1.300 +      (read-string "Length: "))))
   1.301 +)
   1.302 +(fset 'YaTeX::addtolength 'YaTeX::setlength)
   1.303 +
   1.304 +(defun YaTeX::settowidth (&optional argp)
   1.305 +  "YaTeX add-in function for arguments of \\settowidth."
   1.306 +  (cond
   1.307 +   ((equal 1 argp)
   1.308 +    (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\"))
   1.309 +   ((equal 2 argp)
   1.310 +    (read-string "Text: ")))
   1.311 +)
   1.312 +(defun YaTeX::newlength (&optional argp)
   1.313 +  "YaTeX add-in function for arguments of \\newlength"
   1.314 +  (cond
   1.315 +   ((equal argp 1)
   1.316 +    (let ((length (read-string "Length variable: " "\\")))
   1.317 +      (or (assoc length YaTeX:style-parameters-private)
   1.318 +	  (setq YaTeX:style-parameters-private
   1.319 +		(cons (list length) YaTeX:style-parameters-private)
   1.320 +		YaTeX:style-parameters
   1.321 +		(cons (list length) YaTeX:style-parameters)))
   1.322 +      length)))
   1.323 +)
   1.324 +
   1.325 +;; \multicolumn's arguments
   1.326 +(defun YaTeX::multicolumn (&optional argp)
   1.327 +  "YaTeX add-in function for arguments of \\multicolumn."
   1.328 +  (cond
   1.329 +   ((equal 1 argp)
   1.330 +    (read-string "Number of columns: "))
   1.331 +   ((equal 2 argp)
   1.332 +    (let (c)
   1.333 +      (while (not (string-match
   1.334 +		   (progn (message "Format(one of l,r,c): ")
   1.335 +			  (setq c (char-to-string (read-char))))
   1.336 +		   "lrc")))
   1.337 +      c))
   1.338 +   ((equal 3 argp)
   1.339 +    (read-string "Item: ")))
   1.340 +)
   1.341 +
   1.342 +;;; -------------------- End of yatexadd --------------------
   1.343 +(provide 'yatexadd)