Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexhie.el @ 53:5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
YaTeX-end-of-environment.
Line indentation by TAB much improved.
Functions that work at enclosing environments, YaTeX-enclose-<ENVNAME>,
introduced. Functions for enclosing verbatim and equations are supplied.
SPC, DEL, +, - in YaTeX-hierarchy buffer.
Compensate odd highlighting of hilit19.
author | yuuji |
---|---|
date | Thu, 02 Feb 1995 17:18:29 +0000 |
parents | 5d94deabb9f9 |
children | 0eb6997bee16 |
rev | line source |
---|---|
52 | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; YaTeX hierarchy browser. | |
3 ;;; yatexhie.el | |
4 ;;; (c )1995 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
5 ;;; Last modified Thu Feb 2 23:55:59 1995 on figaro |
52 | 6 ;;; $Id$ |
7 | |
8 ;; ----- Customizable variables ----- | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
9 (defvar YaTeX-hierarchy-ignore-heading-regexp |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
10 "\\$[A-Z][a-z]+: .* \\$\\|-\\*- .* -\\*-" |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
11 "*Regexp of lines to ignore as files' headline.") |
52 | 12 |
13 ;; ----- General variables ----- | |
14 (defvar YaTeX-default-TeX-extensions "\\.\\(tex\\|sty\\)") | |
15 (defvar YaTeX-hierarchy-current-main nil) | |
16 (defvar YaTeX-hierarchy-buffer-message | |
17 (concat | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
18 "n)ext p)rev N)extsame P)revsame u)p K)illbuf RET)select" |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
19 (if (and YaTeX-emacs-19 window-system) " Mouse2)select" "") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
20 " ?)help")) |
52 | 21 (defvar YaTeX-hierarchy-saved-wc nil "Saved window configuration.") |
22 | |
23 ;; ----- Functions for parsing hierarchy ----- | |
24 | |
25 (defun YaTeX-all-included-files (&optional file) | |
26 "Return all included files from FILE as a list. | |
27 If FILE is nil, use current buffer." | |
28 (save-excursion | |
29 (let ((include-regex (concat YaTeX-ec-regexp | |
30 "\\(\\(input\\)\\|" ;match#2 | |
31 "\\(include\\)\\)\\b")) ;match#3 | |
32 list file (cb (current-buffer))) | |
33 (if file (set-buffer (YaTeX-switch-to-buffer file t))) | |
34 (goto-char (point-min)) | |
35 (while (YaTeX-re-search-active-forward | |
36 include-regex YaTeX-comment-prefix nil t) | |
37 (cond | |
38 ((match-beginning 2) ;\input, {} is optional, 1 argument | |
39 (skip-chars-forward " {") | |
40 (setq file (buffer-substring | |
41 (point) | |
42 (progn | |
43 (skip-chars-forward | |
44 (concat "^ \t\n\r" YaTeX-ec-regexp "{}")) | |
45 (point))))) | |
46 ((match-beginning 3) | |
47 (skip-chars-forward "{") | |
48 (setq file (buffer-substring | |
49 (point) | |
50 (progn | |
51 (forward-char -1) (forward-list 1) (1- (point))))))) | |
52 (or (string-match YaTeX-default-TeX-extensions file) | |
53 (setq file (concat file ".tex"))) | |
54 (setq list (cons file list))) | |
55 (set-buffer cb) | |
56 (nreverse list)))) | |
57 | |
58 (defun YaTeX-document-hierarchy (&optional file) | |
59 "Return the document hierarchy beginning from FILE as a list. | |
60 If FILE is nil, beginning with current buffer's file." | |
61 (setq file (or file buffer-file-name)) | |
62 (message "Parsing [%s]..." (file-name-nondirectory file)) | |
63 (prog1 | |
64 (save-excursion | |
65 (if (or (file-exists-p file) (null file)) | |
66 (progn | |
67 (if file | |
68 (let ((parent buffer-file-name)) | |
69 (YaTeX-switch-to-buffer file t) ;set buffer to file | |
70 (or YaTeX-parent-file | |
71 (YaTeX-get-builtin "!") | |
72 (setq YaTeX-parent-file parent)))) | |
73 (cons (buffer-file-name (current-buffer)) | |
74 (mapcar 'YaTeX-document-hierarchy ;return value | |
75 (YaTeX-all-included-files)))))) | |
76 (message "Parsing [%s]...done" (file-name-nondirectory file)))) | |
77 | |
78 ;; ----- Functions for displaying hierarchy ----- | |
79 | |
80 (defun YaTeX-hierarchy-get-file-heading (file) | |
81 "Get a FILE's heading." | |
82 (save-excursion | |
83 (set-buffer (find-file-noselect file)) | |
84 (save-excursion | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
85 (let (p) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
86 (goto-char (point-min)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
87 (cond |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
88 ((re-search-forward |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
89 (concat YaTeX-ec-regexp YaTeX-sectioning-regexp) nil t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
90 (search-forward "{") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
91 (forward-char -1) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
92 (setq p (condition-case nil |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
93 (progn (forward-list 1) (1- (point))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
94 (error (point-end-of-line)))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
95 (goto-char (1+ (match-beginning 0))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
96 (skip-chars-forward " \t\n") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
97 (buffer-substring (point) (min (point-end-of-line) p))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
98 ((catch 'found |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
99 (while (re-search-forward "^ *%\\([^#]\\)" nil t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
100 (or (re-search-forward |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
101 YaTeX-hierarchy-ignore-heading-regexp |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
102 (point-end-of-line) t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
103 (throw 'found t)))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
104 (beginning-of-line) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
105 (search-forward "%") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
106 (skip-chars-forward "% \t") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
107 (buffer-substring (point) (point-end-of-line))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
108 (t "")))))) |
52 | 109 |
110 (defun YaTeX-display-a-hierachy (hier level) | |
111 "Put a HIER of document hierarchy. | |
112 LEVEL is including depth." | |
113 (message "Formatting hierarchy buffer...") | |
114 (let ((lastatomcol 0) list i p) | |
115 (cond | |
116 ((listp hier) | |
117 (setq list hier) | |
118 (while list | |
119 (YaTeX-display-a-hierachy (car list) (1+ level)) | |
120 (setq list (cdr list)))) | |
121 ((stringp hier) ;is an atom | |
122 (insert " ") | |
123 (setq i level) | |
124 (while (> i 2) | |
125 (insert "| ") | |
126 (setq i (1- i))) | |
127 (if (> level 1) (insert "+---")) | |
128 (setq p (point)) | |
129 (insert (or (buffer-name (get-file-buffer hier)) | |
130 (file-name-nondirectory hier))) | |
131 (if (and window-system YaTeX-emacs-19) | |
132 (put-text-property p (point) 'mouse-face 'underline)) | |
133 (insert " ") | |
134 (indent-to-column (1- (/ (window-width) 2))) | |
135 (insert "% " (YaTeX-hierarchy-get-file-heading hier)) | |
136 (insert "\n")))) | |
137 (message "Formatting hierarchy buffer...")) | |
138 | |
139 (defun YaTeX-display-hierarchy (file &optional use-default) | |
140 "Display document hierarchy that is beginning from FILE." | |
141 (interactive "P") | |
142 (setq YaTeX-hierarchy-saved-wc | |
143 (list (current-window-configuration) | |
144 (and (featurep 'windows) | |
145 (boundp 'win:current-config) | |
146 win:current-config))) | |
147 (let*((b-in (YaTeX-get-builtin "!")) | |
148 (default (or YaTeX-parent-file | |
149 (and b-in (YaTeX-guess-parent b-in)) | |
150 buffer-file-name))) | |
151 ;;$B$`!<$s"-$3$N$X$s$N;EMM$I$&$7$?$i$$$$$+NI$/J,$+$i$s(B... | |
152 (if default (setq default (expand-file-name default))) | |
153 (YaTeX-visit-main t) ;move to parent file | |
154 (setq file | |
155 (or (if use-default default file) | |
156 (read-file-name | |
157 (format | |
158 "Main .tex file%s: " | |
159 (if default | |
160 (format "(default %s)"(file-name-nondirectory default)) | |
161 "")) | |
162 "" default 1)))) | |
163 (setq file (expand-file-name file)) | |
164 (setq YaTeX-hierarchy-current-main file) | |
165 (let ((dbuf "*document hierarchy*")) | |
166 (YaTeX-showup-buffer dbuf nil t) | |
167 (set-buffer (get-buffer dbuf)) | |
168 (setq truncate-lines t) | |
169 (let ((buffer-read-only nil)) | |
170 (erase-buffer) | |
171 (YaTeX-display-a-hierachy (YaTeX-document-hierarchy file) 0)) | |
172 (goto-char (point-min)) | |
173 (YaTeX-hierarchy-next 0) | |
174 (set-buffer-modified-p nil) | |
175 (YaTeX-hierarchy-mode) | |
176 )) | |
177 | |
178 (defun YaTeX-display-hierarchy-directly () | |
179 "Same as YaTeX-display-hierarchy. Call from mouse." | |
180 (interactive) | |
181 (YaTeX-display-hierarchy nil t)) | |
182 | |
183 (defun YaTeX-hierarchy-mode () | |
184 "Major mode to browse and select document hierarchy. | |
185 | |
186 \\[YaTeX-hierarchy-next] next line | |
187 \\[YaTeX-hierarchy-prev] previous line | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
188 \\[YaTeX-hierarchy-forward] move forward in the same level |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
189 \\[YaTeX-hierarchy-backward] move backward in the same level |
52 | 190 \\[YaTeX-hierarchy-up-document] move to parent file |
191 \\[delete-other-windows] delete other windows | |
192 \\[other-window] other window | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
193 \\[shrink-window] shrink window |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
194 \\[enlarge-window] enlarge window |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
195 \\[YaTeX-hierarchy-show] show file contents in the next window |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
196 \\[YaTeX-hierarchy-scroll-up] scroll up file contents buffer |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
197 \\[YaTeX-hierarchy-scroll-down] scroll down file contents buffer |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
198 \\[YaTeX-hierarchy-top] show the top of file contents |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
199 \\[YaTeX-hierarchy-bottom] show the bottom of file contents |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
200 \\[YaTeX-hierarchy-lastpos] return to the previous position |
52 | 201 \\[YaTeX-hierarchy-select] select file |
202 \\[YaTeX-hierarchy-mouse-select] select | |
203 " | |
204 (setq major-mode 'YaTeX-hierarchy-mode | |
205 mode-name "YaTeX hier") | |
206 (use-local-map YaTeX-hierarchy-mode-map) | |
207 (setq buffer-read-only t) | |
208 (message YaTeX-hierarchy-buffer-message)) | |
209 | |
210 ;; ----- Subfunctions for interactive functions ----- | |
211 (defun YaTeX-hierarchy-get-current-file-buffer () | |
212 "Return the buffer associated with current line's file." | |
213 (let ((file (buffer-substring | |
214 (point) | |
215 (save-excursion | |
216 (skip-chars-forward "^ \t" (point-end-of-line)) (point)))) | |
217 (hilit-auto-highlight) buffer) | |
218 (set-buffer (find-file-noselect YaTeX-hierarchy-current-main)) | |
219 (if (get-buffer file) ;buffer is active | |
220 (setq buffer (get-buffer file)) ;may contain `<2>' | |
221 (if (string-match "<[2-9]>$" file) | |
222 (setq file (substring file 0 -3))) | |
223 (save-excursion | |
224 (setq buffer (YaTeX-switch-to-buffer file t)))))) ; open it! | |
225 | |
226 ;; ----- Interactive functions ----- | |
227 (defun YaTeX-hierarchy-next (arg &optional quiet) | |
228 "Move to next line's file in YaTeX document hierarchy buffer." | |
229 (interactive "p") | |
230 (forward-line arg) | |
231 (skip-chars-forward "- +\\|") | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
232 (if (and (/= arg 0) (not quiet)) |
52 | 233 (YaTeX-hierarchy-select t)) |
234 (message YaTeX-hierarchy-buffer-message)) | |
235 | |
236 (defun YaTeX-hierarchy-prev (arg) | |
237 "Move to previous line's file in YaTeX document hierarchy buffer." | |
238 (interactive "p") | |
239 (YaTeX-hierarchy-next (- arg))) | |
240 | |
241 (defun YaTeX-hierarchy-next-line (arg) | |
242 (interactive "p") | |
243 (YaTeX-hierarchy-next arg t)) | |
244 | |
245 (defun YaTeX-hierarchy-prev-line (arg) | |
246 (interactive "p") | |
247 (YaTeX-hierarchy-next (- arg) t)) | |
248 | |
249 (defun YaTeX-hierarchy-forward (arg) | |
250 "Move to forward file in same hierarchy level." | |
251 (interactive "p") | |
252 (YaTeX-hierarchy-next 0) | |
253 (let ((p (point))(column (current-column)) (i (if (> arg 0) arg (- arg)))) | |
254 (if (= column 0) (error "Not on file line.")) | |
255 (while (> i 0) | |
256 (if (catch 'found | |
257 (while (and (not (eobp)) (not (bobp))) | |
258 (forward-line (if (> arg 0) 1 -1)) | |
259 (move-to-column column) | |
260 (if (looking-at "[- +\\|]") nil | |
261 (YaTeX-hierarchy-next 0) | |
262 (if (= (current-column) column) (throw 'found t))) | |
263 (beginning-of-line))) | |
264 nil | |
265 (goto-char p) | |
266 (error "No same level file.")) | |
267 (setq i (1- i))))) | |
268 | |
269 (defun YaTeX-hierarchy-backward (arg) | |
270 "Move to backward file in same hierarchy level." | |
271 (interactive "p") | |
272 (YaTeX-hierarchy-forward (- arg))) | |
273 | |
274 (defun YaTeX-hierarchy-up-document () | |
275 "Up level, that is, move to parent file position." | |
276 (interactive) | |
277 (YaTeX-hierarchy-next 0) ;adjust column | |
278 (let ((p (point)) (line (count-lines (point-min) (point))) column) | |
279 (if (or (<= line 1) (< (current-column) 6)) | |
280 (message "No more parent") | |
281 (backward-char 1) | |
282 (or (= (char-after (point)) ?-) (error "Unexpected hierarchy buffer")) | |
283 (setq column (current-column)) | |
284 (while (and (> line 1) (looking-at "[- +\\|]")) | |
285 (forward-line -1) | |
286 (move-to-column column)) | |
287 (YaTeX-hierarchy-next 0) | |
288 (push-mark p t) | |
289 (message "Mark set to last position")))) | |
290 | |
291 (defun YaTeX-hierarchy-kill-buffer (arg) | |
292 "Kill buffer associated with current line's file." | |
293 (interactive "p") | |
294 (YaTeX-hierarchy-next 0) ;move to file name column | |
295 (if (bolp) (error "Not on file name line")) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
296 (let ((file (buffer-substring |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
297 (point) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
298 (progn (skip-chars-forward "^ \t") (point))))) |
52 | 299 (YaTeX-hierarchy-next arg) |
300 (cond | |
301 ((get-buffer file) | |
302 (kill-buffer (get-buffer file)) | |
303 (message "Buffer [%s] was killed" file)) | |
304 (t (message "Buffer [%s] is not active." file))))) | |
305 | |
306 (defun YaTeX-hierarchy-select (arg) | |
307 "Select current line's file in YaTeX document hierarchy buffer. | |
308 If ARG is non-nil, show the buffer in the next window." | |
309 (interactive "P") | |
310 (beginning-of-line) | |
311 (skip-chars-forward "- +\\|") | |
312 (or (eolp) | |
313 (let ((buffer (YaTeX-hierarchy-get-current-file-buffer))) | |
314 (if buffer ;if file was found | |
315 (if arg | |
316 (YaTeX-showup-buffer buffer nil) | |
317 (if (and YaTeX-emacs-19 window-system | |
318 (get-buffer-window buffer t)) | |
319 (goto-buffer-window buffer) ;select currently displaying | |
320 (YaTeX-switch-to-buffer-other-window buffer))))))) | |
321 | |
322 (defun YaTeX-hierarchy-show () | |
323 "Show current line's file in the next window." | |
324 (interactive) | |
325 (YaTeX-hierarchy-select t)) | |
326 | |
327 (defun YaTeX-hierarchy-mouse-select (event) | |
328 (interactive "e") | |
329 (mouse-set-point event) | |
330 (YaTeX-hierarchy-select nil)) | |
331 | |
332 (defun YaTeX-hierarchy-quit () | |
333 "Quit from YaTeX-hierarchy buffer and restore window configuration." | |
334 (interactive) | |
335 (if (or (not (featurep 'windows)) | |
336 (car YaTeX-hierarchy-saved-wc) | |
337 (and (= (car (cdr YaTeX-hierarchy-saved-wc)) win:current-config))) | |
338 (set-window-configuration (car YaTeX-hierarchy-saved-wc)) | |
339 (bury-buffer nil))) | |
340 | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
341 (defun YaTeX-hierarchy-scroll-up (arg &optional action) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
342 "Scroll up file contents of YaTeX-hierarchy." |
52 | 343 (interactive "P") |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
344 (YaTeX-hierarchy-next 0 t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
345 (let*((bufname (buffer-substring |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
346 (point) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
347 (save-excursion (skip-chars-forward "^ \t") (point)))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
348 (buf (get-buffer bufname)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
349 (cw (selected-window))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
350 (cond |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
351 ((and buf (get-buffer-window buf)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
352 (select-window (get-buffer-window buf))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
353 ((and buf (YaTeX-showup-buffer buf nil t)) t) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
354 (t (YaTeX-hierarchy-select nil))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
355 (unwind-protect |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
356 (cond |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
357 ((eq action 'down) (scroll-down arg)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
358 ((eq action 'top) (beginning-of-buffer)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
359 ((eq action 'bottom) (end-of-buffer)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
360 ((eq action 'last) (exchange-point-and-mark)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
361 (t (scroll-up arg))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
362 (select-window cw)))) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
363 |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
364 (defun YaTeX-hierarchy-scroll-down (arg) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
365 "Scroll down file contents of YaTeX-hierarchy." |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
366 (interactive "P") |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
367 (YaTeX-hierarchy-scroll-up arg 'down)) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
368 |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
369 (defun YaTeX-hierarchy-top () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
370 "Show the top of YaTeX-hierarchy inspection buffer's." |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
371 (interactive) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
372 (YaTeX-hierarchy-scroll-up nil 'top) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
373 ) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
374 |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
375 (defun YaTeX-hierarchy-bottom () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
376 "Show the top of YaTeX-hierarchy inspection buffer's." |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
377 (interactive) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
378 (YaTeX-hierarchy-scroll-up nil 'bottom) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
379 ) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
380 |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
381 (defun YaTeX-hierarchy-lastpos () |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
382 "Go to last position in YaTeX-hierarchy buffer." |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
383 (interactive) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
384 (YaTeX-hierarchy-scroll-up nil 'last) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
385 ) |
52 | 386 |
387 ;; ----- Setting up keymap ----- | |
388 (defvar YaTeX-hierarchy-mode-map nil "Keymap used in YaTeX-hierarchy-mode.") | |
389 (if YaTeX-hierarchy-mode-map nil | |
390 (setq YaTeX-hierarchy-mode-map (make-sparse-keymap)) | |
391 (define-key YaTeX-hierarchy-mode-map "n" 'YaTeX-hierarchy-next) | |
392 (define-key YaTeX-hierarchy-mode-map "p" 'YaTeX-hierarchy-prev) | |
393 (define-key YaTeX-hierarchy-mode-map "j" 'YaTeX-hierarchy-next-line) | |
394 (define-key YaTeX-hierarchy-mode-map "k" 'YaTeX-hierarchy-prev-line) | |
395 (substitute-all-key-definition | |
396 'next-line 'YaTeX-hierarchy-next-line YaTeX-hierarchy-mode-map) | |
397 (substitute-all-key-definition | |
398 'previous-line 'YaTeX-hierarchy-prev-line YaTeX-hierarchy-mode-map) | |
399 (define-key YaTeX-hierarchy-mode-map "N" 'YaTeX-hierarchy-forward) | |
400 (define-key YaTeX-hierarchy-mode-map "P" 'YaTeX-hierarchy-backward) | |
401 (define-key YaTeX-hierarchy-mode-map "u" 'YaTeX-hierarchy-up-document) | |
402 (define-key YaTeX-hierarchy-mode-map "K" 'YaTeX-hierarchy-kill-buffer) | |
403 (define-key YaTeX-hierarchy-mode-map "1" 'delete-other-windows) | |
404 (define-key YaTeX-hierarchy-mode-map "o" 'other-window) | |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
405 (define-key YaTeX-hierarchy-mode-map "-" 'shrink-window) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
406 (define-key YaTeX-hierarchy-mode-map "+" 'enlarge-window) |
52 | 407 (define-key YaTeX-hierarchy-mode-map "." 'YaTeX-hierarchy-show) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
408 (define-key YaTeX-hierarchy-mode-map " " 'YaTeX-hierarchy-scroll-up) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
409 (define-key YaTeX-hierarchy-mode-map "b" 'YaTeX-hierarchy-scroll-down) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
410 (define-key YaTeX-hierarchy-mode-map "\C-?" 'YaTeX-hierarchy-scroll-down) |
52 | 411 (define-key YaTeX-hierarchy-mode-map "\C-m" 'YaTeX-hierarchy-select) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
412 (define-key YaTeX-hierarchy-mode-map "<" 'YaTeX-hierarchy-top) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
413 (define-key YaTeX-hierarchy-mode-map ">" 'YaTeX-hierarchy-bottom) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
414 (define-key YaTeX-hierarchy-mode-map "'" 'YaTeX-hierarchy-lastpos) |
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
52
diff
changeset
|
415 (define-key YaTeX-hierarchy-mode-map "g" 'YaTeX-hierarchy-select) |
52 | 416 (define-key YaTeX-hierarchy-mode-map "q" 'YaTeX-hierarchy-quit) |
417 (define-key YaTeX-hierarchy-mode-map "?" 'describe-mode) | |
418 (if (and YaTeX-emacs-19 window-system) | |
419 (define-key YaTeX-hierarchy-mode-map | |
420 [mouse-2] 'YaTeX-hierarchy-mouse-select)) | |
421 ) | |
422 | |
423 (provide 'yatexhie) | |
424 ;;end of yatexhie.el |