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