Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexsec.el @ 290:1a4332ecc58b dev
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 27 Jan 2013 23:34:29 +0900 |
parents | 5921f28ef77c |
children | 8d3156073892 |
rev | line source |
---|---|
287 | 1 ;;; yatexsec.el --- YaTeX sectioning browser |
2 ;;; | |
195 | 3 ;;; (c) 1994-2012 by HIROSE Yuuji [yuuji@yatex.org] |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
4 ;;; Last modified Sun Jan 27 20:11:45 2013 on firestorm |
23 | 5 ;;; $Id$ |
6 | |
287 | 7 ;;; Code: |
23 | 8 (defvar YaTeX-sectioning-level |
49 | 9 '(("part" . 0) |
10 ("chapter" . 1) | |
11 ("section" . 2) | |
12 ("subsection" . 3) | |
13 ("subsubsection" . 4) | |
14 ("paragraph" . 5) | |
15 ("subparagraph" . 6)) | |
16 "*Alist of LaTeX's sectioning command and its level. | |
17 This value must be written in numerically ascending order and consecutive. | |
18 Needn't define the level of `*' commands such as `section*'.") | |
19 | |
20 (defvar YaTeX-sectioning-max-level | |
21 (cdr (nth (1- (length YaTeX-sectioning-level)) YaTeX-sectioning-level)) | |
22 "*The heighest(numerically) level of sectioning command. | |
23 This must be the heighest number in YaTeX-sectioning-level.") | |
23 | 24 |
25 (defun YaTeX-sectioning-map-hide (map) | |
26 (let ((ch ?0)) | |
27 (while (<= ch ?9) | |
28 (define-key map (char-to-string ch) 'YaTeX-sectioning-hide) | |
29 (setq ch (1+ ch)))) | |
30 ) | |
31 | |
49 | 32 (defvar YaTeX-sectioning-minibuffer-map nil |
23 | 33 "Key map used in minibuffer for sectioning.") |
49 | 34 (if YaTeX-sectioning-minibuffer-map nil |
35 (setq YaTeX-sectioning-minibuffer-map | |
23 | 36 (copy-keymap minibuffer-local-completion-map)) |
49 | 37 (define-key YaTeX-sectioning-minibuffer-map "\C-p" |
23 | 38 'YaTeX-sectioning-up) |
49 | 39 (define-key YaTeX-sectioning-minibuffer-map "\C-e" |
23 | 40 'YaTeX-sectioning-up) |
49 | 41 (define-key YaTeX-sectioning-minibuffer-map "\C-i" |
23 | 42 'YaTeX-minibuffer-complete) |
49 | 43 (define-key YaTeX-sectioning-minibuffer-map " " |
23 | 44 'YaTeX-minibuffer-complete) |
49 | 45 (define-key YaTeX-sectioning-minibuffer-map "\C-n" |
23 | 46 'YaTeX-sectioning-down) |
49 | 47 (define-key YaTeX-sectioning-minibuffer-map "\C-x" |
23 | 48 'YaTeX-sectioning-down) |
49 | 49 (define-key YaTeX-sectioning-minibuffer-map "\C-v" |
23 | 50 'YaTeX-sectioning-scroll-up) |
49 | 51 (define-key YaTeX-sectioning-minibuffer-map "\C-c" |
23 | 52 'YaTeX-sectioning-scroll-up) |
49 | 53 (define-key YaTeX-sectioning-minibuffer-map "\M-v" |
23 | 54 'YaTeX-sectioning-scroll-down) |
49 | 55 (define-key YaTeX-sectioning-minibuffer-map "\C-r" |
23 | 56 'YaTeX-sectioning-scroll-down) |
49 | 57 (define-key YaTeX-sectioning-minibuffer-map "\C-w" |
23 | 58 '(lambda () (interactive) (YaTeX-sectioning-scroll-down 1))) |
49 | 59 (define-key YaTeX-sectioning-minibuffer-map "\C-z" |
23 | 60 '(lambda () (interactive) (YaTeX-sectioning-scroll-up 1))) |
49 | 61 (define-key YaTeX-sectioning-minibuffer-map "\C-l" |
23 | 62 'YaTeX-sectioning-recenter) |
49 | 63 (define-key YaTeX-sectioning-minibuffer-map "?" |
23 | 64 'YaTeX-sectioning-help) |
49 | 65 (YaTeX-sectioning-map-hide YaTeX-sectioning-minibuffer-map) |
23 | 66 ) |
67 | |
68 (defvar YaTeX-sectioning-buffer-map nil | |
69 "Key map used in YaTeX-sectioning-buffer.") | |
70 (if YaTeX-sectioning-buffer-map nil | |
71 (setq YaTeX-sectioning-buffer-map (make-sparse-keymap)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
72 (define-key YaTeX-sectioning-buffer-map " " 'YaTeX-sectioning-buffer-jump) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
73 (define-key YaTeX-sectioning-buffer-map "." 'YaTeX-sectioning-buffer-show) |
23 | 74 (define-key YaTeX-sectioning-buffer-map (concat YaTeX-prefix "\C-c") |
75 'YaTeX-sectioning-buffer-jump) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
76 (define-key YaTeX-sectioning-buffer-map "u" 'YaTeX-shift-section-up) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
77 (define-key YaTeX-sectioning-buffer-map "d" 'YaTeX-shift-section-down) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
78 (define-key YaTeX-sectioning-buffer-map "U" 'YaTeX-shift-section-up-region) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
79 (define-key YaTeX-sectioning-buffer-map "D" 'YaTeX-shift-section-down-region) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
80 (define-key YaTeX-sectioning-buffer-map "s" 'YaTeX-sync-section-buffer) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
81 (define-key YaTeX-sectioning-buffer-map "n" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
82 'YaTeX-sectioning-buffer-next-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
83 (define-key YaTeX-sectioning-buffer-map "p" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
84 'YaTeX-sectioning-buffer-prev-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
85 (define-key YaTeX-sectioning-buffer-map "h" 'describe-mode) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
86 (define-key YaTeX-sectioning-buffer-map "o" 'other-window) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
87 (define-key YaTeX-sectioning-buffer-map "-" 'shrink-window) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
88 (define-key YaTeX-sectioning-buffer-map "+" 'enlarge-window) |
61 | 89 (define-key YaTeX-sectioning-buffer-map "q" 'delete-window) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
90 (define-key YaTeX-sectioning-buffer-map "\C-_" 'YaTeX-shift-section-undo) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
91 (and YaTeX-emacs-19 (boundp 'window-system) (eq window-system 'x) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
92 (define-key YaTeX-sectioning-buffer-map [?\C-/] |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
93 'YaTeX-shift-section-undo)) |
23 | 94 (YaTeX-sectioning-map-hide YaTeX-sectioning-buffer-map) |
95 ) | |
96 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
97 (defun YaTeX-sectioning-mode () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
98 "Mode for browsing document's sectioning structure. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
99 \\[YaTeX-shift-section-up] Shift up a sectioning command |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
100 \\[YaTeX-shift-section-down] Shift down a sectioning command |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
101 \\[YaTeX-shift-section-up-region] Shift up sectioning commands in region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
102 \\[YaTeX-shift-section-down-region] Shift down sectioning commands in region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
103 \\[YaTeX-shift-section-undo] Undo changes of shifting |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
104 \\[YaTeX-sync-section-buffer] Synchronize sectioning buffer with source |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
105 \\[YaTeX-sectioning-buffer-next-line] Next line |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
106 \\[YaTeX-sectioning-buffer-prev-line] Previous line |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
107 \\[YaTeX-sectioning-buffer-jump] Previous line |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
108 \\[YaTeX-sectioning-buffer-show] Show curresponding source line |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
109 " |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
110 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
111 (setq major-mode 'YaTeX-sectioning-mode |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
112 mode-name "sectioning") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
113 (use-local-map YaTeX-sectioning-buffer-map) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
114 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
115 |
23 | 116 (defvar YaTeX-sectioning-buffer-parent nil) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
117 (defun YaTeX-sectioning-buffer-jump-internal (&optional keep) |
77 | 118 (let ((p (point)) ;save-excursion is NG because |
119 ptn ln) ;this function should switch buffer | |
120 (beginning-of-line) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
121 (if (re-search-forward YaTeX-sectioning-regexp) |
77 | 122 (progn |
123 (save-restriction | |
124 (narrow-to-region (point-beginning-of-line) (point-end-of-line)) | |
125 (setq ptn (buffer-substring | |
126 (1- (match-beginning 0)) | |
127 (progn (skip-chars-forward "^}") (1+ (point)))) | |
128 ln (buffer-substring | |
129 (progn (search-forward "line:") (match-end 0)) | |
130 (progn (skip-chars-forward "0-9") (point))))) | |
131 (goto-char p) | |
132 (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t) | |
133 (or | |
134 (and ln (string< "" ln) | |
135 (progn | |
178 | 136 (goto-char (point-min)) |
137 (forward-line (max 0 (- (string-to-int ln) 2))) | |
77 | 138 (and |
139 (search-forward ptn nil t) | |
140 (goto-char (match-beginning 0))))) | |
141 (progn | |
142 (goto-char (point-max)) | |
143 (search-backward ptn))) | |
144 (if keep (goto-buffer-window YaTeX-sectioning-buffer)) | |
145 (current-buffer)) | |
146 nil))) | |
147 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
148 (defun YaTeX-sectioning-buffer-jump (&optional keep) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
149 "Goto corresponding sectioning unit with current line in the next window. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
150 If optional argument KEEP is non-nil, only shows the line." |
23 | 151 (interactive) |
152 (if (and YaTeX-sectioning-buffer-parent | |
153 (get-buffer YaTeX-sectioning-buffer-parent)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
154 (YaTeX-sectioning-buffer-jump-internal keep) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
155 (message "No line number expression.")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
156 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
157 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
158 (defun YaTeX-sectioning-buffer-show () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
159 "Show corresponding sectioning unit with current line." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
160 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
161 (YaTeX-sectioning-buffer-jump-internal t) |
23 | 162 ) |
163 | |
164 (defun YaTeX-sectioning-hide-under (n) | |
165 "Hide sectioning commands under level N." | |
166 (let ((cw (selected-window))) | |
167 (YaTeX-showup-buffer YaTeX-sectioning-buffer nil t) | |
49 | 168 (if (>= n YaTeX-sectioning-max-level) |
23 | 169 (progn |
170 (set-selective-display nil) | |
171 (message "Show all.")) | |
172 (set-selective-display (1+ n)) | |
49 | 173 (if (rassq n YaTeX-sectioning-level) |
174 (message "Hide lower than %s" (car (rassq n YaTeX-sectioning-level))) | |
23 | 175 (message ""))) |
176 (if (numberp selective-display) | |
177 (setq mode-name (format "level %d" (1- selective-display))) | |
178 (setq mode-name (format "all"))) | |
179 (select-window cw)) | |
180 ) | |
181 (defun YaTeX-sectioning-hide () | |
182 "Call YaTeX-sectioning-hide-under with argument according to pressed key." | |
183 (interactive) | |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
184 (YaTeX-sectioning-hide-under (- (YaTeX-last-key) ?0))) |
23 | 185 |
186 (defun YaTeX-sectioning-help () | |
187 "Show help of sectioning." | |
188 (interactive) | |
189 (let ((cw (selected-window)) sb (hb (get-buffer-create "*Help*"))) | |
190 (unwind-protect | |
191 (progn | |
192 (other-window 1) | |
193 (setq sb (current-buffer)) | |
194 (switch-to-buffer hb) | |
195 (erase-buffer) | |
196 (insert "===== View sectioning ===== | |
197 C-p Up sectioning level. 0 Show only \\part, | |
198 C-n Down sectioning level. 1 and \\chapter, | |
199 C-v Scroll up *Sectioning line* buffer. 2 and \\section, | |
200 M-v Scroll down *Sectioning line* buffer. 3 and \\subsection, | |
49 | 201 C-z Scroll up by 1 line. 4 and \\subsubsection, |
202 C-w Scroll down by 1 line. 5 and \\paragraph. | |
203 SPC Complete word. 6 Show all. | |
204 TAB Complete word. | |
205 C-l Recenter recent line. | |
23 | 206 RET Select. |
207 ==== End of HELP ===== | |
208 ") | |
209 (set-buffer-modified-p nil) | |
210 (goto-char (point-min)) | |
211 (momentary-string-display "" (point-min))) | |
212 (bury-buffer hb) | |
213 (switch-to-buffer sb) | |
214 (select-window cw))) | |
215 ) | |
216 | |
217 (defun YaTeX-sectioning-up (n) | |
218 "Up section level. | |
219 Refers the YaTeX-read-section-in-minibuffer's local variable minibuffer-start." | |
220 (interactive "p") | |
221 (if (eq (selected-window) (minibuffer-window)) | |
72 | 222 (let*((command (YaTeX-minibuffer-string)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
49
diff
changeset
|
223 (aster (and (string< "" command) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
49
diff
changeset
|
224 (equal (substring command -1) "*"))) |
49 | 225 (command (if aster (substring command 0 -1) command)) |
23 | 226 (alist YaTeX-sectioning-level) |
49 | 227 (level 0)) |
228 (or (assoc command alist) (error "No such sectioning command.")) | |
229 (while (not (string= (car (nth level alist)) command)) | |
230 (setq level (1+ level))) ;I want to use `member'.... | |
23 | 231 (setq level (- level n)) |
232 (if (or (< level 0) (>= level (length alist))) | |
233 (ding) | |
72 | 234 (YaTeX-minibuffer-erase) |
49 | 235 (insert (concat (car (nth level alist)) (if aster "*" "")))))) |
23 | 236 ) |
237 | |
238 (defun YaTeX-sectioning-down (n) | |
239 "Down section level." | |
240 (interactive "p") | |
241 (YaTeX-sectioning-up (- n)) | |
242 ) | |
243 | |
244 (defun YaTeX-sectioning-scroll-up (n) | |
245 (interactive "P") | |
246 (let ((section-buffer YaTeX-sectioning-buffer) | |
247 (cw (selected-window))) | |
248 (YaTeX-showup-buffer section-buffer nil t) | |
249 (unwind-protect | |
250 (scroll-up (or n (- (window-height) 2))) | |
251 (select-window cw))) | |
252 ) | |
253 | |
254 (defun YaTeX-sectioning-scroll-down (n) | |
255 (interactive "P") | |
256 (let ((section-buffer YaTeX-sectioning-buffer) | |
257 (cw (selected-window))) | |
258 (YaTeX-showup-buffer section-buffer nil t) | |
259 (unwind-protect | |
260 (scroll-down (or n (- (window-height) 2))) | |
261 (select-window cw))) | |
262 ) | |
263 | |
264 (defun YaTeX-sectioning-recenter (arg) | |
265 "Recenter `<<--' line" | |
266 (interactive "P") | |
267 (let ((cw (selected-window))) | |
268 (unwind-protect | |
269 (progn | |
270 (YaTeX-showup-buffer YaTeX-sectioning-buffer nil t) | |
271 (or (search-forward "<<--" nil t) | |
49 | 272 (search-backward "<<--" nil)) |
23 | 273 (recenter (or arg (/ (window-height) 2)))) |
274 (select-window cw))) | |
275 ) | |
276 | |
277 (defvar YaTeX-sectioning-minibuffer " *sectioning*" | |
278 "Miniuffer used for sectioning") | |
49 | 279 ;;;###autoload |
23 | 280 (defun YaTeX-read-section-in-minibuffer (prompt table &optional default delim) |
281 (interactive) | |
282 (let ((minibuffer-completion-table table)) | |
283 (read-from-minibuffer | |
49 | 284 prompt default YaTeX-sectioning-minibuffer-map)) |
23 | 285 ) |
286 | |
287 (defun YaTeX-get-sectioning-level () | |
288 "Get section-level on the cursor." | |
289 (cdr-safe (assoc (buffer-substring | |
290 (point) | |
291 (progn (skip-chars-forward "a-z") (point))) | |
292 YaTeX-sectioning-level)) | |
293 ) | |
294 | |
295 (defvar YaTeX-sectioning-buffer "*Sectioning lines*") | |
64 | 296 (defvar YaTeX-sectioning-indent 1) |
72 | 297 (defun YaTeX-collect-sections () |
23 | 298 "Collect all the lines which contains sectioning command." |
299 (let ((cw (selected-window)) level indent begp (prevp 1) (prevl 1) | |
300 (pattern (concat YaTeX-ec-regexp | |
301 "\\(" YaTeX-sectioning-regexp "\\)\\*?{")) | |
302 (cb (current-buffer))) | |
303 (save-excursion | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
304 (set-buffer (get-buffer-create YaTeX-sectioning-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
305 (setq buffer-read-only nil) |
70 | 306 (erase-buffer) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
307 (set-buffer cb) |
23 | 308 (YaTeX-showup-buffer YaTeX-sectioning-buffer) ;show buffer |
309 (goto-char (point-min)) | |
68 | 310 (let ((standard-output (get-buffer YaTeX-sectioning-buffer))) |
23 | 311 (while (re-search-forward pattern nil t) |
312 (goto-char (1+ (match-beginning 0))) | |
313 (setq level (YaTeX-get-sectioning-level) | |
314 begp (match-beginning 0)) | |
315 ;;(beginning-of-line) | |
316 ;;(skip-chars-forward " \t") | |
64 | 317 (setq indent (format "%%%ds" (* level YaTeX-sectioning-indent))) |
23 | 318 (princ (format indent "")) |
319 (if (YaTeX-on-comment-p) (princ "%")) | |
320 (princ (buffer-substring begp (progn (forward-list 1) (point)))) | |
321 (setq prevl (+ prevl (count-lines prevp (point)) -1) | |
322 prevp (point)) | |
323 (princ (format " (line:%d)" prevl)) | |
324 (princ "\n"))) | |
325 (set-buffer YaTeX-sectioning-buffer) | |
326 (make-local-variable 'YaTeX-sectioning-buffer-parent) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
327 (YaTeX-sectioning-mode) |
23 | 328 (use-local-map YaTeX-sectioning-buffer-map) |
329 (setq YaTeX-sectioning-buffer-parent cb) | |
330 (if (numberp selective-display) | |
331 (setq mode-name (format "level %d" (1- selective-display)))) | |
332 YaTeX-sectioning-buffer)) | |
333 ) | |
334 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
335 (defvar YaTeX-pending-undo nil) |
23 | 336 (defun YaTeX-section-overview () |
337 "Show section overview. Return the nearest sectioning command." | |
338 (interactive) | |
339 (let ((cw (selected-window)) (ln (count-lines (point-min) (point))) | |
340 (pattern "(line:\\([0-9]+\\))") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
341 secbuf (command "")) |
23 | 342 (save-excursion |
72 | 343 (setq secbuf (YaTeX-collect-sections)) |
23 | 344 (YaTeX-showup-buffer secbuf nil t) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
345 (set-buffer secbuf) |
23 | 346 (goto-char (point-max)) |
347 (while (re-search-backward pattern nil t) | |
348 (if (< ln (string-to-int (YaTeX-match-string 1))) nil | |
349 (beginning-of-line) | |
350 (search-forward YaTeX-ec) | |
351 (looking-at YaTeX-TeX-token-regexp) | |
352 (setq command (YaTeX-match-string 0)) | |
353 (end-of-line) | |
354 (insert " <<--") | |
355 (setq pattern (concat "HackyRegexp" "ForFailure")))) | |
356 (set-buffer-modified-p nil) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
357 (setq buffer-read-only t buffer-undo-list nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
358 (make-local-variable 'YaTeX-pending-undo) |
23 | 359 (forward-line 1) |
360 (if (eobp) (recenter -1) (recenter -3)) | |
361 (select-window cw) | |
362 command)) | |
363 ) | |
364 | |
49 | 365 ;;;###autoload |
23 | 366 (defun YaTeX-make-section-with-overview () |
367 "Input sectining command with previous overview." | |
368 (interactive) | |
369 (insert | |
370 YaTeX-ec | |
371 (YaTeX-read-section-in-minibuffer | |
372 "Sectioning(Up=C-p, Down=C-n, Help=?): " | |
373 YaTeX-sectioning-level (YaTeX-section-overview)) | |
374 "{}") | |
375 (forward-char -1) | |
376 ) | |
377 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
378 (defun YaTeX-shifted-section (sc n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
379 "Get SC's N-shifted sectioning command." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
380 (let (lv) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
381 (setq lv (- (cdr (assoc sc YaTeX-sectioning-level)) n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
382 lv (max (min YaTeX-sectioning-max-level lv) 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
383 (car (nth lv YaTeX-sectioning-level))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
384 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
385 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
386 (defun YaTeX-shift-section-up (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
387 "Shift sectioning command down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
388 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
389 (let ((cb (current-buffer)) sc nsc lv) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
390 (if (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
391 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
392 (save-excursion |
68 | 393 (beginning-of-line) |
394 (skip-chars-forward "^\\\\" (point-end-of-line)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
395 (YaTeX-on-section-command-p YaTeX-sectioning-regexp))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
396 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
397 (or (buffer-name (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
398 (error "This buffer is obsolete.")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
399 (setq nsc (YaTeX-shifted-section (YaTeX-match-string 1) n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
400 (YaTeX-sectioning-buffer-jump-internal) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
401 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
402 (goto-char (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
403 (skip-chars-forward "\\\\") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
404 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
405 (point) (progn (skip-chars-forward "^*{") (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
406 (insert nsc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
407 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
408 ;; Return to *Sectioning Lines* buffer |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
409 (select-window (get-buffer-window cb)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
410 (beginning-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
411 (let (buffer-read-only) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
412 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
413 (point) (progn (skip-chars-forward " \t") (point))) |
64 | 414 (indent-to-column (* (cdr (assoc nsc YaTeX-sectioning-level)) |
415 YaTeX-sectioning-indent)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
416 (skip-chars-forward "^\\\\") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
417 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
418 (1+ (point)) (progn (skip-chars-forward "^*{") (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
419 (insert nsc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
420 (undo-boundary)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
421 (set-buffer-modified-p nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
422 (setq YaTeX-pending-undo pending-undo-list) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
423 ))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
424 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
425 (defun YaTeX-shift-section-down (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
426 "Shift sectioning command down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
427 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
428 (YaTeX-shift-section-up (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
429 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
430 (defun YaTeX-shift-section-undo (arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
431 "Undo YaTeX-shift-section-up/down." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
432 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
433 (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
434 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
435 (equal (current-buffer) (get-buffer YaTeX-sectioning-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
436 (let ((cb (current-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
437 (lc (if (eq last-command 'YaTeX-shift-section-undo) 'undo t))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
438 (let ((pending-undo-list YaTeX-pending-undo) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
439 buffer-read-only (last-command lc)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
440 (undo arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
441 (setq YaTeX-pending-undo pending-undo-list)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
442 (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
443 (goto-buffer-window YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
444 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
445 (let ((last-command lc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
446 (pending-undo-list |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
447 (if (eq lc 'undo) YaTeX-pending-undo pending-undo-list))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
448 (undo arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
449 (setq YaTeX-pending-undo pending-undo-list)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
450 (goto-buffer-window cb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
451 (setq this-command 'YaTeX-shift-section-undo))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
452 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
453 (defun YaTeX-sync-section-buffer () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
454 "Synchronize *Sectioning Lines* buffer with parent buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
455 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
456 (if (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
457 (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
458 (let ((cb (current-buffer)) (p (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
459 (set-buffer (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
460 (YaTeX-section-overview) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
461 (switch-to-buffer cb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
462 (goto-char p))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
463 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
464 (defun YaTeX-shift-section-up-region (beg end n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
465 "Shift sectioning commands in region down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
466 (interactive "r\np") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
467 (or YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
468 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
469 (error "Can't find corresponding LaTeX buffer")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
470 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
471 (goto-char beg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
472 (let ((cb (current-buffer)) nsc from to repllist (e (make-marker))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
473 (set-marker e end) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
474 (while (progn (skip-chars-forward "^\\\\") (< (point) e)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
475 (YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
476 (setq from (YaTeX-match-string 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
477 nsc (YaTeX-shifted-section (YaTeX-match-string 1) n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
478 (goto-char (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
479 (let (buffer-read-only) |
68 | 480 ;(delete-region (point) (progn (beginning-of-line) (point))) |
481 (delete-region (progn (beginning-of-line) (point)) | |
482 (progn (skip-chars-forward " \t") (point))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
483 (indent-to-column (cdr (assoc nsc YaTeX-sectioning-level))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
484 (delete-region |
68 | 485 (progn (skip-chars-forward "%\\\\") (point)) |
486 (progn (skip-chars-forward "^*{") (point))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
487 (insert nsc)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
488 (YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
489 (setq to (YaTeX-match-string 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
490 repllist (cons (cons from to) repllist)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
491 (forward-line 1)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
492 (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
493 (goto-buffer-window YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
494 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
495 (goto-char (point-max)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
496 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
497 (while repllist |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
498 (if (search-backward (car (car repllist)) nil t) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
499 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
500 (goto-char (match-beginning 0)) ;confirm |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
501 (delete-region (point) (match-end 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
502 (insert (cdr (car repllist))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
503 (goto-char (match-beginning 0)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
504 (setq repllist (cdr repllist)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
505 (goto-buffer-window cb))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
506 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
507 (defun YaTeX-shift-section-down-region (beg end n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
508 "Shift sectioning commands in region down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
509 (interactive "r\np") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
510 (YaTeX-shift-section-up-region beg end (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
511 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
512 (defun YaTeX-sectioning-buffer-next-line (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
513 "Move to next line in *Sectioning Lines* buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
514 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
515 (forward-line n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
516 (skip-chars-forward " \t%") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
517 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
518 (defun YaTeX-sectioning-buffer-prev-line (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
519 "Move to previous line in *Sectioning Lines* buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
520 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
521 (YaTeX-sectioning-buffer-next-line (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
522 ) |
23 | 523 (provide 'yatexsec) |