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