Mercurial > hgrepos > hgweb.cgi > yatex
annotate yatexhlp.el @ 364:d69fd7b1ac4d dev yatex-1.78
yatex-1.78
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Fri, 26 Dec 2014 01:02:52 +0900 |
parents | 5465428f5a68 |
children | 77a2fd4fd634 |
rev | line source |
---|---|
287 | 1 ;;; yatexhlp.el --- YaTeX helper with LaTeX commands and macros |
2 ;;; | |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
339
diff
changeset
|
3 ;;; (c)1994,1998,2004,2014 by HIROSE Yuuji.[yuuji@yatex.org] |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
4 ;;; Last modified Sun Dec 21 22:55:07 2014 on firestorm |
364 | 5 ;;; $Id: yatexhlp.el,v 1.78 2014/12/25 15:11:02 yuuji Rel $ |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
6 |
287 | 7 ;;; Code: |
46 | 8 (let ((help-file (concat "YATEXHLP." |
9 (cond (YaTeX-japan "jp") | |
10 (t "eng")))) | |
11 (help-dir | |
49 | 12 (cond |
68 | 13 ((and (boundp 'site-directory) site-directory) site-directory) |
80 | 14 ((string-match "\\.app/" doc-directory) ;For Emacs.app(Darwin) |
15 (expand-file-name "../site-lisp" doc-directory)) | |
59 | 16 (YaTeX-emacs-19 (expand-file-name "../../site-lisp" doc-directory)) |
49 | 17 (t exec-directory)))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
18 (defvar YaTeX-help-file |
46 | 19 (expand-file-name help-file help-dir) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
20 "*Help file of LaTeX/TeX commands or macros.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
21 (defvar YaTeX-help-file-private |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
22 (expand-file-name (concat "~/" help-file)) |
68 | 23 "*Private help file of LaTeX/TeX macros.")) |
24 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
25 (defvar YaTeX-help-delimiter "\C-_" "Delimiter of each help entry.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
26 (defvar YaTeX-help-entry-map (copy-keymap YaTeX-mode-map) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
27 "Key map used in help entry.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
28 (defvar YaTeX-help-file-current nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
29 "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
|
30 (defvar YaTeX-help-command-current nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
31 "Holds command name on which the user currently write description.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
32 (defvar YaTeX-help-saved-config nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
33 "Holds window configruation before the editing of manual.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
34 (defvar YaTeX-help-synopsis |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
35 (cond (YaTeX-japan "yz") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
36 (t "[[ Synopsis ]]")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
37 "Section header of synopsis.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
38 (defvar YaTeX-help-description |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
39 (cond (YaTeX-japan "yz") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
40 (t "[[ Description ]]")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
41 "Section header of description.") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
42 |
80 | 43 (defvar YaTeX-help-mode-map nil "Keymap used in YaTeX-help buffer") |
44 (if YaTeX-help-mode-map nil | |
45 (setq YaTeX-help-mode-map (make-sparse-keymap)) | |
46 (let ((map YaTeX-help-mode-map)) | |
47 (suppress-keymap map) | |
353
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
339
diff
changeset
|
48 (define-key map "j" (function (lambda () (interactive) (scroll-up 1)))) |
2a72779d9c50
Rewrite lambda notations to suppress annoying warnings from emacs24
HIROSE Yuuji <yuuji@gentei.org>
parents:
339
diff
changeset
|
49 (define-key map "k" (function (lambda () (interactive) (scroll-up -1)))) |
80 | 50 (define-key map "n" 'next-line) |
51 (define-key map "p" 'previous-line) | |
52 (define-key map " " 'scroll-up) | |
53 (define-key map "\C-?" 'scroll-down) | |
54 (define-key map "o" 'other-window) | |
55 (define-key map "h" 'describe-bindings) | |
56 (define-key map "q" 'YaTeX-help-quit) | |
57 (define-key map "<" 'beginning-of-buffer) | |
58 (define-key map ">" 'end-of-buffer))) | |
59 | |
60 (defun YaTeX-help-quit () | |
61 "Close help and return to privious buffer" | |
62 (interactive) | |
63 (bury-buffer (current-buffer)) | |
64 (set-window-configuration YaTeX-help-saved-config)) | |
65 | |
23 | 66 (defvar YaTeX-help-reference-regexp "<refer\\s +\\([^>]+\\)>" |
67 "Regexp of reference format of YaTeX-help file.") | |
68 (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp") | |
69 | |
70 (defun YaTeX-help-entries () | |
71 "Return the alist which contains all the entries in YaTeX-help file." | |
72 (let (entries entry) | |
73 (save-excursion | |
74 (mapcar | |
75 (function | |
76 (lambda (help) | |
77 (if (file-exists-p help) | |
78 (progn | |
79 (set-buffer (find-file-noselect help)) | |
80 (save-excursion | |
81 (goto-char (point-min)) | |
82 (while (re-search-forward | |
83 (concat "^" (regexp-quote YaTeX-help-delimiter) | |
84 "\\(.+\\)$") nil t) | |
85 (setq entry (buffer-substring | |
86 (match-beginning 1) (match-end 1))) | |
87 (or (assoc entry entries) | |
88 (setq entries (cons (list entry) entries))))))))) | |
89 (list YaTeX-help-file YaTeX-help-file-private))) | |
80 | 90 entries)) |
23 | 91 |
80 | 92 (defvar YaTeX-help-entries nil |
93 "Helo entries alist.") | |
94 (setq YaTeX-help-entries (YaTeX-help-entries)) | |
23 | 95 |
96 (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list) | |
97 "Replace reference format in buffer1 with refered contents in buffer2." | |
98 (let (ref ref-list beg end) | |
99 (save-excursion | |
100 (switch-to-buffer buffer1) | |
101 (goto-char (point-min)) | |
102 (while (re-search-forward YaTeX-help-reference-regexp nil t) | |
103 (setq ref (buffer-substring (match-beginning 1) (match-end 1)) | |
104 ref-list (cons (list ref) ref-list)) | |
105 (replace-match "") | |
106 (if (assoc ref done-list) nil ;already documented. | |
107 (switch-to-buffer buffer2) | |
108 (save-excursion | |
109 (goto-char (point-min)) | |
110 (if (re-search-forward | |
111 (concat (regexp-quote YaTeX-help-delimiter) | |
112 (regexp-quote ref) | |
113 "$") nil t) | |
114 (progn | |
115 (setq beg (progn (forward-line 2) (point)) | |
116 end (progn | |
117 (re-search-forward | |
118 (concat "^" (regexp-quote YaTeX-help-delimiter)) | |
119 nil 1) | |
120 (goto-char (match-beginning 0)) | |
121 (forward-line -1) | |
122 (while (and (bolp) (eolp) (not (bobp))) | |
123 (forward-char -1)) | |
124 (point))) | |
125 (switch-to-buffer buffer1) | |
126 (insert-buffer-substring buffer2 beg end)))) | |
127 (switch-to-buffer buffer1))) | |
128 (if beg (YaTeX-help-resolve-reference | |
80 | 129 buffer1 buffer2 (append done-list ref-list)))))) |
23 | 130 |
131 (defun YaTeX-refer-help (command help-file &optional append) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
132 "Refer the COMMAND's help into HELP-FILE. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
133 \[Help-file format\] |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
134 <DELIM><LaTeX/TeX command without escape character(\\)><NL> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
135 <Synopsis><NL> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
136 <Documentation><TERM> |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
137 Where: <DELIM> is the value of YaTeX-help-delimiter. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
138 <NL> is newline. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
139 <TERM> is newline or end of buffer." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
140 (let ((hfbuf (find-file-noselect help-file)) |
23 | 141 (hbuf (get-buffer-create YaTeX-help-buffer)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
142 (curwin (selected-window)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
143 sb se db de) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
144 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
145 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
146 (if (null |
23 | 147 (let ((case-fold-search nil)) |
148 (re-search-forward | |
149 (concat (regexp-quote YaTeX-help-delimiter) | |
150 (regexp-quote command) | |
151 "$") nil t))) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
152 nil ;if not found, return nil |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
153 (forward-line 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
154 (setq sb (point) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
155 se (progn (forward-line 1) (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
156 db (point) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
157 de (progn |
23 | 158 (re-search-forward |
159 (concat "^" (regexp-quote YaTeX-help-delimiter)) nil 1) | |
160 (- (point) (length YaTeX-help-delimiter)))) | |
161 (YaTeX-showup-buffer | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
162 hbuf 'YaTeX-showup-buffer-bottom-most t) |
59 | 163 (set-buffer hbuf) |
80 | 164 (setq buffer-read-only nil) |
23 | 165 (if append (goto-char (point-max)) (erase-buffer)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
166 (insert YaTeX-help-synopsis "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
167 (insert-buffer-substring hfbuf sb se) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
168 (insert "\n" YaTeX-help-description "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
169 (insert-buffer-substring hfbuf db de) |
23 | 170 (YaTeX-help-resolve-reference hbuf hfbuf (list (list command))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
171 (goto-char (point-min)) |
80 | 172 (setq buffer-read-only t) |
173 (set-buffer-modified-p nil) | |
174 (YaTeX-help-mode) | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
175 (select-window curwin) |
80 | 176 t))) |
177 | |
178 (defun YaTeX-help-mode () | |
179 (interactive) | |
180 (use-local-map YaTeX-help-mode-map) | |
181 (setq major-mode 'yatex-help-mode | |
182 mode-name "YaTeX-HELP")) | |
183 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
184 (defun YaTeX-help-newline (&optional arg) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
185 (interactive "P") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
186 (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
187 (let ((cbuf (current-buffer))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
188 (beginning-of-line) |
53
5f4b18da14b3
Fix functions relating YaTeX-beginning-of-environment or
yuuji
parents:
49
diff
changeset
|
189 (delete-region (point) (progn (forward-line 1) (point))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
190 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
191 (YaTeX-help-add-entry |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
192 YaTeX-help-command-current YaTeX-help-file-current)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
193 (set-window-configuration YaTeX-help-saved-config) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
194 (bury-buffer cbuf)) |
80 | 195 (newline arg))) |
196 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
197 (defun YaTeX-help-add-entry (command help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
198 (let ((hfbuf (find-file-noselect help-file)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
199 (dbuf (current-buffer)) beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
200 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
201 (re-search-forward (concat "^" (regexp-quote YaTeX-help-synopsis))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
202 (forward-line 1) (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
203 (end-of-line) (setq end (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
204 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
205 (goto-char (point-min)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
206 (insert YaTeX-help-delimiter command "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
207 (insert-buffer-substring dbuf beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
208 (insert "\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
209 (set-buffer dbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
210 (re-search-forward (concat "^" (regexp-quote YaTeX-help-description))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
211 (forward-line 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
212 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
213 (setq end (point-max)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
214 (set-buffer hfbuf) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
215 (insert-buffer-substring dbuf beg end) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
216 (insert "\n\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
217 (forward-line -1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
218 (delete-blank-lines) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
219 (let ((make-backup-files t)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
220 (basic-save-buffer)) |
23 | 221 (bury-buffer hfbuf) |
80 | 222 (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries)))) |
223 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
224 (defun YaTeX-help-prepare-entry (command help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
225 "Read help description on COMMAND and add it to HELP-FILE." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
226 (let ((buf (get-buffer-create "**Description**")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
227 (conf (current-window-configuration))) |
23 | 228 (YaTeX-showup-buffer |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
229 buf 'YaTeX-showup-buffer-bottom-most t) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
230 (make-local-variable 'YaTeX-help-file-current) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
231 (make-local-variable 'YaTeX-help-command-current) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
232 (make-local-variable 'YaTeX-help-saved-config) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
233 (setq YaTeX-help-file-current help-file |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
234 YaTeX-help-command-current command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
235 YaTeX-help-saved-config conf |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
236 mode-name "Text" |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
237 major-mode 'text) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
238 (erase-buffer) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
239 (insert YaTeX-help-synopsis "\n\n" YaTeX-help-description "\n\n") |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
240 (define-key YaTeX-help-entry-map "\r" 'YaTeX-help-newline) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
241 (use-local-map YaTeX-help-entry-map) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
242 (message |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
243 (cond (YaTeX-japan "͂I . ̂ݓ͂RET") |
80 | 244 (t "Type only `.' and RET to exit."))))) |
245 | |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
246 (defun YaTeX-enrich-help (command) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
247 "Add the COMMAND's help to help file." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
248 (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
|
249 (YaTeX-help-prepare-entry |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
250 command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
251 (if (y-or-n-p "Add help to global documentation?") |
80 | 252 YaTeX-help-file YaTeX-help-file-private)))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
253 |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
254 (defun YaTeX-help-sort (&optional help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
255 "Sort help file HELP-FILE. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
256 If HELP-FILE is nil or called interactively, sort current buffer |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
257 as a help file." |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
258 (interactive) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
259 (if help-file (set-buffer (find-file-noselect help-file))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
260 (sort-regexp-fields |
80 | 261 nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
262 |
23 | 263 (defun YaTeX-apropos-file (keyword help-file &optional append) |
264 (let ((hb (find-file-noselect help-file)) | |
265 (ab (get-buffer-create YaTeX-help-buffer)) | |
266 (sw (selected-window)) | |
267 (head (concat "^" (regexp-quote YaTeX-help-delimiter))) | |
268 pt command) | |
354
5465428f5a68
`[prefix] t e' displays typesetting image in the next window, if possible.
HIROSE Yuuji <yuuji@gentei.org>
parents:
353
diff
changeset
|
269 (YaTeX-showup-buffer ab 'YaTeX-showup-buffer-bottom-most) |
23 | 270 (select-window (get-buffer-window ab)) |
271 (set-buffer ab) ;assertion | |
80 | 272 (setq buffer-read-only nil) |
23 | 273 (or append (erase-buffer)) |
274 (set-buffer hb) | |
275 (goto-char (point-min)) | |
276 (while (re-search-forward keyword nil t) | |
277 (setq pt (point)) | |
278 (re-search-backward head nil t) | |
279 (setq command (buffer-substring (match-end 0) (point-end-of-line))) | |
280 (switch-to-buffer ab) | |
281 (goto-char (point-max)) | |
282 (insert-char ?- (1- (window-width))) | |
283 (insert (format "\n<<%s>>\n" command)) | |
284 (YaTeX-refer-help command help-file t) ;append mode | |
80 | 285 (setq buffer-read-only nil) |
23 | 286 (set-buffer hb) |
287 (goto-char pt) | |
288 (if (re-search-forward head nil 1) | |
289 (goto-char (1- (match-beginning 0))))) | |
80 | 290 (setq buffer-read-only t) |
23 | 291 (select-window sw) |
80 | 292 pt)) |
23 | 293 |
294 ;;;###autoload | |
295 (defun YaTeX-apropos (key) | |
296 (interactive "sLaTeX apropos (regexp): ") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
53
diff
changeset
|
297 (if (string= "" key) (error "Nothing to show")) |
80 | 298 (setq YaTeX-help-saved-config (current-window-configuration)) |
23 | 299 (or (YaTeX-apropos-file key YaTeX-help-file) |
300 (YaTeX-apropos-file key YaTeX-help-file-private t) | |
80 | 301 (message "No matches found."))) |
23 | 302 |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
303 ;;;###autoload |
339
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
304 (defun YaTeX-help (&optional macro) |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
305 "Show help buffer of LaTeX/TeX commands or macros. |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
306 Optional argument MACRO, if supplied, is directly selected to keyword." |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
307 (interactive) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
308 (let (p beg end command) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
309 (save-excursion |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
310 (if (looking-at YaTeX-ec-regexp) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
311 (goto-char (match-end 0))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
312 (setq p (point)) ;remember current position. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
313 (cond |
339
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
314 (macro nil) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
315 ((YaTeX-on-begin-end-p) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
316 ;;if on \begin or \end, extract its environment. |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
317 (setq command |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
318 (cond ((match-beginning 1) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
319 (buffer-substring (match-beginning 1) (match-end 1))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
320 ((match-beginning 2) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
321 (buffer-substring (match-beginning 2) (match-end 2)))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
322 ((search-backward YaTeX-ec (point-beginning-of-line) t) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
323 (goto-char (setq beg (match-end 0))) |
23 | 324 (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
|
325 (setq end (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
326 (if (and (<= beg p) (<= p end)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
327 (setq command (buffer-substring beg end))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
328 (if (or (string= command "begin") (string= command "end")) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
329 (progn |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
330 (search-forward "{" (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
331 (setq beg (point)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
332 (search-forward "}" (point-end-of-line)) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
333 (setq command (buffer-substring beg (match-beginning 0))))) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
334 (setq command |
339
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
335 (or macro |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
336 (completing-read |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
337 "Describe (La)TeX command: " |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
338 YaTeX-help-entries nil nil command))));end excursion |
9c39aa8a50e9
YaTeX-help takes one optional argument which directly taken as keyword.
HIROSE Yuuji <yuuji@gentei.org>
parents:
287
diff
changeset
|
339 |
80 | 340 (setq YaTeX-help-saved-config (current-window-configuration)) |
16
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
341 (or (YaTeX-refer-help command YaTeX-help-file) |
cb9afa9c1213
Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff
changeset
|
342 (YaTeX-refer-help command YaTeX-help-file-private) |
80 | 343 (YaTeX-enrich-help command)))) |