annotate yatexenv.el @ 31:459e1eca4e10

Stay initial version.
author yuuji
date Mon, 11 Jul 1994 14:56:13 +0000
parents b00c74813e56
children cd1b63102eed
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
4 ;;; (c ) 1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
5 ;;; Last modified Mon Jul 11 02:01:18 1994 on 98fa
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."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
16 (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&") (n 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
17 (firsterr "This line might be the first row."))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
18 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
19 (YaTeX-beginning-of-environment)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
20 (search-forward "{" p) (up-list 1)
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 ;;(re-search-forward andptn p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
23 (while (progn (search-forward "&" p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
24 (equal (char-after (1- (match-beginning 0))) ?\\ )))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
25 (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
26 (or (re-search-forward nlptn p t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
27 (error firsterr))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
28 (setq eot (point)) ;eot is the point of the first \\
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
29 (goto-char p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
30 (or (re-search-backward nlptn beg t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
31 (error firsterr))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
32 (setq bor (point)) ;bor is the beginning of this row.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
33 (while (< (1- (point)) p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
34 (if (equal (following-char) ?&)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
35 (forward-char 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
36 (re-search-forward andptn nil 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
37 (setq n (1+ n))) ;Check current column number
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
38 (goto-char p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
39 (cond ;Start searching \multicolumn{N}
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
40 ((> n 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
41 (re-search-backward andptn) ;Sure to find!
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
42 (while (re-search-backward "\\\\multicolumn{\\([0-9]+\\)}" bor t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
43 (setq n (+ n (string-to-int
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
44 (buffer-substring (match-beginning 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
45 (match-end 1)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
46 -1)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
47 (message "%s" n)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
48 (goto-char (1- beg))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
49 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
50 ((= n 1) (message "Here is the FIRST column!"))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
51 (t (while (> n 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
52 (or (re-search-forward andptn p nil)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
53 (error "This column exceeds the limit."))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
54 (setq n (1- n)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
55 (skip-chars-forward "\\s ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
56 (message
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
57 "Here is the column of: %s"
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
58 (buffer-substring
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
59 (point)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
60 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
61 (re-search-forward (concat andptn "\\|" nlptn) eot)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
62 (goto-char (match-beginning 0))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
63 (if (looking-at andptn)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
64 (forward-char 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
65 (skip-chars-backward "\\s ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
66 (point))))))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
67 )
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 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
70 (defun YaTeX-what-column ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
71 "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
72 (interactive)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
73 (cond
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
74 ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*"))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
75 (YaTeX-array-what-column))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
76 (t (message "Not in array/tabuar environment.")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
77 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
78
31
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
79 (defun YaTeX-tabular-parse-format (&optional tabular*)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
80 "Parse `tabular' format.
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
81 Return the list of (No.ofCols PointEndofFormat)"
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
82 (let ((p (point)) elt boform eoform (cols 0))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
83 (save-excursion
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
84 (if (null (YaTeX-beginning-of-environment t))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
85 (error "Beginning of tabular not found."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
86 (skip-chars-forward "^{")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
87 (forward-list 1)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
88 (if tabular*
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
89 (progn (skip-chars-forward "^{")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
90 (forward-list 1)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
91 (skip-chars-forward "^{" p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
92 (if (/= (following-char) ?\{) (error "Tabular format not found."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
93 (setq boform (1+ (point))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
94 eoform (progn (forward-list 1) (1- (point))))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
95 (if (> eoform p) (error "Non-terminated tabular format."))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
96 (goto-char boform)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
97 (while (< (point) eoform)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
98 (setq elt (following-char))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
99 (cond
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
100 ((string-match (char-to-string elt) "clr") ;normal indicators.
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
101 (setq cols (1+ cols))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
102 (forward-char 1))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
103 ((equal elt ?|) ;vertical
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
104 (forward-char 1))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
105 ((string-match (char-to-string elt) "p@") ;p or @ expression
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
106 (setq cols (+ (if (eq elt ?p) 1 0) cols))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
107 (skip-chars-forward "^{" p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
108 (forward-list 1))))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
109 (list cols (1+ eoform))))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
110 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
111 ;; Insert &
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
112 (defun YaTeX-intelligent-newline-tabular (&optional tabular*)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
113 "Parse current tabular format and insert that many `&'s."
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
114 (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
115 (cols (car format)) (beg (car (cdr format)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
116 space hline)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
117 (setq hline (search-backward "\\hline" beg t))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
118 (goto-char p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
119 (setq space (if (search-backward "\t&" beg t) "\t" " "))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
120 (goto-char p)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
121 (YaTeX-indent-line)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
122 (setq p (point))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
123 (while (> (1- cols) 0)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
124 (insert "&" space)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
125 (setq cols (1- cols)))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
126 (insert "\\\\")
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
127 (if hline (insert " \\hline"))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
128 (goto-char p))
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
129 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
130
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
131 (defun YaTeX-intelligent-newline-tabular* ()
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
132 "Parse current tabular* format and insert that many `&'s."
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
133 (YaTeX-intelligent-newline-tabular t)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
134 )
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
135
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
136 (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
459e1eca4e10 Stay initial version.
yuuji
parents: 23
diff changeset
137
23
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
138 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
139 ;; Functions for tabbing environment
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
140 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
141 (defun YaTeX-intelligent-newline-tabbing ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
142 "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
143 (let ((p (point)) begenv tabcount)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
144 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
145 (YaTeX-beginning-of-environment)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
146 (setq begenv (point-end-of-line))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
147 (if (YaTeX-search-active-forward "\\\\" YaTeX-comment-prefix p t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
148 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
149 (setq tabcount 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
150 (while (> (point) begenv)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
151 (if (search-backward "\\=" begenv 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
152 (setq tabcount (1+ tabcount)))))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
153 (YaTeX-indent-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
154 (if tabcount
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
155 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
156 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
157 (while (> tabcount 0)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
158 (insert "\\>\t")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
159 (setq tabcount (1- tabcount))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
160 (forward-char 2))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
161 (insert "\\=")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
162 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
163
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
164 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
165 ;; Functions for itemize/enumerate/list environments
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
166 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
167
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
168 (defun YaTeX-indent-for-item ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
169 (let (col (p (point)) begenv)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
170 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
171 (YaTeX-beginning-of-environment t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
172 (setq begenv (point-end-of-line))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
173 (goto-char p)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
174 (if (YaTeX-search-active-backward "\\item" YaTeX-comment-prefix begenv t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
175 (setq col (current-column))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
176 (if col (indent-to col) (YaTeX-indent-line)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
177 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
178
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
179 (defvar YaTeX-item-for-insert "\\item ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
180 (defun YaTeX-intelligent-newline-itemize ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
181 "Insert '\\item '."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
182 (YaTeX-indent-for-item)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
183 (insert YaTeX-item-for-insert)
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 (fset 'YaTeX-intelligent-newline-enumerate 'YaTeX-intelligent-newline-itemize)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
186 (fset 'YaTeX-intelligent-newline-list 'YaTeX-intelligent-newline-itemize)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
187
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
188 (defun YaTeX-intelligent-newline-description ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
189 (YaTeX-indent-for-item)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
190 (insert "\\item[] ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
191 (forward-char -2)
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
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 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
196 ;; Intelligent newline
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
197 ;;;
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
198 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
199 (defun YaTeX-intelligent-newline (arg)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
200 "Insert newline and environment-specific entry.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
201 `\\item' for some itemizing environment,
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
202 `\\> \\> \\' for tabbing environemnt,
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
203 `& & \\ \hline' for tabular environment."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
204 (interactive "P")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
205 (let*((env (YaTeX-inner-environment))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
206 func)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
207 (if arg (setq env (YaTeX-read-environment "For what environment? ")))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
208 (setq func (intern-soft (concat "YaTeX-intelligent-newline-" env)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
209 (end-of-line)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
210 (newline)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
211 (if (and env func (fboundp func))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
212 (funcall func)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents:
diff changeset
213 )

yatex.org