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