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