annotate yatexenv.el @ 59:48ac97a6b6ce

Call drawing tools ID completion (yahtml)
author yuuji
date Wed, 01 May 1996 15:35:40 +0000
parents 3a7c0c2bf16d
children 9e08ed569d80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
1 ;;; -*- Emacs-Lisp -*-
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
2 ;;; YaTeX environment-specific functions.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
3 ;;; yatexenv.el
56
a9653fbd1c1c Bug fix version
yuuji
parents: 53
diff changeset
4 ;;; (c ) 1994, 1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
5 ;;; Last modified Mon Apr 15 16:24:00 1996 on supra
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
6 ;;; $Id$
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
7
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
8 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
9 ;; Functions for tabular environment
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
10 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
11
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
12 ;; Showing the matching column of tabular environment.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
13 (defun YaTeX-array-what-column ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
14 "Show matching columne title of array environment.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
15 When calling from a program, make sure to be in array/tabular environment."
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
16 (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&")
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
17 (n 0) j
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
18 (firsterr "This line might be the first row."))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
19 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
20 (YaTeX-beginning-of-environment)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
21 (search-forward "{" p) (up-list 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
22 (search-forward "{" p) (up-list 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
23 ;;(re-search-forward andptn p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
24 (while (progn (search-forward "&" p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
25 (equal (char-after (1- (match-beginning 0))) ?\\ )))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
26 (setq beg (1- (point))) ;beg is the point of the first &
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
27 (or (re-search-forward nlptn p t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
28 (error firsterr))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
29 (setq eot (point)) ;eot is the point of the first \\
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
30 (goto-char p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
31 (or (re-search-backward nlptn beg t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
32 (error firsterr))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
33 (setq bor (point)) ;bor is the beginning of this row.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
34 (while (< (1- (point)) p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
35 (if (equal (following-char) ?&)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
36 (forward-char 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
37 (re-search-forward andptn nil 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
38 (setq n (1+ n))) ;Check current column number
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
39 (goto-char p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
40 (cond ;Start searching \multicolumn{N}
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
41 ((> n 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
42 (re-search-backward andptn) ;Sure to find!
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
43 (while (re-search-backward "\\\\multicolumn{\\([0-9]+\\)}" bor t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
44 (setq n (+ n (string-to-int
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
45 (buffer-substring (match-beginning 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
46 (match-end 1)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
47 -1)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
48 (message "%s" n)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
49 (goto-char (1- beg))
59
48ac97a6b6ce Call drawing tools
yuuji
parents: 58
diff changeset
50 (beginning-of-line)
49
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
51 (setq j n)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
52 (while (> j 1)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
53 (or (re-search-forward andptn p nil)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
54 (error "This column exceeds the limit."))
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
55 (setq j (1- j)))
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
56 (skip-chars-forward "\\s ")
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
57 (message
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
58 "This is the column(#%d) of: %s" n
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
59 (buffer-substring
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
60 (point)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
61 (progn
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
62 (re-search-forward (concat andptn "\\|" nlptn) eot)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
63 (goto-char (match-beginning 0))
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
64 (if (looking-at andptn)
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
65 (forward-char 1))
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
66 (skip-chars-backward "\\s ")
eb0512bfcb7f Abolish user-article table.
yuuji
parents: 46
diff changeset
67 (point))))))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
68 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
69
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
70 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
71 (defun YaTeX-what-column ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
72 "Show which kind of column the current position is belonging to."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
73 (interactive)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
74 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
75 ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*"))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
76 (YaTeX-array-what-column))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
77 (t (message "Not in array/tabuar environment.")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
78 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
79
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
80 (defun YaTeX-tabular-parse-format (&optional tabular*)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
81 "Parse `tabular' format.
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
82 Return the list of (No.ofCols PointEndofFormat)"
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
83 (let ((p (point)) elt boform eoform (cols 0))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
84 (save-excursion
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
85 (if (null (YaTeX-beginning-of-environment t))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
86 (error "Beginning of tabular not found."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
87 (skip-chars-forward "^{")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
88 (forward-list 1)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
89 (if tabular*
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
90 (progn (skip-chars-forward "^{")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
91 (forward-list 1)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
92 (skip-chars-forward "^{" p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
93 (if (/= (following-char) ?\{) (error "Tabular format not found."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
94 (setq boform (1+ (point))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
95 eoform (progn (forward-list 1) (1- (point))))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
96 (if (> eoform p) (error "Non-terminated tabular format."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
97 (goto-char boform)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
98 (while (< (point) eoform)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
99 (setq elt (following-char))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
100 (cond
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
101 ((string-match (char-to-string elt) "clr") ;normal indicators.
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
102 (setq cols (1+ cols))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
103 (forward-char 1))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
104 ((equal elt ?|) ;vertical
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
105 (forward-char 1))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
106 ((string-match (char-to-string elt) "p@") ;p or @ expression
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
107 (setq cols (+ (if (eq elt ?p) 1 0) cols))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
108 (skip-chars-forward "^{" p)
56
a9653fbd1c1c Bug fix version
yuuji
parents: 53
diff changeset
109 (forward-list 1))
a9653fbd1c1c Bug fix version
yuuji
parents: 53
diff changeset
110 (t (forward-char 1)) ;unknown char
a9653fbd1c1c Bug fix version
yuuji
parents: 53
diff changeset
111 ))
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
112 (list cols (1+ eoform))))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
113 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
114 ;; Insert &
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
115 (defun YaTeX-intelligent-newline-tabular (&optional tabular*)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
116 "Parse current tabular format and insert that many `&'s."
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
117 (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
118 (cols (car format)) (beg (car (cdr format)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
119 space hline)
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
120 (cond
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
121 ((search-backward "&" beg t)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
122 (goto-char p)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
123 (setq hline (search-backward "\\hline" beg t))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
124 (setq space (if (search-backward "\t&" beg t) "\t" " "))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
125 (goto-char p))
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
126 (t ;;(insert "\\hline\n")
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
127 (setq space " ")))
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
128 (goto-char p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
129 (while (> (1- cols) 0)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
130 (insert "&" space)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
131 (setq cols (1- cols)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
132 (insert "\\\\")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
133 (if hline (insert " \\hline"))
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
134 (goto-char p)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
135 (YaTeX-indent-line)
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
136 )
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
137 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
138
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
139 (defun YaTeX-intelligent-newline-tabular* ()
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
140 "Parse current tabular* format and insert that many `&'s."
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
141 (YaTeX-intelligent-newline-tabular t)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
142 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
143
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
144 (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
145
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
146 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
147 ;; Functions for tabbing environment
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
148 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
149 (defun YaTeX-intelligent-newline-tabbing ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
150 "Check the number of \\= in the first line and insert that many \\>."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
151 (let ((p (point)) begenv tabcount)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
152 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
153 (YaTeX-beginning-of-environment)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
154 (setq begenv (point-end-of-line))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
155 (if (YaTeX-search-active-forward "\\\\" YaTeX-comment-prefix p t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
156 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
157 (setq tabcount 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
158 (while (> (point) begenv)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
159 (if (search-backward "\\=" begenv 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
160 (setq tabcount (1+ tabcount)))))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
161 (YaTeX-indent-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
162 (if tabcount
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
163 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
164 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
165 (while (> tabcount 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
166 (insert "\\>\t")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
167 (setq tabcount (1- tabcount))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
168 (forward-char 2))
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
169 (insert "\\= \\\\")
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
170 (forward-char -5)))
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
171 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
172
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
173 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
174 ;; Functions for itemize/enumerate/list environments
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
175 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
176
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
177 (defun YaTeX-intelligent-newline-itemize ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
178 "Insert '\\item '."
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
179 (insert "\\item ")
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
180 (YaTeX-indent-line)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
181 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
182 (fset 'YaTeX-intelligent-newline-enumerate 'YaTeX-intelligent-newline-itemize)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
183 (fset 'YaTeX-intelligent-newline-list 'YaTeX-intelligent-newline-itemize)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
184
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
185 (defun YaTeX-intelligent-newline-description ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
186 (insert "\\item[] ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
187 (forward-char -2)
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
188 (YaTeX-indent-line)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
189 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
190
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
191
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
192 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
193 ;; Intelligent newline
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
194 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
195 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
196 (defun YaTeX-intelligent-newline (arg)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
197 "Insert newline and environment-specific entry.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
198 `\\item' for some itemizing environment,
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
199 `\\> \\> \\' for tabbing environemnt,
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
200 `& & \\ \hline' for tabular environment."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
201 (interactive "P")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
202 (let*((env (YaTeX-inner-environment))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
203 func)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
204 (if arg (setq env (YaTeX-read-environment "For what environment? ")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
205 (setq func (intern-soft (concat "YaTeX-intelligent-newline-" env)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
206 (end-of-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
207 (newline)
58
3a7c0c2bf16d Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents: 56
diff changeset
208 (undo-boundary)
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
209 (if (and env func (fboundp func))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
210 (funcall func)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
211 )
53
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
212
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
213 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
214 ;; Environment-specific line indenting functions
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
215 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
216 ;;;###autoload
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
217 (defun YaTeX-indent-line-equation ()
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
218 "Indent a line in equation family."
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
219 (let ((p (point)) (l-r 0) right-p peol depth (mp YaTeX-environment-indent))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
220 (if (save-excursion
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
221 (beginning-of-line)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
222 (skip-chars-forward " \t")
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
223 (looking-at "\\\\right\\b"))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
224 (progn (YaTeX-reindent
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
225 (save-excursion (YaTeX-goto-corresponding-leftright)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
226 (current-column))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
227 (save-excursion
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
228 (forward-line -1)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
229 (while (and (not (bobp)) (YaTeX-on-comment-p))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
230 (forward-line -1))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
231 ;;(beginning-of-line) ;must be unnecessary
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
232 (skip-chars-forward " \t")
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
233 (if (eolp) (error "Math-environment can't have a null line!!"))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
234 (setq depth (current-column)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
235 peol (point-end-of-line))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
236 (while (re-search-forward
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
237 "\\\\\\(\\(left\\)\\|\\(right\\)\\)\\b" peol t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
238 (setq l-r (+ l-r (if (match-beginning 2) 1 -1))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
239 (cond
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
240 ((progn (beginning-of-line)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
241 (re-search-forward "\\\\\\\\\\s *$" (point-end-of-line) t))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
242 ;;If previous line has `\\', this indentation is always normal.
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
243 (setq depth (+ (YaTeX-current-indentation) mp)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
244 ((> l-r 0)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
245 (beginning-of-line)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
246 (search-forward "\\left" peol)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
247 (goto-char (1+ (match-beginning 0)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
248 (setq depth (current-column)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
249 ((< l-r 0)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
250 (goto-char (match-beginning 0)) ;should be \right
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
251 (YaTeX-goto-corresponding-leftright)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
252 (beginning-of-line)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
253 (skip-chars-forward " \t")
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
254 (setq depth (+ (current-column) mp))) ;+mp is good?
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
255 (t ;if \left - \right = 0
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
256 (cond
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
257 ((re-search-forward "\\\\\\\\\\s *$" peol t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
258 (setq depth (+ (YaTeX-current-indentation) mp)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
259 ((re-search-forward "\\\\end{" peol t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
260 nil) ;same indentation as previous line's
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
261 ((re-search-forward "\\\\begin{" peol t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
262 (setq depth (+ depth mp)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
263 (t
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
264 (or (bobp) (forward-line -1))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
265 (cond
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
266 ((re-search-forward
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
267 "\\\\\\\\\\s *$\\|\\\\begin{" (point-end-of-line) t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
268 (setq depth (+ depth mp)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
269 )))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
270 (goto-char p))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
271 (YaTeX-reindent depth))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
272
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
273 ;;;###autoload
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
274 (defun YaTeX-goto-corresponding-leftright ()
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
275 "Go to corresponding \left or \right.
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
276 Note that this function assumes the corresponding \left\right
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
277 is on another line."
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
278 (let ((YaTeX-struct-begin "\\left%1")
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
279 (YaTeX-struct-end "\\right%1")
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
280 (YaTeX-struct-name-regexp "[][(){}.|]"))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
281 (YaTeX-goto-corresponding-environment t)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
282
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
283 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
284 ;; Functions for formatting region being enclosed with environment
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
285 ;;;
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
286 ; These functions must take two argument; region-beginning, region-end.
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
287
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
288 (defun YaTeX-enclose-equation (beg end)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
289 (goto-char beg)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
290 (save-restriction
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
291 (let (m0 bsl)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
292 (narrow-to-region beg end)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
293 (while (YaTeX-re-search-active-forward
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
294 "\\(\\$\\)" YaTeX-comment-prefix nil t)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
295 (goto-char (setq m0 (match-beginning 0)))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
296 (setq bsl 0)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
297 (if (and (not (bobp)) (= (char-after (1- (point))) ?\\ ))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
298 (while (progn (forward-char -1) (= (char-after (point)) ?\\ ))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
299 (setq bsl (1+ bsl))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
300 (goto-char m0)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
301 (if (= 0 (% bsl 2))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
302 (delete-char 1)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
303 (forward-char 1))))))
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
304
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
305 (fset 'YaTeX-enclose-eqnarray 'YaTeX-enclose-equation)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
306 (fset 'YaTeX-enclose-eqnarray* 'YaTeX-enclose-equation)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
307
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
308 (defun YaTeX-enclose-verbatim (beg end)) ;do nothing when enclose verbatim
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
309 (fset 'YaTeX-enclose-verbatim* 'YaTeX-enclose-verbatim)
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
310
5f4b18da14b3 Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents: 49
diff changeset
311 (provide 'yatexenv)

yatex.org