yatex
diff yatexenv.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 | |
children | 459e1eca4e10 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/yatexenv.el Thu Jul 07 16:37:05 1994 +0000 1.3 @@ -0,0 +1,154 @@ 1.4 +;;; -*- Emacs-Lisp -*- 1.5 +;;; YaTeX environment-specific functions. 1.6 +;;; yatexenv.el 1.7 +;;; (c ) 1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] 1.8 +;;; Last modified Fri Jul 8 00:48:40 1994 on figaro 1.9 +;;; $Id$ 1.10 + 1.11 +;;; 1.12 +;; Functions for tabular environment 1.13 +;;; 1.14 + 1.15 +;; Showing the matching column of tabular environment. 1.16 +(defun YaTeX-array-what-column () 1.17 + "Show matching columne title of array environment. 1.18 +When calling from a program, make sure to be in array/tabular environment." 1.19 + (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") (n 0) 1.20 + (firsterr "This line might be the first row.")) 1.21 + (save-excursion 1.22 + (YaTeX-beginning-of-environment) 1.23 + (search-forward "{" p) (up-list 1) 1.24 + (search-forward "{" p) (up-list 1) 1.25 + ;;(re-search-forward andptn p) 1.26 + (while (progn (search-forward "&" p) 1.27 + (equal (char-after (1- (match-beginning 0))) ?\\ ))) 1.28 + (setq beg (1- (point))) ;beg is the point of the first & 1.29 + (or (re-search-forward nlptn p t) 1.30 + (error firsterr)) 1.31 + (setq eot (point)) ;eot is the point of the first \\ 1.32 + (goto-char p) 1.33 + (or (re-search-backward nlptn beg t) 1.34 + (error firsterr)) 1.35 + (setq bor (point)) ;bor is the beginning of this row. 1.36 + (while (< (1- (point)) p) 1.37 + (if (equal (following-char) ?&) 1.38 + (forward-char 1) 1.39 + (re-search-forward andptn nil 1)) 1.40 + (setq n (1+ n))) ;Check current column number 1.41 + (goto-char p) 1.42 + (cond ;Start searching \multicolumn{N} 1.43 + ((> n 1) 1.44 + (re-search-backward andptn) ;Sure to find! 1.45 + (while (re-search-backward "\\\\multicolumn{\\([0-9]+\\)}" bor t) 1.46 + (setq n (+ n (string-to-int 1.47 + (buffer-substring (match-beginning 1) 1.48 + (match-end 1))) 1.49 + -1))))) 1.50 + (message "%s" n) 1.51 + (goto-char (1- beg)) 1.52 + (cond 1.53 + ((= n 1) (message "Here is the FIRST column!")) 1.54 + (t (while (> n 1) 1.55 + (or (re-search-forward andptn p nil) 1.56 + (error "This column exceeds the limit.")) 1.57 + (setq n (1- n))) 1.58 + (skip-chars-forward "\\s ") 1.59 + (message 1.60 + "Here is the column of: %s" 1.61 + (buffer-substring 1.62 + (point) 1.63 + (progn 1.64 + (re-search-forward (concat andptn "\\|" nlptn) eot) 1.65 + (goto-char (match-beginning 0)) 1.66 + (if (looking-at andptn) 1.67 + (forward-char 1)) 1.68 + (skip-chars-backward "\\s ") 1.69 + (point)))))))) 1.70 +) 1.71 + 1.72 +;;;###autoload 1.73 +(defun YaTeX-what-column () 1.74 + "Show which kind of column the current position is belonging to." 1.75 + (interactive) 1.76 + (cond 1.77 + ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*")) 1.78 + (YaTeX-array-what-column)) 1.79 + (t (message "Not in array/tabuar environment."))) 1.80 +) 1.81 + 1.82 +;;; 1.83 +;; Functions for tabbing environment 1.84 +;;; 1.85 +(defun YaTeX-intelligent-newline-tabbing () 1.86 + "Check the number of \\= in the first line and insert that many \\>." 1.87 + (let ((p (point)) begenv tabcount) 1.88 + (save-excursion 1.89 + (YaTeX-beginning-of-environment) 1.90 + (setq begenv (point-end-of-line)) 1.91 + (if (YaTeX-search-active-forward "\\\\" YaTeX-comment-prefix p t) 1.92 + (progn 1.93 + (setq tabcount 0) 1.94 + (while (> (point) begenv) 1.95 + (if (search-backward "\\=" begenv 1) 1.96 + (setq tabcount (1+ tabcount))))))) 1.97 + (YaTeX-indent-line) 1.98 + (if tabcount 1.99 + (progn 1.100 + (save-excursion 1.101 + (while (> tabcount 0) 1.102 + (insert "\\>\t") 1.103 + (setq tabcount (1- tabcount)))) 1.104 + (forward-char 2)) 1.105 + (insert "\\="))) 1.106 +) 1.107 + 1.108 +;;; 1.109 +;; Functions for itemize/enumerate/list environments 1.110 +;;; 1.111 + 1.112 +(defun YaTeX-indent-for-item () 1.113 + (let (col (p (point)) begenv) 1.114 + (save-excursion 1.115 + (YaTeX-beginning-of-environment t) 1.116 + (setq begenv (point-end-of-line)) 1.117 + (goto-char p) 1.118 + (if (YaTeX-search-active-backward "\\item" YaTeX-comment-prefix begenv t) 1.119 + (setq col (current-column)))) 1.120 + (if col (indent-to col) (YaTeX-indent-line))) 1.121 +) 1.122 + 1.123 +(defvar YaTeX-item-for-insert "\\item ") 1.124 +(defun YaTeX-intelligent-newline-itemize () 1.125 + "Insert '\\item '." 1.126 + (YaTeX-indent-for-item) 1.127 + (insert YaTeX-item-for-insert) 1.128 +) 1.129 +(fset 'YaTeX-intelligent-newline-enumerate 'YaTeX-intelligent-newline-itemize) 1.130 +(fset 'YaTeX-intelligent-newline-list 'YaTeX-intelligent-newline-itemize) 1.131 + 1.132 +(defun YaTeX-intelligent-newline-description () 1.133 + (YaTeX-indent-for-item) 1.134 + (insert "\\item[] ") 1.135 + (forward-char -2) 1.136 +) 1.137 + 1.138 + 1.139 +;;; 1.140 +;; Intelligent newline 1.141 +;;; 1.142 +;;;###autoload 1.143 +(defun YaTeX-intelligent-newline (arg) 1.144 + "Insert newline and environment-specific entry. 1.145 +`\\item' for some itemizing environment, 1.146 +`\\> \\> \\' for tabbing environemnt, 1.147 +`& & \\ \hline' for tabular environment." 1.148 + (interactive "P") 1.149 + (let*((env (YaTeX-inner-environment)) 1.150 + func) 1.151 + (if arg (setq env (YaTeX-read-environment "For what environment? "))) 1.152 + (setq func (intern-soft (concat "YaTeX-intelligent-newline-" env))) 1.153 + (end-of-line) 1.154 + (newline) 1.155 + (if (and env func (fboundp func)) 1.156 + (funcall func))) 1.157 +)