annotate yatexsec.el @ 364:d69fd7b1ac4d dev yatex-1.78

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

yatex.org