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