Mercurial > hgrepos > hgweb.cgi > yatex
diff yatexadd.el @ 23:b00c74813e56
Change the YaTeX-math-mode's prefix from `,' to `;'.
Add YaTeX-apropos, YaTeX-what-column, YaTeX-beginning-of-environment,
YaTeX-end-of-environment.
Add variables YaTeX-default-pop-window-height, YaTeX-close-paren-always,
YaTeX-no-begend-shortcut, YaTeX-auto-math-mode.
Remove Greek letters from maketitle-type.
Make YaTeX-inner-environment two times faster and more reliable.
C-u for [prefix] k kills contents too.
Fix the detection of the range of section-type commands when nested.
Add \end{ completion.
Add YaTeX-generate-simple.
Refine documents(using Texinfo).
%#REQUIRE for sub-preambles.
author | yuuji |
---|---|
date | Thu, 07 Jul 1994 16:37:05 +0000 |
parents | adc2f1472409 |
children | ef686a35472d |
line wrap: on
line diff
--- a/yatexadd.el Thu Jul 07 16:37:05 1994 +0000 +++ b/yatexadd.el Thu Jul 07 16:37:05 1994 +0000 @@ -1,12 +1,10 @@ ;;; -*- Emacs-Lisp -*- ;;; YaTeX add-in functions. -;;; yatexadd.el rev.8 +;;; yatexadd.el rev.9 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Sun May 15 18:00:12 1994 on 98fa +;;; Last modified Mon Jun 27 17:00:19 1994 on figaro ;;; $Id$ -(provide 'yatexadd) - ;;; ;;Sample functions for LaTeX environment. ;;; @@ -14,22 +12,53 @@ "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}" "*Your favorite default rule format." ) +(defvar YaTeX:tabular-thick-vrule "\\vrule width %s" + "*Vertical thick line format (without @{}). %s'll be replaced by its width." +) +(defvar YaTeX:tabular-thick-hrule "\\noalign{\\hrule height %s}" + "*Horizontal thick line format. %s will be replaced by its width." +) (defun YaTeX:tabular () "YaTeX add-in function for tabular environment. Notice that this function refers the let-variable `env' in YaTeX-make-begin-end." - (let ((width "") bars (rule "") (j 0) loc) + (let ((width "") bars (rule "") (and "") (j 1) loc ans (hline "\\hline")) (if (string= env "tabular*") (setq width (concat "{" (read-string "Width: ") "}"))) (setq loc (YaTeX:read-position "tb") - bars (string-to-int (read-string "Number of `|': "))) - (if (> bars 0) - (while (< j bars) (setq rule (concat rule "|")) (setq j (1+ j))) - (setq rule YaTeX:tabular-default-rule)) + bars (string-to-int + (read-string "Number of columns(0 for default format): " "3"))) + (if (<= bars 0) + (setq ;if 0, simple format + rule YaTeX:tabular-default-rule + and "& &") + (while (< j bars) ;repeat bars-1 times + (setq rule (concat rule "c|") + and (concat and "& ") + j (1+ j))) + (setq rule (concat rule "c")) + (message "(N)ormal-frame or (T)hick frame? [nt]") + (setq ans (read-char)) + (cond + ((or (equal ans ?t) (equal ans ?T)) + (setq ans (read-string "Rule width: " "1pt") + rule (concat + "@{" (format YaTeX:tabular-thick-vrule ans) "}" + rule + "@{\\ " (format YaTeX:tabular-thick-vrule ans) "}") + hline (format YaTeX:tabular-thick-hrule ans))) + (t (setq rule (concat "|" rule "|") + hline "\\hline")))) + (setq rule (read-string "rule format: " rule)) - (message "") - (format "%s%s{%s}" width loc rule)) + (message "Dont forget to remove null line at the end of tabular.") + (format "%s%s{%s}%s" + width loc rule + (if (and (boundp 'region-mode) region-mode) + "" ;do nothing in region-mode + (format "\n%s\n%s \\\\ \\hline\n%s\n\\\\ %s" + hline and and hline)))) ) (fset 'YaTeX:tabular* 'YaTeX:tabular) (defun YaTeX:array () @@ -37,11 +66,13 @@ "{" (read-string "Column format: ") "}") ) -(defun YaTeX:read-position (oneof) - (let ((pos "") loc) +(defun YaTeX:read-oneof (oneof) + (let ((pos "") loc (guide "")) + (and (boundp 'name) name (setq guide (format "%s " name))) (while (not (string-match (setq loc (read-key-sequence - (format "Position (`%s') [%s]: " oneof pos))) + (format "%s position (`%s') [%s]: " + guide oneof pos)));name is in YaTeX-addin "\r\^g\n")) (cond ((string-match loc oneof) @@ -54,8 +85,13 @@ (message "Please input one of `%s'." oneof) (sit-for 3)))) (message "") - (if (string= pos "") "" - (concat "[" pos "]"))) + pos) +) + +(defun YaTeX:read-position (oneof) + "Read a LaTeX (optional) position format such as `[htbp]'." + (let ((pos (YaTeX:read-oneof oneof))) + (if (string= pos "") "" (concat "[" pos "]"))) ) (defun YaTeX:table () @@ -113,8 +149,17 @@ ) (defun YaTeX:makebox () - (concat (YaTeX:read-coordinates "Dimension") - (YaTeX:read-position "lrtb")) + (cond + ((YaTeX-in-environment-p "picture") + (concat (YaTeX:read-coordinates "Dimension") + (YaTeX:read-position "lrtb"))) + (t + (let ((width (read-string "Width: "))) + (if (string< "" width) + (progn + (or (equal (aref width 0) ?\[) + (setq width (concat "[" width "]"))) + (concat width (YaTeX:read-position "lr"))))))) ) (defun YaTeX:framebox () @@ -127,6 +172,19 @@ (YaTeX:read-coordinates "Dimension")) ) +(defun YaTeX:left () + (let (c) + (while (not (string-match + (progn (message "Which parenthesis? One of [{(|)}]: ") + (setq c (regexp-quote (char-to-string (read-char))))) + "[{(|)}]"))) + (setq single-command "right") + (cond + ((string-match c "[(|)]") c) + (t (concat "\\" c)))) +) +(fset 'YaTeX:right 'YaTeX:left) + (defun YaTeX:read-coordinates (&optional mes varX varY) (concat "(" @@ -177,6 +235,7 @@ (contents (read-string "Quoted contents: "))) (concat quote-char contents quote-char)) ) +(fset 'YaTeX:verb* 'YaTeX:verb) ;;; ;;Subroutine @@ -202,6 +261,8 @@ ;; (defvar YaTeX-label-menu-other (if YaTeX-japan "':他のバッファのラベル\n" "':LABEL IN OTHER BUFFER.\n")) +(defvar YaTeX-label-menu-repeat + (if YaTeX-japan ".:直前の\\refと同じ\n" "/:REPEAT LAST \ref{}\n")) (defvar YaTeX-label-menu-any (if YaTeX-japan "*:任意の文字列\n" "*:ANY STRING.\n")) (defvar YaTeX-label-buffer "*Label completions*") @@ -228,6 +289,7 @@ (define-key YaTeX-label-select-map "/" 'isearch-forward) (define-key YaTeX-label-select-map "?" 'isearch-backward) (define-key YaTeX-label-select-map "'" 'YaTeX::label-search-tag) + (define-key YaTeX-label-select-map "." 'YaTeX::label-search-tag) (define-key YaTeX-label-select-map "*" 'YaTeX::label-search-tag) (message "Setting up label selection mode map...Done") (let ((key ?A)) @@ -244,15 +306,15 @@ (interactive) (forward-line -1) (message YaTeX-label-guide-msg)) (defun YaTeX::label-search-tag () (interactive) - (let ((case-fold-search t)) + (let ((case-fold-search t) (tag (regexp-quote (this-command-keys)))) (cond ((save-excursion (forward-char 1) - (re-search-forward (concat "^" (this-command-keys)) nil t)) + (re-search-forward (concat "^" tag) nil t)) (goto-char (match-beginning 0))) ((save-excursion (goto-char (point-min)) - (re-search-forward (concat "^" (this-command-keys)) nil t)) + (re-search-forward (concat "^" tag) nil t)) (goto-char (match-beginning 0)))) (message YaTeX-label-guide-msg)) ) @@ -284,6 +346,7 @@ (message "Collecting \\label{}... %d" lnum)) (goto-char e0)) (princ YaTeX-label-menu-other) + (princ YaTeX-label-menu-repeat) (princ YaTeX-label-menu-any) );with (goto-char p) @@ -303,7 +366,15 @@ (setq line (count-lines (point-min)(point))) (cond ((= line lnum) (setq label (YaTeX-label-other))) - ((>= line (1+ lnum )) + ((= line (1+ lnum)) + (save-excursion + (switch-to-buffer buf) + (goto-char p) + (if (re-search-backward "\\\\ref{\\([^}]+\\)}" nil t) + (setq label (buffer-substring + (match-beginning 1) (match-end 1))) + (setq label "")))) + ((>= line (+ lnum 2)) (setq label (read-string "\\ref{???}: "))) (t (setq label (nth (- lnum line 1) label-list))))) (bury-buffer YaTeX-label-buffer))) @@ -408,24 +479,101 @@ '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman"))) ) -;;; -;; global subroutines -;;; -(defun substitute-all-key-definition (olddef newdef keymap) - "Replace recursively OLDDEF with NEWDEF for any keys in KEYMAP now -defined as OLDDEF. In other words, OLDDEF is replaced with NEWDEF -where ever it appears." - (if (arrayp keymap) - (let ((len (length keymap)) - (i 0)) - (while (< i len) - (let ((map (aref keymap i))) - (cond - ((arrayp map) (substitute-key-definition olddef newdef map)) - ((equal map olddef) - (aset keymap i newdef))) - (setq i (1+ i))))) - (while keymap - (if (equal (cdr-safe (car-safe keymap)) olddef) - (setcdr (car keymap) newdef)) - (setq keymap (cdr keymap))))) +;; +; Length +;; +(defvar YaTeX:style-parameters-default + '(("\\arraycolsep") + ("\\arrayrulewidth") + ("\\baselineskip") + ("\\columnsep") + ("\\columnseprule") + ("\\doublerulesep") + ("\\evensidemargin") + ("\\footheight") + ("\\footskip") + ("\\headheight") + ("\\headsep") + ("\\itemindent") + ("\\itemsep") + ("\\labelsep") + ("\\labelwidth") + ("\\leftmargin") + ("\\linewidth") + ("\\listparindent") + ("\\marginparsep") + ("\\marginparwidth") + ("\\mathindent") + ("\\oddsidemargin") + ("\\parindent") + ("\\parsep") + ("\\parskip") + ("\\partopsep") + ("\\rightmargin") + ("\\tabcolsep") + ("\\textheight") + ("\\textwidth") + ("\\topmargin") + ("\\topsep") + ("\\topskip") + ) + "Alist of LaTeX style parameters.") +(defvar YaTeX:style-parameters-private nil + "*User definable alist of style parameters.") +(defvar YaTeX:style-parameters-private nil + "Holds the union of LaTeX style parameters.") +(setq YaTeX:style-parameters + (append YaTeX:style-parameters-private YaTeX:style-parameters-default)) + +(defvar YaTeX:length-history nil "Holds history of length.") +(defun YaTeX::setlength (&optional argp) + "YaTeX add-in function for arguments of \\setlength." + (cond + ((equal 1 argp) + (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")) + ((equal 2 argp) + (let ((minibuffer-history-symbol 'YaTeX:length-history)) + (read-string "Length: ")))) +) +(fset 'YaTeX::addtolength 'YaTeX::setlength) + +(defun YaTeX::settowidth (&optional argp) + "YaTeX add-in function for arguments of \\settowidth." + (cond + ((equal 1 argp) + (completing-read "Length variable: " YaTeX:style-parameters nil nil "\\")) + ((equal 2 argp) + (read-string "Text: "))) +) +(defun YaTeX::newlength (&optional argp) + "YaTeX add-in function for arguments of \\newlength" + (cond + ((equal argp 1) + (let ((length (read-string "Length variable: " "\\"))) + (or (assoc length YaTeX:style-parameters-private) + (setq YaTeX:style-parameters-private + (cons (list length) YaTeX:style-parameters-private) + YaTeX:style-parameters + (cons (list length) YaTeX:style-parameters))) + length))) +) + +;; \multicolumn's arguments +(defun YaTeX::multicolumn (&optional argp) + "YaTeX add-in function for arguments of \\multicolumn." + (cond + ((equal 1 argp) + (read-string "Number of columns: ")) + ((equal 2 argp) + (let (c) + (while (not (string-match + (progn (message "Format(one of l,r,c): ") + (setq c (char-to-string (read-char)))) + "lrc"))) + c)) + ((equal 3 argp) + (read-string "Item: "))) +) + +;;; -------------------- End of yatexadd -------------------- +(provide 'yatexadd)