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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
1 ;;; -*- Emacs-Lisp -*-
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
2 ;;; YaTeX hierarchy browser.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
6 ;;; $Id$
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
7
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
12
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
13 ;; ----- General variables -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
14 (defvar YaTeX-default-TeX-extensions "\\.\\(tex\\|sty\\)")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
15 (defvar YaTeX-hierarchy-current-main nil)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
16 (defvar YaTeX-hierarchy-buffer-message
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
21 (defvar YaTeX-hierarchy-saved-wc nil "Saved window configuration.")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
22
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
23 ;; ----- Functions for parsing hierarchy -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
24
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
25 (defun YaTeX-all-included-files (&optional file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
26 "Return all included files from FILE as a list.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
27 If FILE is nil, use current buffer."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
28 (save-excursion
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
29 (let ((include-regex (concat YaTeX-ec-regexp
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
30 "\\(\\(input\\)\\|" ;match#2
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
31 "\\(include\\)\\)\\b")) ;match#3
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
32 list file (cb (current-buffer)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
33 (if file (set-buffer (YaTeX-switch-to-buffer file t)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
34 (goto-char (point-min))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
35 (while (YaTeX-re-search-active-forward
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
36 include-regex YaTeX-comment-prefix nil t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
37 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
38 ((match-beginning 2) ;\input, {} is optional, 1 argument
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
39 (skip-chars-forward " {")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
40 (setq file (buffer-substring
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
41 (point)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
42 (progn
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
43 (skip-chars-forward
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
44 (concat "^ \t\n\r" YaTeX-ec-regexp "{}"))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
45 (point)))))
68
0eb6997bee16 More adjustment for Emacs20 and XEmacs
yuuji
parents: 53
diff changeset
46 ((and (match-beginning 3) (looking-at "{"))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
47 (skip-chars-forward "{")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
48 (setq file (buffer-substring
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
49 (point)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
50 (progn
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
51 (forward-char -1) (forward-list 1) (1- (point)))))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
52 (or (string-match YaTeX-default-TeX-extensions file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
53 (setq file (concat file ".tex")))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
54 (setq list (cons file list)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
55 (set-buffer cb)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
56 (nreverse list))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
57
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
58 (defun YaTeX-document-hierarchy (&optional file basedir)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
59 "Return the document hierarchy beginning from FILE as a list.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
60 If FILE is nil, beginning with current buffer's file."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
61 (setq file (or file buffer-file-name))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
62 (and YaTeX-search-file-from-top-directory
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
63 (not (file-exists-p file))
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
64 (string-match "^[^/].*/" file)
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
65 (setq file (expand-file-name file basedir)))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
66 (message "Parsing [%s]..." (file-name-nondirectory file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
67 (prog1
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
68 (save-excursion
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
69 (if (or (file-exists-p file) (null file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
70 (progn
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
71 (if file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
72 (let ((parent buffer-file-name))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
73 (YaTeX-switch-to-buffer file t) ;set buffer to file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
74 (or YaTeX-parent-file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
75 (YaTeX-get-builtin "!")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
76 (setq YaTeX-parent-file parent))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
77 (cons (buffer-file-name (current-buffer))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
78 (mapcar '(lambda (f) ;return value
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
79 (YaTeX-document-hierarchy f basedir))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
80 (YaTeX-all-included-files))))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
81 (message "Parsing [%s]...done" (file-name-nondirectory file))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
82
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
83 ;; ----- Functions for displaying hierarchy -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
84
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
85 (defun YaTeX-hierarchy-get-file-heading (file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
86 "Get a FILE's heading."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
87 (save-excursion
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
88 (set-buffer (find-file-noselect file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
114
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
115 (defun YaTeX-display-a-hierachy (hier level)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
116 "Put a HIER of document hierarchy.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
117 LEVEL is including depth."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
118 (message "Formatting hierarchy buffer...")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
119 (let ((lastatomcol 0) list i p)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
120 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
121 ((listp hier)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
122 (setq list hier)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
123 (while list
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
124 (YaTeX-display-a-hierachy (car list) (1+ level))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
125 (setq list (cdr list))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
126 ((stringp hier) ;is an atom
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
127 (insert " ")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
128 (setq i level)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
129 (while (> i 2)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
130 (insert "| ")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
131 (setq i (1- i)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
132 (if (> level 1) (insert "+---"))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
133 (setq p (point))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
134 (insert (or (buffer-name (get-file-buffer hier))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
135 (file-name-nondirectory hier)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
136 (if (and window-system YaTeX-emacs-19)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
137 (put-text-property p (point) 'mouse-face 'underline))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
138 (insert " ")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
139 (indent-to-column (1- (/ (window-width) 2)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
140 (insert "% " (YaTeX-hierarchy-get-file-heading hier))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
141 (insert "\n"))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
142 (message "Formatting hierarchy buffer..."))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
143
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
144 (defun YaTeX-display-hierarchy (file &optional use-default)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
145 "Display document hierarchy that is beginning from FILE."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
146 (interactive "P")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
147 (setq YaTeX-hierarchy-saved-wc
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
148 (list (current-window-configuration)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
149 (and (featurep 'windows)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
150 (boundp 'win:current-config)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
151 win:current-config)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
152 (let*((b-in (YaTeX-get-builtin "!"))
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
153 default)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
154 ;;$B$`!<$s"-$3$N$X$s$N;EMM$I$&$7$?$i$$$$$+NI$/J,$+$i$s(B...
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
155 (if default (setq default (expand-file-name default)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
156 (YaTeX-visit-main t) ;move to parent file
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
157 (setq default buffer-file-name)
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
158 (setq file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
159 (or (if use-default default file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
160 (read-file-name
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
161 (format
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
162 "Main .tex file%s: "
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
163 (if default
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
164 (format "(default %s)"(file-name-nondirectory default))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
165 ""))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
166 "" default 1))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
167 (setq file (expand-file-name file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
168 (setq YaTeX-hierarchy-current-main file)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
169 (let ((dbuf "*document hierarchy*")
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
170 (topdir default-directory))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
171 (YaTeX-showup-buffer dbuf nil t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
172 (set-buffer (get-buffer dbuf))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
173 (setq truncate-lines t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
174 (let ((buffer-read-only nil))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
175 (erase-buffer)
70
44e3a5e1e883 Fix makefile for Windows
yuuji
parents: 68
diff changeset
176 (YaTeX-display-a-hierachy (YaTeX-document-hierarchy file topdir) 0))
52
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
177 (goto-char (point-min))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
178 (YaTeX-hierarchy-next 0)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
179 (set-buffer-modified-p nil)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
180 (YaTeX-hierarchy-mode)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
181 ))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
182
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
183 (defun YaTeX-display-hierarchy-directly ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
184 "Same as YaTeX-display-hierarchy. Call from mouse."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
185 (interactive)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
186 (YaTeX-display-hierarchy nil t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
187
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
188 (defun YaTeX-hierarchy-mode ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
189 "Major mode to browse and select document hierarchy.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
190
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
191 \\[YaTeX-hierarchy-next] next line
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
195 \\[YaTeX-hierarchy-up-document] move to parent file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
196 \\[delete-other-windows] delete other windows
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
206 \\[YaTeX-hierarchy-select] select file
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
207 \\[YaTeX-hierarchy-mouse-select] select
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
208 "
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
209 (setq major-mode 'YaTeX-hierarchy-mode
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
210 mode-name "YaTeX hier")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
211 (use-local-map YaTeX-hierarchy-mode-map)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
212 (setq buffer-read-only t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
213 (message YaTeX-hierarchy-buffer-message))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
214
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
215 ;; ----- Subfunctions for interactive functions -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
216 (defun YaTeX-hierarchy-get-current-file-buffer ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
217 "Return the buffer associated with current line's file."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
218 (let ((file (buffer-substring
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
219 (point)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
220 (save-excursion
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
221 (skip-chars-forward "^ \t" (point-end-of-line)) (point))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
222 (hilit-auto-highlight) buffer)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
223 (set-buffer (find-file-noselect YaTeX-hierarchy-current-main))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
224 (if (get-buffer file) ;buffer is active
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
225 (setq buffer (get-buffer file)) ;may contain `<2>'
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
226 (if (string-match "<[2-9]>$" file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
227 (setq file (substring file 0 -3)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
228 (save-excursion
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
229 (setq buffer (YaTeX-switch-to-buffer file t)))))) ; open it!
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
230
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
231 ;; ----- Interactive functions -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
232 (defun YaTeX-hierarchy-next (arg &optional quiet)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
233 "Move to next line's file in YaTeX document hierarchy buffer."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
234 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
235 (forward-line arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
238 (YaTeX-hierarchy-select t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
239 (message YaTeX-hierarchy-buffer-message))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
240
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
241 (defun YaTeX-hierarchy-prev (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
242 "Move to previous line's file in YaTeX document hierarchy buffer."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
243 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
244 (YaTeX-hierarchy-next (- arg)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
245
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
246 (defun YaTeX-hierarchy-next-line (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
247 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
248 (YaTeX-hierarchy-next arg t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
249
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
250 (defun YaTeX-hierarchy-prev-line (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
251 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
252 (YaTeX-hierarchy-next (- arg) t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
253
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
254 (defun YaTeX-hierarchy-forward (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
255 "Move to forward file in same hierarchy level."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
256 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
257 (YaTeX-hierarchy-next 0)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
258 (let ((p (point))(column (current-column)) (i (if (> arg 0) arg (- arg))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
259 (if (= column 0) (error "Not on file line."))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
260 (while (> i 0)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
261 (if (catch 'found
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
262 (while (and (not (eobp)) (not (bobp)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
263 (forward-line (if (> arg 0) 1 -1))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
264 (move-to-column column)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
265 (if (looking-at "[- +\\|]") nil
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
266 (YaTeX-hierarchy-next 0)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
267 (if (= (current-column) column) (throw 'found t)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
268 (beginning-of-line)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
269 nil
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
270 (goto-char p)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
271 (error "No same level file."))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
272 (setq i (1- i)))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
273
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
274 (defun YaTeX-hierarchy-backward (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
275 "Move to backward file in same hierarchy level."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
276 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
277 (YaTeX-hierarchy-forward (- arg)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
278
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
279 (defun YaTeX-hierarchy-up-document ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
280 "Up level, that is, move to parent file position."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
281 (interactive)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
282 (YaTeX-hierarchy-next 0) ;adjust column
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
283 (let ((p (point)) (line (count-lines (point-min) (point))) column)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
284 (if (or (<= line 1) (< (current-column) 6))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
285 (message "No more parent")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
286 (backward-char 1)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
287 (or (= (char-after (point)) ?-) (error "Unexpected hierarchy buffer"))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
288 (setq column (current-column))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
289 (while (and (> line 1) (looking-at "[- +\\|]"))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
290 (forward-line -1)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
291 (move-to-column column))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
292 (YaTeX-hierarchy-next 0)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
293 (push-mark p t)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
294 (message "Mark set to last position"))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
295
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
296 (defun YaTeX-hierarchy-kill-buffer (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
297 "Kill buffer associated with current line's file."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
298 (interactive "p")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
299 (YaTeX-hierarchy-next 0) ;move to file name column
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
304 (YaTeX-hierarchy-next arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
305 (cond
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
306 ((get-buffer file)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
307 (kill-buffer (get-buffer file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
308 (message "Buffer [%s] was killed" file))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
309 (t (message "Buffer [%s] is not active." file)))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
310
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
311 (defun YaTeX-hierarchy-select (arg)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
312 "Select current line's file in YaTeX document hierarchy buffer.
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
313 If ARG is non-nil, show the buffer in the next window."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
314 (interactive "P")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
315 (beginning-of-line)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
316 (skip-chars-forward "- +\\|")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
317 (or (eolp)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
318 (let ((buffer (YaTeX-hierarchy-get-current-file-buffer)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
319 (if buffer ;if file was found
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
320 (if arg
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
321 (YaTeX-showup-buffer buffer nil)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
322 (if (and YaTeX-emacs-19 window-system
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
323 (get-buffer-window buffer t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
324 (goto-buffer-window buffer) ;select currently displaying
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
325 (YaTeX-switch-to-buffer-other-window buffer)))))))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
326
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
327 (defun YaTeX-hierarchy-show ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
328 "Show current line's file in the next window."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
329 (interactive)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
330 (YaTeX-hierarchy-select t))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
331
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
332 (defun YaTeX-hierarchy-mouse-select (event)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
333 (interactive "e")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
334 (mouse-set-point event)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
335 (YaTeX-hierarchy-select nil))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
336
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
337 (defun YaTeX-hierarchy-quit ()
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
338 "Quit from YaTeX-hierarchy buffer and restore window configuration."
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
339 (interactive)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
340 (if (or (not (featurep 'windows))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
341 (car YaTeX-hierarchy-saved-wc)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
342 (and (= (car (cdr YaTeX-hierarchy-saved-wc)) win:current-config)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
343 (set-window-configuration (car YaTeX-hierarchy-saved-wc))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
344 (bury-buffer nil)))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
391
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
392 ;; ----- Setting up keymap -----
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
393 (defvar YaTeX-hierarchy-mode-map nil "Keymap used in YaTeX-hierarchy-mode.")
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
394 (if YaTeX-hierarchy-mode-map nil
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
395 (setq YaTeX-hierarchy-mode-map (make-sparse-keymap))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
396 (define-key YaTeX-hierarchy-mode-map "n" 'YaTeX-hierarchy-next)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
397 (define-key YaTeX-hierarchy-mode-map "p" 'YaTeX-hierarchy-prev)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
398 (define-key YaTeX-hierarchy-mode-map "j" 'YaTeX-hierarchy-next-line)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
399 (define-key YaTeX-hierarchy-mode-map "k" 'YaTeX-hierarchy-prev-line)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
400 (substitute-all-key-definition
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
401 'next-line 'YaTeX-hierarchy-next-line YaTeX-hierarchy-mode-map)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
402 (substitute-all-key-definition
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
403 'previous-line 'YaTeX-hierarchy-prev-line YaTeX-hierarchy-mode-map)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
404 (define-key YaTeX-hierarchy-mode-map "N" 'YaTeX-hierarchy-forward)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
405 (define-key YaTeX-hierarchy-mode-map "P" 'YaTeX-hierarchy-backward)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
406 (define-key YaTeX-hierarchy-mode-map "u" 'YaTeX-hierarchy-up-document)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
407 (define-key YaTeX-hierarchy-mode-map "K" 'YaTeX-hierarchy-kill-buffer)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
408 (define-key YaTeX-hierarchy-mode-map "1" 'delete-other-windows)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
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
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
421 (define-key YaTeX-hierarchy-mode-map "q" 'YaTeX-hierarchy-quit)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
422 (define-key YaTeX-hierarchy-mode-map "?" 'describe-mode)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
423 (if (and YaTeX-emacs-19 window-system)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
424 (define-key YaTeX-hierarchy-mode-map
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
425 [mouse-2] 'YaTeX-hierarchy-mouse-select))
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
426 )
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
427
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
428 (provide 'yatexhie)
5d94deabb9f9 Set YaTeX-indent-line to 'indent-line-function.
yuuji
parents:
diff changeset
429 ;;end of yatexhie.el

yatex.org