Mercurial > emacs
annotate lisp/textmodes/reftex-auc.el @ 59384:a1edc5959dcf
* macfns.c: Include sys/param.h.
[TARGET_API_MAC_CARBON] (mac_nav_event_callback): New declaration
and function.
[TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size
of filename string. Set event callback function when creating
dialog boxes. Add code conversions for filenames. Don't dispose
apple event descriptor record if failed to create it.
* macterm.c: Include sys/param.h.
[USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for
kEventWindowUpdate.
(install_window_handler) [USE_CARBON_EVENTS]: Register it.
(do_ae_open_documents) [TARGET_API_MAC_CARBON]: Get FSRef instead
of FSSpec from apple event descriptor record.
(do_ae_open_documents) [TARGET_API_MAC_CARBON]: Use MAXPATHLEN for
size of filename string.
[TARGET_API_MAC_CARBON] (mac_do_receive_drag): Likewise.
[TARGET_API_MAC_CARBON] (mac_do_receive_drag): Return error when a
file dialog is in action.
[TARGET_API_MAC_CARBON] (mac_do_track_drag): Likewise. Reject
only when there are no filename items. Set background color
before (un)highlighting the window below the dragged items.
(XTread_socket) [!USE_CARBON_EVENTS]: Don't call do_window_update.
author | Steven Tamm <steventamm@mac.com> |
---|---|
date | Thu, 06 Jan 2005 02:53:39 +0000 |
parents | 49550f69cc8d |
children | 9bad65481674 d8411455de48 |
rev | line source |
---|---|
56756 | 1 ;;; reftex-auc.el --- RefTeX's interface to AUCTeX |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
2 ;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. |
27035 | 3 |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
38422
diff
changeset
|
4 ;; Author: Carsten Dominik <dominik@science.uva.nl> |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
5 ;; Version: 4.21 |
27035 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
25280 | 23 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
24 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
25 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
26 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
27 |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
25280 | 29 (provide 'reftex-auc) |
30 (require 'reftex) | |
31 ;;; | |
32 | |
33 (defun reftex-plug-flag (which) | |
34 ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX | |
35 (or (eq t reftex-plug-into-AUCTeX) | |
36 (and (listp reftex-plug-into-AUCTeX) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
37 (nth which reftex-plug-into-AUCTeX)))) |
25280 | 38 |
39 (defun reftex-arg-label (optional &optional prompt definition) | |
40 "Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg. | |
41 What is being used depends upon `reftex-plug-into-AUCTeX'." | |
42 (let (label) | |
43 (cond | |
44 ((and definition (reftex-plug-flag 1)) | |
45 ;; Create a new label, with a temporary brace for `reftex-what-macro' | |
46 (unwind-protect | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
47 (progn (insert "{") (setq label (or (reftex-label nil t) ""))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
48 (delete-backward-char 1))) |
25280 | 49 ((and (not definition) (reftex-plug-flag 2)) |
50 ;; Reference a label with RefTeX | |
51 (setq label (reftex-reference nil t))) | |
52 (t | |
53 ;; AUCTeX's default mechanism | |
54 (setq label (completing-read (TeX-argument-prompt optional prompt "Key") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
55 (LaTeX-label-list))))) |
25280 | 56 (if (and definition (not (string-equal "" label))) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
57 (LaTeX-add-labels label)) |
25280 | 58 (TeX-argument-insert label optional))) |
59 | |
60 (defun reftex-arg-cite (optional &optional prompt definition) | |
61 "Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument. | |
62 What is being used depends upon `reftex-plug-into-AUCTeX'." | |
63 (let (items) | |
64 (cond | |
65 ((and (not definition) (reftex-plug-flag 3)) | |
66 (setq items (list (or (reftex-citation t) "")))) | |
67 (t | |
68 (setq prompt (concat (if optional "(Optional) " "") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
69 (if prompt prompt "Add key") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
70 ": (default none) ")) |
25280 | 71 (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list))))) |
72 (apply 'LaTeX-add-bibitems items) | |
73 (TeX-argument-insert (mapconcat 'identity items ",") optional))) | |
74 | |
75 | |
76 (defun reftex-arg-index-tag (optional &optional prompt &rest args) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
77 "Prompt for an index tag with completion. |
25280 | 78 This is the name of an index, not the entry." |
79 (let (tag taglist) | |
80 (setq prompt (concat (if optional "(Optional) " "") | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
81 (if prompt prompt "Index tag") |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
82 ": (default none) ")) |
25280 | 83 (if (and reftex-support-index (reftex-plug-flag 4)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
84 ;; Use RefTeX completion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
85 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
86 (reftex-access-scan-info nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
87 (setq taglist |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
88 (cdr (assoc 'index-tags |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
89 (symbol-value reftex-docstruct-symbol))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
90 tag (completing-read prompt (mapcar 'list taglist)))) |
25280 | 91 ;; Just ask like AUCTeX does. |
92 (setq tag (read-string prompt))) | |
93 (TeX-argument-insert tag optional))) | |
94 | |
95 (defun reftex-arg-index (optional &optional prompt &rest args) | |
96 "Prompt for an index entry completing with known entries. | |
97 Completion is specific for just one index, if the macro or a tag | |
98 argument identify one of multiple indices." | |
99 (let* (tag key) | |
100 (if (and reftex-support-index (reftex-plug-flag 4)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
101 (progn |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
102 (reftex-access-scan-info nil) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
103 (setq tag (reftex-what-index-tag) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
104 key (reftex-index-complete-key (or tag "idx")))) |
25280 | 105 (setq key (completing-read (TeX-argument-prompt optional prompt "Key") |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
106 (LaTeX-index-entry-list)))) |
25280 | 107 (unless (string-equal "" key) |
108 (LaTeX-add-index-entries key)) | |
109 (TeX-argument-insert key optional))) | |
110 | |
111 (defun reftex-what-index-tag () | |
112 ;; Look backward to find out what index the macro at point belongs to | |
113 (let ((macro (save-excursion | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
114 (and (re-search-backward "\\\\[a-zA-Z*]+" nil t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
115 (match-string 0)))) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
116 tag entry) |
25280 | 117 (when (and macro |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
118 (setq entry (assoc macro reftex-index-macro-alist))) |
25280 | 119 (setq tag (nth 1 entry)) |
120 (cond | |
121 ((stringp tag) tag) | |
122 ((integerp tag) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
123 (save-excursion |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
124 (goto-char (match-end 1)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
125 (or (reftex-nth-arg tag (nth 6 entry)) "idx"))) |
25280 | 126 (t "idx"))))) |
127 | |
128 (defvar LaTeX-label-function) | |
129 (defun reftex-plug-into-AUCTeX () | |
130 ;; Replace AUCTeX functions with RefTeX functions. | |
131 ;; Which functions are replaced is controlled by the variable | |
132 ;; `reftex-plug-into-AUCTeX'. | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
133 |
25280 | 134 (if (reftex-plug-flag 0) |
135 (setq LaTeX-label-function 'reftex-label) | |
136 (setq LaTeX-label-function nil)) | |
137 | |
138 (and (or (reftex-plug-flag 1) (reftex-plug-flag 2)) | |
139 (fboundp 'TeX-arg-label) | |
140 (fset 'TeX-arg-label 'reftex-arg-label)) | |
141 | |
142 (and (reftex-plug-flag 3) | |
143 (fboundp 'TeX-arg-cite) | |
144 (fset 'TeX-arg-cite 'reftex-arg-cite)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
145 |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
146 (and (reftex-plug-flag 4) |
25280 | 147 (fboundp 'TeX-arg-index-tag) |
148 (fset 'TeX-arg-index-tag 'reftex-arg-index-tag)) | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
149 (and (reftex-plug-flag 4) |
25280 | 150 (fboundp 'TeX-arg-index) |
151 (fset 'TeX-arg-index 'reftex-arg-index))) | |
152 | |
153 (defun reftex-toggle-plug-into-AUCTeX () | |
154 "Toggle Interface between AUCTeX and RefTeX on and off." | |
155 (interactive) | |
156 (unless (and (featurep 'tex-site) (featurep 'latex)) | |
157 (error "AUCTeX's LaTeX mode does not seem to be loaded")) | |
158 (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX)) | |
159 (reftex-plug-into-AUCTeX) | |
160 (if reftex-plug-into-AUCTeX | |
161 (message "RefTeX has been plugged into AUCTeX.") | |
162 (message "RefTeX no longer interacts with AUCTeX."))) | |
163 | |
164 (defun reftex-add-label-environments (entry-list) | |
165 "Add label environment descriptions to `reftex-label-alist-style'. | |
166 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there | |
167 for details. | |
168 This function makes it possible to support RefTeX from AUCTeX style files. | |
169 The entries in ENTRY-LIST will be processed after the user settings in | |
170 `reftex-label-alist', and before the defaults (specified in | |
171 `reftex-default-label-alist-entries'). Any changes made to | |
172 `reftex-label-alist-style' will raise a flag to the effect that | |
173 the label information is recompiled on next use." | |
174 (unless reftex-docstruct-symbol | |
175 (reftex-tie-multifile-symbols)) | |
176 (when (and reftex-docstruct-symbol | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
177 (symbolp reftex-docstruct-symbol)) |
25280 | 178 (let ((list (get reftex-docstruct-symbol 'reftex-label-alist-style)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
179 entry changed) |
25280 | 180 (while entry-list |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
181 (setq entry (pop entry-list)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
182 (unless (member entry list) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
183 (setq reftex-tables-dirty t |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
184 changed t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
185 (push entry list))) |
25280 | 186 (when changed |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
187 (put reftex-docstruct-symbol 'reftex-label-alist-style list))))) |
25280 | 188 (defalias 'reftex-add-to-label-alist 'reftex-add-label-environments) |
189 | |
190 (defun reftex-add-section-levels (entry-list) | |
191 "Add entries to the value of `reftex-section-levels'. | |
192 The added values are kept local to the current document. The format | |
193 of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See | |
194 `reftex-section-levels' for an example." | |
195 (unless reftex-docstruct-symbol | |
196 (reftex-tie-multifile-symbols)) | |
197 (when (and reftex-docstruct-symbol | |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
198 (symbolp reftex-docstruct-symbol)) |
25280 | 199 (let ((list (get reftex-docstruct-symbol 'reftex-section-levels)) |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
200 entry changed) |
25280 | 201 (while entry-list |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
202 (setq entry (pop entry-list)) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
203 (unless (member entry list) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
204 (setq reftex-tables-dirty t |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
205 changed t) |
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
206 (push entry list))) |
25280 | 207 (when changed |
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
49599
diff
changeset
|
208 (put reftex-docstruct-symbol 'reftex-section-levels list))))) |
25280 | 209 |
210 (defun reftex-notice-new-section () | |
211 (reftex-notice-new 1 'force)) | |
212 | |
52401 | 213 ;;; arch-tag: 4a798e68-3405-421c-a09b-0269aac64ab4 |
25280 | 214 ;;; reftex-auc.el ends here |