Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexhlp.el @ 46:cd1b63102eed
Support Mule2
author | yuuji |
---|---|
date | Mon, 19 Sep 1994 16:54:19 +0000 |
parents | b00c74813e56 |
children | eb0512bfcb7f |
rev | line source |
---|---|
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
1 ;;; -*- Emacs-Lisp -*- |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
2 ;;; YaTeX helper with LaTeX commands and macros. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
3 ;;; yatexhlp.el |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
4 ;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] |
46 | 5 ;;; Last modified Tue Sep 20 01:35:12 1994 on figaro |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
6 ;;; $Id$ |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
7 |
46 | 8 (let ((help-file (concat "YATEXHLP." |
9 (cond (YaTeX-japan "jp") | |
10 (t "eng")))) | |
11 (help-dir | |
12 (cond (YaTeX-emacs-19 (expand-file-name "../etc" exec-directory)) | |
13 (t exec-directory)))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
14 (defvar YaTeX-help-file |
46 | 15 (expand-file-name help-file help-dir) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
16 "*Help file of LaTeX/TeX commands or macros.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
17 (defvar YaTeX-help-file-private |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
18 (expand-file-name (concat "~/" help-file)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
19 "*Private help file of LaTeX/TeX macros.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
20 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
21 (defvar YaTeX-help-delimiter "\C-_" "Delimiter of each help entry.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
22 (defvar YaTeX-help-entry-map (copy-keymap YaTeX-mode-map) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
23 "Key map used in help entry.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
24 (defvar YaTeX-help-file-current nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
25 "Holds help file name to which the description in current buffer should go.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
26 (defvar YaTeX-help-command-current nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
27 "Holds command name on which the user currently write description.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
28 (defvar YaTeX-help-saved-config nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
29 "Holds window configruation before the editing of manual.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
30 (defvar YaTeX-help-synopsis |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
31 (cond (YaTeX-japan "【書式】") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
32 (t "[[ Synopsis ]]")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
33 "Section header of synopsis.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
34 (defvar YaTeX-help-description |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
35 (cond (YaTeX-japan "【説明】") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
36 (t "[[ Description ]]")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
37 "Section header of description.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
38 |
23 | 39 (defvar YaTeX-help-reference-regexp "<refer\\s +\\([^>]+\\)>" |
40 "Regexp of reference format of YaTeX-help file.") | |
41 (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp") | |
42 | |
43 (defun YaTeX-help-entries () | |
44 "Return the alist which contains all the entries in YaTeX-help file." | |
45 (let (entries entry) | |
46 (save-excursion | |
47 (mapcar | |
48 (function | |
49 (lambda (help) | |
50 (if (file-exists-p help) | |
51 (progn | |
52 (set-buffer (find-file-noselect help)) | |
53 (save-excursion | |
54 (goto-char (point-min)) | |
55 (while (re-search-forward | |
56 (concat "^" (regexp-quote YaTeX-help-delimiter) | |
57 "\\(.+\\)$") nil t) | |
58 (setq entry (buffer-substring | |
59 (match-beginning 1) (match-end 1))) | |
60 (or (assoc entry entries) | |
61 (setq entries (cons (list entry) entries))))))))) | |
62 (list YaTeX-help-file YaTeX-help-file-private))) | |
63 entries) | |
64 ) | |
65 | |
66 (defvar YaTeX-help-entries (YaTeX-help-entries)) | |
67 | |
68 (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list) | |
69 "Replace reference format in buffer1 with refered contents in buffer2." | |
70 (let (ref ref-list beg end) | |
71 (save-excursion | |
72 (switch-to-buffer buffer1) | |
73 (goto-char (point-min)) | |
74 (while (re-search-forward YaTeX-help-reference-regexp nil t) | |
75 (setq ref (buffer-substring (match-beginning 1) (match-end 1)) | |
76 ref-list (cons (list ref) ref-list)) | |
77 (replace-match "") | |
78 (if (assoc ref done-list) nil ;already documented. | |
79 (switch-to-buffer buffer2) | |
80 (save-excursion | |
81 (goto-char (point-min)) | |
82 (if (re-search-forward | |
83 (concat (regexp-quote YaTeX-help-delimiter) | |
84 (regexp-quote ref) | |
85 "$") nil t) | |
86 (progn | |
87 (setq beg (progn (forward-line 2) (point)) | |
88 end (progn | |
89 (re-search-forward | |
90 (concat "^" (regexp-quote YaTeX-help-delimiter)) | |
91 nil 1) | |
92 (goto-char (match-beginning 0)) | |
93 (forward-line -1) | |
94 (while (and (bolp) (eolp) (not (bobp))) | |
95 (forward-char -1)) | |
96 (point))) | |
97 (switch-to-buffer buffer1) | |
98 (insert-buffer-substring buffer2 beg end)))) | |
99 (switch-to-buffer buffer1))) | |
100 (if beg (YaTeX-help-resolve-reference | |
101 buffer1 buffer2 (append done-list ref-list)))) | |
102 ) | |
103 ) | |
104 | |
105 (defun YaTeX-refer-help (command help-file &optional append) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
106 "Refer the COMMAND's help into HELP-FILE. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
107 \[Help-file format\] |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
108 <DELIM><LaTeX/TeX command without escape character(\\)><NL> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
109 <Synopsis><NL> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
110 <Documentation><TERM> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
111 Where: <DELIM> is the value of YaTeX-help-delimiter. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
112 <NL> is newline. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
113 <TERM> is newline or end of buffer." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
114 (let ((hfbuf (find-file-noselect help-file)) |
23 | 115 (hbuf (get-buffer-create YaTeX-help-buffer)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
116 (curwin (selected-window)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
117 sb se db de) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
118 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
119 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
120 (if (null |
23 | 121 (let ((case-fold-search nil)) |
122 (re-search-forward | |
123 (concat (regexp-quote YaTeX-help-delimiter) | |
124 (regexp-quote command) | |
125 "$") nil t))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
126 nil ;if not found, return nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
127 (forward-line 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
128 (setq sb (point) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
129 se (progn (forward-line 1) (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
130 db (point) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
131 de (progn |
23 | 132 (re-search-forward |
133 (concat "^" (regexp-quote YaTeX-help-delimiter)) nil 1) | |
134 (- (point) (length YaTeX-help-delimiter)))) | |
135 (YaTeX-showup-buffer | |
136 hbuf (function (lambda (x) (nth 3 (window-edges x))))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
137 (pop-to-buffer hbuf) |
23 | 138 (if append (goto-char (point-max)) (erase-buffer)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
139 (insert YaTeX-help-synopsis "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
140 (insert-buffer-substring hfbuf sb se) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
141 (insert "\n" YaTeX-help-description "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
142 (insert-buffer-substring hfbuf db de) |
23 | 143 (YaTeX-help-resolve-reference hbuf hfbuf (list (list command))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
144 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
145 (select-window curwin) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
146 t)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
147 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
148 (defun YaTeX-help-newline (&optional arg) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
149 (interactive "P") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
150 (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
151 (let ((cbuf (current-buffer))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
152 (beginning-of-line) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
153 (kill-line 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
154 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
155 (YaTeX-help-add-entry |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
156 YaTeX-help-command-current YaTeX-help-file-current)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
157 (set-window-configuration YaTeX-help-saved-config) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
158 (bury-buffer cbuf)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
159 (newline arg)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
160 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
161 (defun YaTeX-help-add-entry (command help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
162 (let ((hfbuf (find-file-noselect help-file)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
163 (dbuf (current-buffer)) beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
164 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
165 (re-search-forward (concat "^" (regexp-quote YaTeX-help-synopsis))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
166 (forward-line 1) (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
167 (end-of-line) (setq end (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
168 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
169 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
170 (insert YaTeX-help-delimiter command "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
171 (insert-buffer-substring dbuf beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
172 (insert "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
173 (set-buffer dbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
174 (re-search-forward (concat "^" (regexp-quote YaTeX-help-description))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
175 (forward-line 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
176 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
177 (setq end (point-max)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
178 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
179 (insert-buffer-substring dbuf beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
180 (insert "\n\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
181 (forward-line -1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
182 (delete-blank-lines) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
183 (let ((make-backup-files t)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
184 (basic-save-buffer)) |
23 | 185 (bury-buffer hfbuf) |
186 (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
187 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
188 (defun YaTeX-help-prepare-entry (command help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
189 "Read help description on COMMAND and add it to HELP-FILE." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
190 (let ((buf (get-buffer-create "**Description**")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
191 (conf (current-window-configuration))) |
23 | 192 (YaTeX-showup-buffer |
193 buf (function (lambda (x) (nth 3 (window-edges x))))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
194 (pop-to-buffer buf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
195 (make-local-variable 'YaTeX-help-file-current) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
196 (make-local-variable 'YaTeX-help-command-current) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
197 (make-local-variable 'YaTeX-help-saved-config) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
198 (setq YaTeX-help-file-current help-file |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
199 YaTeX-help-command-current command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
200 YaTeX-help-saved-config conf |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
201 mode-name "Text" |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
202 major-mode 'text) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
203 (erase-buffer) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
204 (insert YaTeX-help-synopsis "\n\n" YaTeX-help-description "\n\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
205 (define-key YaTeX-help-entry-map "\r" 'YaTeX-help-newline) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
206 (use-local-map YaTeX-help-entry-map) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
207 (message |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
208 (cond (YaTeX-japan "入力を終えたら . のみ入力してRET") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
209 (t "Type only `.' and RET to exit.")))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
210 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
211 (defun YaTeX-enrich-help (command) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
212 "Add the COMMAND's help to help file." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
213 (if (y-or-n-p (format "No help on `%s'. Create help?" command)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
214 (YaTeX-help-prepare-entry |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
215 command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
216 (if (y-or-n-p "Add help to global documentation?") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
217 YaTeX-help-file YaTeX-help-file-private))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
218 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
219 |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
220 (defun YaTeX-help-sort (&optional help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
221 "Sort help file HELP-FILE. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
222 If HELP-FILE is nil or called interactively, sort current buffer |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
223 as a help file." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
224 (interactive) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
225 (if help-file (set-buffer (find-file-noselect help-file))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
226 (sort-regexp-fields |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
227 nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
228 ) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
229 |
23 | 230 (defun YaTeX-apropos-file (keyword help-file &optional append) |
231 (let ((hb (find-file-noselect help-file)) | |
232 (ab (get-buffer-create YaTeX-help-buffer)) | |
233 (sw (selected-window)) | |
234 (head (concat "^" (regexp-quote YaTeX-help-delimiter))) | |
235 pt command) | |
236 (YaTeX-showup-buffer | |
237 ab (function (lambda (x) (nth 3 (window-edges x))))) | |
238 (select-window (get-buffer-window ab)) | |
239 (set-buffer ab) ;assertion | |
240 (or append (erase-buffer)) | |
241 (set-buffer hb) | |
242 (goto-char (point-min)) | |
243 (while (re-search-forward keyword nil t) | |
244 (setq pt (point)) | |
245 (re-search-backward head nil t) | |
246 (setq command (buffer-substring (match-end 0) (point-end-of-line))) | |
247 (switch-to-buffer ab) | |
248 (goto-char (point-max)) | |
249 (insert-char ?- (1- (window-width))) | |
250 (insert (format "\n<<%s>>\n" command)) | |
251 (YaTeX-refer-help command help-file t) ;append mode | |
252 (set-buffer hb) | |
253 (goto-char pt) | |
254 (if (re-search-forward head nil 1) | |
255 (goto-char (1- (match-beginning 0))))) | |
256 (select-window sw) | |
257 pt) | |
258 ) | |
259 | |
260 ;;;###autoload | |
261 (defun YaTeX-apropos (key) | |
262 (interactive "sLaTeX apropos (regexp): ") | |
263 (or (YaTeX-apropos-file key YaTeX-help-file) | |
264 (YaTeX-apropos-file key YaTeX-help-file-private t) | |
265 (message "No matches found.")) | |
266 ) | |
267 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
268 ;;;###autoload |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
269 (defun YaTeX-help () |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
270 "Show help buffer of LaTeX/TeX commands or macros." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
271 (interactive) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
272 (let (p beg end command) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
273 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
274 (if (looking-at YaTeX-ec-regexp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
275 (goto-char (match-end 0))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
276 (setq p (point)) ;remember current position. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
277 (cond |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
278 ((YaTeX-on-begin-end-p) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
279 ;;if on \begin or \end, extract its environment. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
280 (setq command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
281 (cond ((match-beginning 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
282 (buffer-substring (match-beginning 1) (match-end 1))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
283 ((match-beginning 2) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
284 (buffer-substring (match-beginning 2) (match-end 2)))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
285 ((search-backward YaTeX-ec (point-beginning-of-line) t) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
286 (goto-char (setq beg (match-end 0))) |
23 | 287 (re-search-forward YaTeX-TeX-token-regexp (point-end-of-line) t) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
288 (setq end (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
289 (if (and (<= beg p) (<= p end)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
290 (setq command (buffer-substring beg end))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
291 (if (or (string= command "begin") (string= command "end")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
292 (progn |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
293 (search-forward "{" (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
294 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
295 (search-forward "}" (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
296 (setq command (buffer-substring beg (match-beginning 0))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
297 (setq command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
298 (completing-read |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
299 "Describe (La)TeX command: " |
23 | 300 YaTeX-help-entries nil nil command)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
301 );end excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
302 (or (YaTeX-refer-help command YaTeX-help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
303 (YaTeX-refer-help command YaTeX-help-file-private) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
304 (YaTeX-enrich-help command))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
305 ) |