Mercurial > emacs
annotate lisp/textmodes/reftex-auc.el @ 26839:97029667b1a9
Include composite.h.
(casify_object): Use MAX_MULTIBYTE_LENGTH to allocate memory for a
multibyte character. Adjusted for the change of CHAR_STRING.
(casify_region): Likewise. Call update_compositions.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 15 Dec 1999 00:02:33 +0000 |
parents | 7ed67319c5aa |
children | 489a5439b988 |
rev | line source |
---|---|
25280 | 1 ;;; reftex-auc.el - RefTeX's interface to AUC TeX |
25806
7ed67319c5aa
version number change
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
2 ;;; Version: 4.6 |
25280 | 3 ;;; |
4 ;;; See main file reftex.el for licensing information | |
5 | |
6 (provide 'reftex-auc) | |
7 (require 'reftex) | |
8 ;;; | |
9 | |
10 (defun reftex-plug-flag (which) | |
11 ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX | |
12 (or (eq t reftex-plug-into-AUCTeX) | |
13 (and (listp reftex-plug-into-AUCTeX) | |
14 (nth which reftex-plug-into-AUCTeX)))) | |
15 | |
16 (defun reftex-arg-label (optional &optional prompt definition) | |
17 "Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg. | |
18 What is being used depends upon `reftex-plug-into-AUCTeX'." | |
19 (let (label) | |
20 (cond | |
21 ((and definition (reftex-plug-flag 1)) | |
22 ;; Create a new label, with a temporary brace for `reftex-what-macro' | |
23 (unwind-protect | |
24 (progn (insert "{") (setq label (or (reftex-label nil t) ""))) | |
25 (delete-backward-char 1))) | |
26 ((and (not definition) (reftex-plug-flag 2)) | |
27 ;; Reference a label with RefTeX | |
28 (setq label (reftex-reference nil t))) | |
29 (t | |
30 ;; AUCTeX's default mechanism | |
31 (setq label (completing-read (TeX-argument-prompt optional prompt "Key") | |
32 (LaTeX-label-list))))) | |
33 (if (and definition (not (string-equal "" label))) | |
34 (LaTeX-add-labels label)) | |
35 (TeX-argument-insert label optional))) | |
36 | |
37 (defun reftex-arg-cite (optional &optional prompt definition) | |
38 "Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument. | |
39 What is being used depends upon `reftex-plug-into-AUCTeX'." | |
40 (let (items) | |
41 (cond | |
42 ((and (not definition) (reftex-plug-flag 3)) | |
43 (setq items (list (or (reftex-citation t) "")))) | |
44 (t | |
45 (setq prompt (concat (if optional "(Optional) " "") | |
46 (if prompt prompt "Add key") | |
47 ": (default none) ")) | |
48 (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list))))) | |
49 (apply 'LaTeX-add-bibitems items) | |
50 (TeX-argument-insert (mapconcat 'identity items ",") optional))) | |
51 | |
52 | |
53 (defun reftex-arg-index-tag (optional &optional prompt &rest args) | |
54 "Prompt for an index tag with completion. | |
55 This is the name of an index, not the entry." | |
56 (let (tag taglist) | |
57 (setq prompt (concat (if optional "(Optional) " "") | |
58 (if prompt prompt "Index tag") | |
59 ": (default none) ")) | |
60 (if (and reftex-support-index (reftex-plug-flag 4)) | |
61 ;; Use RefTeX completion | |
62 (progn | |
63 (reftex-access-scan-info nil) | |
64 (setq taglist | |
65 (cdr (assoc 'index-tags | |
66 (symbol-value reftex-docstruct-symbol))) | |
67 tag (completing-read prompt (mapcar 'list taglist)))) | |
68 ;; Just ask like AUCTeX does. | |
69 (setq tag (read-string prompt))) | |
70 (TeX-argument-insert tag optional))) | |
71 | |
72 (defun reftex-arg-index (optional &optional prompt &rest args) | |
73 "Prompt for an index entry completing with known entries. | |
74 Completion is specific for just one index, if the macro or a tag | |
75 argument identify one of multiple indices." | |
76 (let* (tag key) | |
77 (if (and reftex-support-index (reftex-plug-flag 4)) | |
78 (progn | |
79 (reftex-access-scan-info nil) | |
80 (setq tag (reftex-what-index-tag) | |
81 key (reftex-index-complete-key (or tag "idx")))) | |
82 (setq key (completing-read (TeX-argument-prompt optional prompt "Key") | |
83 (LaTeX-index-entry-list)))) | |
84 (unless (string-equal "" key) | |
85 (LaTeX-add-index-entries key)) | |
86 (TeX-argument-insert key optional))) | |
87 | |
88 (defun reftex-what-index-tag () | |
89 ;; Look backward to find out what index the macro at point belongs to | |
90 (let ((macro (save-excursion | |
91 (and (re-search-backward "\\\\[a-zA-Z*]+" nil t) | |
92 (match-string 0)))) | |
93 tag entry) | |
94 (when (and macro | |
95 (setq entry (assoc macro reftex-index-macro-alist))) | |
96 (setq tag (nth 1 entry)) | |
97 (cond | |
98 ((stringp tag) tag) | |
99 ((integerp tag) | |
100 (save-excursion | |
101 (goto-char (match-end 1)) | |
102 (or (reftex-nth-arg tag (nth 6 entry)) "idx"))) | |
103 (t "idx"))))) | |
104 | |
105 (defvar LaTeX-label-function) | |
106 (defun reftex-plug-into-AUCTeX () | |
107 ;; Replace AUCTeX functions with RefTeX functions. | |
108 ;; Which functions are replaced is controlled by the variable | |
109 ;; `reftex-plug-into-AUCTeX'. | |
110 | |
111 (if (reftex-plug-flag 0) | |
112 (setq LaTeX-label-function 'reftex-label) | |
113 (setq LaTeX-label-function nil)) | |
114 | |
115 (and (or (reftex-plug-flag 1) (reftex-plug-flag 2)) | |
116 (fboundp 'TeX-arg-label) | |
117 (fset 'TeX-arg-label 'reftex-arg-label)) | |
118 | |
119 (and (reftex-plug-flag 3) | |
120 (fboundp 'TeX-arg-cite) | |
121 (fset 'TeX-arg-cite 'reftex-arg-cite)) | |
122 | |
123 (and (reftex-plug-flag 4) | |
124 (fboundp 'TeX-arg-index-tag) | |
125 (fset 'TeX-arg-index-tag 'reftex-arg-index-tag)) | |
126 (and (reftex-plug-flag 4) | |
127 (fboundp 'TeX-arg-index) | |
128 (fset 'TeX-arg-index 'reftex-arg-index))) | |
129 | |
130 (defun reftex-toggle-plug-into-AUCTeX () | |
131 "Toggle Interface between AUCTeX and RefTeX on and off." | |
132 (interactive) | |
133 (unless (and (featurep 'tex-site) (featurep 'latex)) | |
134 (error "AUCTeX's LaTeX mode does not seem to be loaded")) | |
135 (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX)) | |
136 (reftex-plug-into-AUCTeX) | |
137 (if reftex-plug-into-AUCTeX | |
138 (message "RefTeX has been plugged into AUCTeX.") | |
139 (message "RefTeX no longer interacts with AUCTeX."))) | |
140 | |
141 (defun reftex-add-label-environments (entry-list) | |
142 "Add label environment descriptions to `reftex-label-alist-style'. | |
143 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there | |
144 for details. | |
145 This function makes it possible to support RefTeX from AUCTeX style files. | |
146 The entries in ENTRY-LIST will be processed after the user settings in | |
147 `reftex-label-alist', and before the defaults (specified in | |
148 `reftex-default-label-alist-entries'). Any changes made to | |
149 `reftex-label-alist-style' will raise a flag to the effect that | |
150 the label information is recompiled on next use." | |
151 (unless reftex-docstruct-symbol | |
152 (reftex-tie-multifile-symbols)) | |
153 (when (and reftex-docstruct-symbol | |
154 (symbolp reftex-docstruct-symbol)) | |
155 (let ((list (get reftex-docstruct-symbol 'reftex-label-alist-style)) | |
156 entry changed) | |
157 (while entry-list | |
158 (setq entry (pop entry-list)) | |
159 (unless (member entry list) | |
160 (setq reftex-tables-dirty t | |
161 changed t) | |
162 (push entry list))) | |
163 (when changed | |
164 (put reftex-docstruct-symbol 'reftex-label-alist-style list))))) | |
165 (defalias 'reftex-add-to-label-alist 'reftex-add-label-environments) | |
166 | |
167 (defun reftex-add-section-levels (entry-list) | |
168 "Add entries to the value of `reftex-section-levels'. | |
169 The added values are kept local to the current document. The format | |
170 of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See | |
171 `reftex-section-levels' for an example." | |
172 (unless reftex-docstruct-symbol | |
173 (reftex-tie-multifile-symbols)) | |
174 (when (and reftex-docstruct-symbol | |
175 (symbolp reftex-docstruct-symbol)) | |
176 (let ((list (get reftex-docstruct-symbol 'reftex-section-levels)) | |
177 entry changed) | |
178 (while entry-list | |
179 (setq entry (pop entry-list)) | |
180 (unless (member entry list) | |
181 (setq reftex-tables-dirty t | |
182 changed t) | |
183 (push entry list))) | |
184 (when changed | |
185 (put reftex-docstruct-symbol 'reftex-section-levels list))))) | |
186 | |
187 (defun reftex-notice-new-section () | |
188 (reftex-notice-new 1 'force)) | |
189 | |
190 ;;; reftex-auc.el ends here |