annotate yatexhlp.el @ 16:cb9afa9c1213

Auto-indentation at begin-type completion works correctly. Hack for gmhist&gmhist-mh. Fix the bug on \ref-completion. YaTeX-help is now available.
author yuuji
date Fri, 06 May 1994 21:14:11 +0000
parents
children b00c74813e56
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]
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
5 ;;; Last modified Thu May 5 16:09:42 1994 on 98fa
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
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
37 (defun YaTeX-refer-help (command help-file)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
38 "Refer the COMMAND's help into HELP-FILE.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
39 \[Help-file format\]
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
40 <DELIM><LaTeX/TeX command without escape character(\\)><NL>
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
41 <Synopsis><NL>
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
42 <Documentation><TERM>
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
43 Where: <DELIM> is the value of YaTeX-help-delimiter.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
44 <NL> is newline.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
45 <TERM> is newline or end of buffer."
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
46 (let ((hfbuf (find-file-noselect help-file))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
47 (hbuf (get-buffer-create "** YaTeX HELP **"))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
48 (curwin (selected-window))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
49 sb se db de)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
50 (set-buffer hfbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
51 (goto-char (point-min))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
52 (if (null
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
53 (re-search-forward
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
54 (concat (regexp-quote YaTeX-help-delimiter)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
55 (regexp-quote command)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
56 "$") nil t))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
57 nil ;if not found, return nil
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
58 (forward-line 1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
59 (setq sb (point)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
60 se (progn (forward-line 1) (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
61 db (point)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
62 de (progn
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
63 (re-search-forward (regexp-quote YaTeX-help-delimiter) nil 1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
64 (1- (match-beginning 0))))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
65 (YaTeX-showup-buffer hbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
66 (pop-to-buffer hbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
67 (erase-buffer)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
68 (insert YaTeX-help-synopsis "\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
69 (insert-buffer-substring hfbuf sb se)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
70 (insert "\n" YaTeX-help-description "\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
71 (insert-buffer-substring hfbuf db de)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
72 (goto-char (point-min))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
73 (select-window curwin)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
74 t))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
75 )
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
76 (defun YaTeX-help-newline (&optional arg)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
77 (interactive "P")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
78 (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
79 (let ((cbuf (current-buffer)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
80 (beginning-of-line)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
81 (kill-line 1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
82 (save-excursion
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
83 (YaTeX-help-add-entry
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
84 YaTeX-help-command-current YaTeX-help-file-current))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
85 (set-window-configuration YaTeX-help-saved-config)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
86 (bury-buffer cbuf))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
87 (newline arg))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
88 )
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
89 (defun YaTeX-help-add-entry (command help-file)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
90 (let ((hfbuf (find-file-noselect help-file))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
91 (dbuf (current-buffer)) beg end)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
92 (goto-char (point-min))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
93 (re-search-forward (concat "^" (regexp-quote YaTeX-help-synopsis)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
94 (forward-line 1) (setq beg (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
95 (end-of-line) (setq end (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
96 (set-buffer hfbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
97 (goto-char (point-min))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
98 (insert YaTeX-help-delimiter command "\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
99 (insert-buffer-substring dbuf beg end)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
100 (insert "\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
101 (set-buffer dbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
102 (re-search-forward (concat "^" (regexp-quote YaTeX-help-description)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
103 (forward-line 1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
104 (setq beg (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
105 (setq end (point-max))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
106 (set-buffer hfbuf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
107 (insert-buffer-substring dbuf beg end)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
108 (insert "\n\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
109 (forward-line -1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
110 (delete-blank-lines)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
111 (let ((make-backup-files t))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
112 (basic-save-buffer))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
113 (bury-buffer hfbuf))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
114 )
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
115 (defun YaTeX-help-prepare-entry (command help-file)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
116 "Read help description on COMMAND and add it to HELP-FILE."
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
117 (let ((buf (get-buffer-create "**Description**"))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
118 (conf (current-window-configuration)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
119 (YaTeX-showup-buffer buf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
120 (pop-to-buffer buf)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
121 (make-local-variable 'YaTeX-help-file-current)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
122 (make-local-variable 'YaTeX-help-command-current)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
123 (make-local-variable 'YaTeX-help-saved-config)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
124 (setq YaTeX-help-file-current help-file
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
125 YaTeX-help-command-current command
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
126 YaTeX-help-saved-config conf
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
127 mode-name "Text"
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
128 major-mode 'text)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
129 (erase-buffer)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
130 (insert YaTeX-help-synopsis "\n\n" YaTeX-help-description "\n\n")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
131 (define-key YaTeX-help-entry-map "\r" 'YaTeX-help-newline)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
132 (use-local-map YaTeX-help-entry-map)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
133 (message
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
134 (cond (YaTeX-japan "入力を終えたら . のみ入力してRET")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
135 (t "Type only `.' and RET to exit."))))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
136 )
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
137 (defun YaTeX-enrich-help (command)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
138 "Add the COMMAND's help to help file."
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
139 (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
140 (YaTeX-help-prepare-entry
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
141 command
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
142 (if (y-or-n-p "Add help to global documentation?")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
143 YaTeX-help-file YaTeX-help-file-private)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
144 )
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-sort (&optional help-file)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
147 "Sort help file HELP-FILE.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
148 If HELP-FILE is nil or called interactively, sort current buffer
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
149 as a help file."
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
150 (interactive)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
151 (if help-file (set-buffer (find-file-noselect help-file)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
152 (sort-regexp-fields
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
153 nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
154 )
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
155
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
156 ;;;###autoload
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
157 (defun YaTeX-help ()
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
158 "Show help buffer of LaTeX/TeX commands or macros."
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
159 (interactive)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
160 (let (p beg end command)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
161 (save-excursion
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
162 (if (looking-at YaTeX-ec-regexp)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
163 (goto-char (match-end 0)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
164 (setq p (point)) ;remember current position.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
165 (cond
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
166 ((YaTeX-on-begin-end-p)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
167 ;;if on \begin or \end, extract its environment.
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
168 (setq command
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
169 (cond ((match-beginning 1)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
170 (buffer-substring (match-beginning 1) (match-end 1)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
171 ((match-beginning 2)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
172 (buffer-substring (match-beginning 2) (match-end 2))))))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
173 ((search-backward YaTeX-ec (point-beginning-of-line) t)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
174 (goto-char (setq beg (match-end 0)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
175 (re-search-forward "\\sw+")
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
176 (setq end (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
177 (if (and (<= beg p) (<= p end))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
178 (setq command (buffer-substring beg end)))))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
179 (if (or (string= command "begin") (string= command "end"))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
180 (progn
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
181 (search-forward "{" (point-end-of-line))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
182 (setq beg (point))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
183 (search-forward "}" (point-end-of-line))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
184 (setq command (buffer-substring beg (match-beginning 0)))))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
185 (setq command
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
186 (completing-read
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
187 "Describe (La)TeX command: "
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
188 (append
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
189 section-table user-section-table tmp-section-table
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
190 article-table user-article-table
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
191 env-table user-env-table tmp-env-table
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
192 singlecmd-table user-singlecmd-table tmp-singlecmd-table)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
193 nil nil command)) ;no-predicate, not require match
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
194 );end excursion
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
195 (or (YaTeX-refer-help command YaTeX-help-file)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
196 (YaTeX-refer-help command YaTeX-help-file-private)
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
197 (YaTeX-enrich-help command)))
cb9afa9c1213 Auto-indentation at begin-type completion works correctly.
yuuji
parents:
diff changeset
198 )

yatex.org