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