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