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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
37 (defvar YaTeX-help-reference-regexp "<refer\\s +\\([^>]+\\)>"
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
38 "Regexp of reference format of YaTeX-help file.")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
39 (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
40
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
41 (defun YaTeX-help-entries ()
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
42 "Return the alist which contains all the entries in YaTeX-help file."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
43 (let (entries entry)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
44 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
45 (mapcar
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
46 (function
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
47 (lambda (help)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
48 (if (file-exists-p help)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
49 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
50 (set-buffer (find-file-noselect help))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
51 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
52 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
53 (while (re-search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
54 (concat "^" (regexp-quote YaTeX-help-delimiter)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
55 "\\(.+\\)$") nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
56 (setq entry (buffer-substring
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
57 (match-beginning 1) (match-end 1)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
58 (or (assoc entry entries)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
59 (setq entries (cons (list entry) entries)))))))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
60 (list YaTeX-help-file YaTeX-help-file-private)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
61 entries)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
62 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
63
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
64 (defvar YaTeX-help-entries (YaTeX-help-entries))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
65
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
66 (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
67 "Replace reference format in buffer1 with refered contents in buffer2."
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
68 (let (ref ref-list beg end)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
69 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
70 (switch-to-buffer buffer1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
71 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
72 (while (re-search-forward YaTeX-help-reference-regexp nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
73 (setq ref (buffer-substring (match-beginning 1) (match-end 1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
74 ref-list (cons (list ref) ref-list))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
75 (replace-match "")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
76 (if (assoc ref done-list) nil ;already documented.
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
77 (switch-to-buffer buffer2)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
78 (save-excursion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
79 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
80 (if (re-search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
81 (concat (regexp-quote YaTeX-help-delimiter)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
82 (regexp-quote ref)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
83 "$") nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
84 (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
85 (setq beg (progn (forward-line 2) (point))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
86 end (progn
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
87 (re-search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
88 (concat "^" (regexp-quote YaTeX-help-delimiter))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
89 nil 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
90 (goto-char (match-beginning 0))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
91 (forward-line -1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
92 (while (and (bolp) (eolp) (not (bobp)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
93 (forward-char -1))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
94 (point)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
95 (switch-to-buffer buffer1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
96 (insert-buffer-substring buffer2 beg end))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
97 (switch-to-buffer buffer1)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
98 (if beg (YaTeX-help-resolve-reference
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
99 buffer1 buffer2 (append done-list ref-list))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
100 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
101 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
102
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
119 (let ((case-fold-search nil))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
120 (re-search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
121 (concat (regexp-quote YaTeX-help-delimiter)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
122 (regexp-quote command)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
130 (re-search-forward
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
131 (concat "^" (regexp-quote YaTeX-help-delimiter)) nil 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
132 (- (point) (length YaTeX-help-delimiter))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
133 (YaTeX-showup-buffer
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
183 (bury-buffer hfbuf)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
190 (YaTeX-showup-buffer
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
228 (defun YaTeX-apropos-file (keyword help-file &optional append)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
229 (let ((hb (find-file-noselect help-file))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
230 (ab (get-buffer-create YaTeX-help-buffer))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
231 (sw (selected-window))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
232 (head (concat "^" (regexp-quote YaTeX-help-delimiter)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
233 pt command)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
234 (YaTeX-showup-buffer
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
235 ab (function (lambda (x) (nth 3 (window-edges x)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
236 (select-window (get-buffer-window ab))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
237 (set-buffer ab) ;assertion
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
238 (or append (erase-buffer))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
239 (set-buffer hb)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
240 (goto-char (point-min))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
241 (while (re-search-forward keyword nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
242 (setq pt (point))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
243 (re-search-backward head nil t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
244 (setq command (buffer-substring (match-end 0) (point-end-of-line)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
245 (switch-to-buffer ab)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
246 (goto-char (point-max))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
247 (insert-char ?- (1- (window-width)))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
248 (insert (format "\n<<%s>>\n" command))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
249 (YaTeX-refer-help command help-file t) ;append mode
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
250 (set-buffer hb)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
251 (goto-char pt)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
252 (if (re-search-forward head nil 1)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
253 (goto-char (1- (match-beginning 0)))))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
254 (select-window sw)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
255 pt)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
256 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
257
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
258 ;;;###autoload
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
259 (defun YaTeX-apropos (key)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
260 (interactive "sLaTeX apropos (regexp): ")
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
261 (or (YaTeX-apropos-file key YaTeX-help-file)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
262 (YaTeX-apropos-file key YaTeX-help-file-private t)
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
263 (message "No matches found."))
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
264 )
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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
b00c74813e56 Change the YaTeX-math-mode's prefix from `,' to `;'.
yuuji
parents: 16
diff changeset
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 )

yatex.org