Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexsec.el @ 546:071cd0ab1c71 dev
Optional second arg. for YaTeX-help suppress ask of new entry creation
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 02 Jun 2018 16:47:26 +0900 |
parents | 5eb2b1d824f3 |
children |
rev | line source |
---|---|
287 | 1 ;;; yatexsec.el --- YaTeX sectioning browser |
2 ;;; | |
451
2011de73a671
Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents:
366
diff
changeset
|
3 ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji@yatex.org] |
532
5eb2b1d824f3
Emacs26's switch-to-buffer does not keep logical point.
HIROSE Yuuji <yuuji@gentei.org>
parents:
451
diff
changeset
|
4 ;;; Last modified Wed May 30 13:29:50 2018 on firestorm |
366 | 5 ;;; $Id$ |
23 | 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" |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
58 (function (lambda () (interactive) (YaTeX-sectioning-scroll-down 1)))) |
49 | 59 (define-key YaTeX-sectioning-minibuffer-map "\C-z" |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
294
diff
changeset
|
60 (function (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)) |
451
2011de73a671
Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents:
366
diff
changeset
|
137 (forward-line (max 0 (- (YaTeX-str2int 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) | |
532
5eb2b1d824f3
Emacs26's switch-to-buffer does not keep logical point.
HIROSE Yuuji <yuuji@gentei.org>
parents:
451
diff
changeset
|
195 (setq buffer-read-only nil) ;; Emacs26 |
23 | 196 (erase-buffer) |
197 (insert "===== View sectioning ===== | |
198 C-p Up sectioning level. 0 Show only \\part, | |
199 C-n Down sectioning level. 1 and \\chapter, | |
200 C-v Scroll up *Sectioning line* buffer. 2 and \\section, | |
201 M-v Scroll down *Sectioning line* buffer. 3 and \\subsection, | |
49 | 202 C-z Scroll up by 1 line. 4 and \\subsubsection, |
203 C-w Scroll down by 1 line. 5 and \\paragraph. | |
204 SPC Complete word. 6 Show all. | |
205 TAB Complete word. | |
206 C-l Recenter recent line. | |
23 | 207 RET Select. |
208 ==== End of HELP ===== | |
209 ") | |
210 (set-buffer-modified-p nil) | |
211 (goto-char (point-min)) | |
212 (momentary-string-display "" (point-min))) | |
213 (bury-buffer hb) | |
214 (switch-to-buffer sb) | |
215 (select-window cw))) | |
216 ) | |
217 | |
218 (defun YaTeX-sectioning-up (n) | |
219 "Up section level. | |
220 Refers the YaTeX-read-section-in-minibuffer's local variable minibuffer-start." | |
221 (interactive "p") | |
222 (if (eq (selected-window) (minibuffer-window)) | |
72 | 223 (let*((command (YaTeX-minibuffer-string)) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
49
diff
changeset
|
224 (aster (and (string< "" command) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
49
diff
changeset
|
225 (equal (substring command -1) "*"))) |
49 | 226 (command (if aster (substring command 0 -1) command)) |
23 | 227 (alist YaTeX-sectioning-level) |
49 | 228 (level 0)) |
229 (or (assoc command alist) (error "No such sectioning command.")) | |
230 (while (not (string= (car (nth level alist)) command)) | |
231 (setq level (1+ level))) ;I want to use `member'.... | |
23 | 232 (setq level (- level n)) |
233 (if (or (< level 0) (>= level (length alist))) | |
234 (ding) | |
72 | 235 (YaTeX-minibuffer-erase) |
49 | 236 (insert (concat (car (nth level alist)) (if aster "*" "")))))) |
23 | 237 ) |
238 | |
239 (defun YaTeX-sectioning-down (n) | |
240 "Down section level." | |
241 (interactive "p") | |
242 (YaTeX-sectioning-up (- n)) | |
243 ) | |
244 | |
245 (defun YaTeX-sectioning-scroll-up (n) | |
246 (interactive "P") | |
247 (let ((section-buffer YaTeX-sectioning-buffer) | |
248 (cw (selected-window))) | |
249 (YaTeX-showup-buffer section-buffer nil t) | |
250 (unwind-protect | |
251 (scroll-up (or n (- (window-height) 2))) | |
252 (select-window cw))) | |
253 ) | |
254 | |
255 (defun YaTeX-sectioning-scroll-down (n) | |
256 (interactive "P") | |
257 (let ((section-buffer YaTeX-sectioning-buffer) | |
258 (cw (selected-window))) | |
259 (YaTeX-showup-buffer section-buffer nil t) | |
260 (unwind-protect | |
261 (scroll-down (or n (- (window-height) 2))) | |
262 (select-window cw))) | |
263 ) | |
264 | |
265 (defun YaTeX-sectioning-recenter (arg) | |
266 "Recenter `<<--' line" | |
267 (interactive "P") | |
268 (let ((cw (selected-window))) | |
269 (unwind-protect | |
270 (progn | |
271 (YaTeX-showup-buffer YaTeX-sectioning-buffer nil t) | |
272 (or (search-forward "<<--" nil t) | |
49 | 273 (search-backward "<<--" nil)) |
23 | 274 (recenter (or arg (/ (window-height) 2)))) |
275 (select-window cw))) | |
276 ) | |
277 | |
278 (defvar YaTeX-sectioning-minibuffer " *sectioning*" | |
279 "Miniuffer used for sectioning") | |
49 | 280 ;;;###autoload |
23 | 281 (defun YaTeX-read-section-in-minibuffer (prompt table &optional default delim) |
282 (interactive) | |
283 (let ((minibuffer-completion-table table)) | |
284 (read-from-minibuffer | |
49 | 285 prompt default YaTeX-sectioning-minibuffer-map)) |
23 | 286 ) |
287 | |
288 (defun YaTeX-get-sectioning-level () | |
289 "Get section-level on the cursor." | |
290 (cdr-safe (assoc (buffer-substring | |
291 (point) | |
292 (progn (skip-chars-forward "a-z") (point))) | |
293 YaTeX-sectioning-level)) | |
294 ) | |
295 | |
296 (defvar YaTeX-sectioning-buffer "*Sectioning lines*") | |
64 | 297 (defvar YaTeX-sectioning-indent 1) |
72 | 298 (defun YaTeX-collect-sections () |
23 | 299 "Collect all the lines which contains sectioning command." |
300 (let ((cw (selected-window)) level indent begp (prevp 1) (prevl 1) | |
301 (pattern (concat YaTeX-ec-regexp | |
302 "\\(" YaTeX-sectioning-regexp "\\)\\*?{")) | |
303 (cb (current-buffer))) | |
304 (save-excursion | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
305 (set-buffer (get-buffer-create YaTeX-sectioning-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
306 (setq buffer-read-only nil) |
70 | 307 (erase-buffer) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
308 (set-buffer cb) |
23 | 309 (YaTeX-showup-buffer YaTeX-sectioning-buffer) ;show buffer |
310 (goto-char (point-min)) | |
68 | 311 (let ((standard-output (get-buffer YaTeX-sectioning-buffer))) |
23 | 312 (while (re-search-forward pattern nil t) |
313 (goto-char (1+ (match-beginning 0))) | |
314 (setq level (YaTeX-get-sectioning-level) | |
315 begp (match-beginning 0)) | |
316 ;;(beginning-of-line) | |
317 ;;(skip-chars-forward " \t") | |
64 | 318 (setq indent (format "%%%ds" (* level YaTeX-sectioning-indent))) |
23 | 319 (princ (format indent "")) |
320 (if (YaTeX-on-comment-p) (princ "%")) | |
321 (princ (buffer-substring begp (progn (forward-list 1) (point)))) | |
322 (setq prevl (+ prevl (count-lines prevp (point)) -1) | |
323 prevp (point)) | |
324 (princ (format " (line:%d)" prevl)) | |
325 (princ "\n"))) | |
326 (set-buffer YaTeX-sectioning-buffer) | |
327 (make-local-variable 'YaTeX-sectioning-buffer-parent) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
328 (YaTeX-sectioning-mode) |
23 | 329 (use-local-map YaTeX-sectioning-buffer-map) |
330 (setq YaTeX-sectioning-buffer-parent cb) | |
331 (if (numberp selective-display) | |
332 (setq mode-name (format "level %d" (1- selective-display)))) | |
333 YaTeX-sectioning-buffer)) | |
334 ) | |
335 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
336 (defvar YaTeX-pending-undo nil) |
23 | 337 (defun YaTeX-section-overview () |
338 "Show section overview. Return the nearest sectioning command." | |
339 (interactive) | |
340 (let ((cw (selected-window)) (ln (count-lines (point-min) (point))) | |
341 (pattern "(line:\\([0-9]+\\))") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
342 secbuf (command "")) |
23 | 343 (save-excursion |
72 | 344 (setq secbuf (YaTeX-collect-sections)) |
23 | 345 (YaTeX-showup-buffer secbuf nil t) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
346 (set-buffer secbuf) |
23 | 347 (goto-char (point-max)) |
348 (while (re-search-backward pattern nil t) | |
451
2011de73a671
Who owes the incompatibility of string-to-int?
HIROSE Yuuji <yuuji@gentei.org>
parents:
366
diff
changeset
|
349 (if (< ln (YaTeX-str2int (YaTeX-match-string 1))) nil |
23 | 350 (beginning-of-line) |
351 (search-forward YaTeX-ec) | |
352 (looking-at YaTeX-TeX-token-regexp) | |
353 (setq command (YaTeX-match-string 0)) | |
354 (end-of-line) | |
355 (insert " <<--") | |
356 (setq pattern (concat "HackyRegexp" "ForFailure")))) | |
357 (set-buffer-modified-p nil) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
358 (setq buffer-read-only t buffer-undo-list nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
359 (make-local-variable 'YaTeX-pending-undo) |
23 | 360 (forward-line 1) |
361 (if (eobp) (recenter -1) (recenter -3)) | |
362 (select-window cw) | |
363 command)) | |
364 ) | |
365 | |
49 | 366 ;;;###autoload |
23 | 367 (defun YaTeX-make-section-with-overview () |
368 "Input sectining command with previous overview." | |
369 (interactive) | |
370 (insert | |
371 YaTeX-ec | |
372 (YaTeX-read-section-in-minibuffer | |
373 "Sectioning(Up=C-p, Down=C-n, Help=?): " | |
374 YaTeX-sectioning-level (YaTeX-section-overview)) | |
375 "{}") | |
376 (forward-char -1) | |
377 ) | |
378 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
379 (defun YaTeX-shifted-section (sc n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
380 "Get SC's N-shifted sectioning command." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
381 (let (lv) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
382 (setq lv (- (cdr (assoc sc YaTeX-sectioning-level)) n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
383 lv (max (min YaTeX-sectioning-max-level lv) 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
384 (car (nth lv YaTeX-sectioning-level))) |
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 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
387 (defun YaTeX-shift-section-up (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
388 "Shift sectioning command down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
389 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
390 (let ((cb (current-buffer)) sc nsc lv) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
391 (if (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
392 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
393 (save-excursion |
68 | 394 (beginning-of-line) |
395 (skip-chars-forward "^\\\\" (point-end-of-line)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
396 (YaTeX-on-section-command-p YaTeX-sectioning-regexp))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
397 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
398 (or (buffer-name (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
399 (error "This buffer is obsolete.")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
400 (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
|
401 (YaTeX-sectioning-buffer-jump-internal) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
402 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
403 (goto-char (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
404 (skip-chars-forward "\\\\") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
405 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
406 (point) (progn (skip-chars-forward "^*{") (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
407 (insert nsc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
408 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
409 ;; Return to *Sectioning Lines* buffer |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
410 (select-window (get-buffer-window cb)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
411 (beginning-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
412 (let (buffer-read-only) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
413 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
414 (point) (progn (skip-chars-forward " \t") (point))) |
64 | 415 (indent-to-column (* (cdr (assoc nsc YaTeX-sectioning-level)) |
416 YaTeX-sectioning-indent)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
417 (skip-chars-forward "^\\\\") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
418 (delete-region |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
419 (1+ (point)) (progn (skip-chars-forward "^*{") (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
420 (insert nsc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
421 (undo-boundary)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
422 (set-buffer-modified-p nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
423 (setq YaTeX-pending-undo pending-undo-list) |
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 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
426 (defun YaTeX-shift-section-down (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
427 "Shift sectioning command down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
428 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
429 (YaTeX-shift-section-up (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
430 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
431 (defun YaTeX-shift-section-undo (arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
432 "Undo YaTeX-shift-section-up/down." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
433 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
434 (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
435 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
436 (equal (current-buffer) (get-buffer YaTeX-sectioning-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
437 (let ((cb (current-buffer)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
438 (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
|
439 (let ((pending-undo-list YaTeX-pending-undo) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
440 buffer-read-only (last-command lc)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
441 (undo arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
442 (setq YaTeX-pending-undo pending-undo-list)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
443 (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
444 (goto-buffer-window YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
445 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
446 (let ((last-command lc) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
447 (pending-undo-list |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
448 (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
|
449 (undo arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
450 (setq YaTeX-pending-undo pending-undo-list)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
451 (goto-buffer-window cb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
452 (setq this-command 'YaTeX-shift-section-undo))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
453 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
454 (defun YaTeX-sync-section-buffer () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
455 "Synchronize *Sectioning Lines* buffer with parent buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
456 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
457 (if (and YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
458 (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
459 (let ((cb (current-buffer)) (p (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
460 (set-buffer (get-buffer YaTeX-sectioning-buffer-parent)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
461 (YaTeX-section-overview) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
462 (switch-to-buffer cb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
463 (goto-char p))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
464 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
465 (defun YaTeX-shift-section-up-region (beg end n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
466 "Shift sectioning commands in region down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
467 (interactive "r\np") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
468 (or YaTeX-sectioning-buffer-parent |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
469 (get-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
470 (error "Can't find corresponding LaTeX buffer")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
471 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
472 (goto-char beg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
473 (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
|
474 (set-marker e end) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
475 (while (progn (skip-chars-forward "^\\\\") (< (point) e)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
476 (YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
477 (setq from (YaTeX-match-string 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
478 nsc (YaTeX-shifted-section (YaTeX-match-string 1) n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
479 (goto-char (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
480 (let (buffer-read-only) |
68 | 481 ;(delete-region (point) (progn (beginning-of-line) (point))) |
482 (delete-region (progn (beginning-of-line) (point)) | |
483 (progn (skip-chars-forward " \t") (point))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
484 (indent-to-column (cdr (assoc nsc YaTeX-sectioning-level))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
485 (delete-region |
68 | 486 (progn (skip-chars-forward "%\\\\") (point)) |
487 (progn (skip-chars-forward "^*{") (point))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
488 (insert nsc)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
489 (YaTeX-on-section-command-p YaTeX-sectioning-regexp) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
490 (setq to (YaTeX-match-string 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
491 repllist (cons (cons from to) repllist)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
492 (forward-line 1)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
493 (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
494 (goto-buffer-window YaTeX-sectioning-buffer-parent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
495 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
496 (goto-char (point-max)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
497 (undo-boundary) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
498 (while repllist |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
499 (if (search-backward (car (car repllist)) nil t) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
500 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
501 (goto-char (match-beginning 0)) ;confirm |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
502 (delete-region (point) (match-end 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
503 (insert (cdr (car repllist))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
504 (goto-char (match-beginning 0)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
505 (setq repllist (cdr repllist)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
506 (goto-buffer-window cb))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
507 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
508 (defun YaTeX-shift-section-down-region (beg end n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
509 "Shift sectioning commands in region down by level N." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
510 (interactive "r\np") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
511 (YaTeX-shift-section-up-region beg end (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
512 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
513 (defun YaTeX-sectioning-buffer-next-line (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
514 "Move to next line in *Sectioning Lines* buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
515 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
516 (forward-line n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
517 (skip-chars-forward " \t%") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
518 ) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
519 (defun YaTeX-sectioning-buffer-prev-line (n) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
520 "Move to previous line in *Sectioning Lines* buffer." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
521 (interactive "p") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
522 (YaTeX-sectioning-buffer-next-line (- n)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
523 ) |
23 | 524 (provide 'yatexsec) |