Mercurial > emacs
comparison lisp/textmodes/reftex-dcr.el @ 49599:5ade352e8d1c
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 13:30:45 +0000 |
parents | 11e08f9901ea |
children | 27340819ef07 d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49598:0d8b17d428b5 | 49599:5ade352e8d1c |
---|---|
84 (reftex-access-scan-info arg) | 84 (reftex-access-scan-info arg) |
85 (setq dw (reftex-view-regexp-match | 85 (setq dw (reftex-view-regexp-match |
86 (format reftex-find-index-entry-regexp-format | 86 (format reftex-find-index-entry-regexp-format |
87 (regexp-quote key)) | 87 (regexp-quote key)) |
88 3 nil nil))) | 88 3 nil nil))) |
89 (t | 89 (t |
90 (reftex-access-scan-info arg) | 90 (reftex-access-scan-info arg) |
91 (catch 'exit | 91 (catch 'exit |
92 (let ((list reftex-view-crossref-extra) | 92 (let ((list reftex-view-crossref-extra) |
93 entry mre action group) | 93 entry mre action group) |
94 (while (setq entry (pop list)) | 94 (while (setq entry (pop list)) |
95 (setq mre (car entry) | 95 (setq mre (car entry) |
96 action (nth 1 entry) | 96 action (nth 1 entry) |
97 group (nth 2 entry)) | 97 group (nth 2 entry)) |
98 (when (string-match mre macro) | 98 (when (string-match mre macro) |
99 (setq dw (reftex-view-regexp-match | 99 (setq dw (reftex-view-regexp-match |
100 (format action key) group nil nil)) | 100 (format action key) group nil nil)) |
101 (throw 'exit t)))) | 101 (throw 'exit t)))) |
102 (error "Not on a crossref macro argument")))) | 102 (error "Not on a crossref macro argument")))) |
103 (if (and (eq arg 2) (windowp dw)) (select-window dw)))) | 103 (if (and (eq arg 2) (windowp dw)) (select-window dw)))) |
104 | 104 |
105 (defun reftex-view-cr-cite (arg key how) | 105 (defun reftex-view-cr-cite (arg key how) |
106 ;; View crossreference of a ref cite. HOW can have the values | 106 ;; View crossreference of a ref cite. HOW can have the values |
107 ;; nil: Show in another window. | 107 ;; nil: Show in another window. |
108 ;; echo: Show one-line info in echo area. | 108 ;; echo: Show one-line info in echo area. |
109 ;; tmp-window: Show in small window and arrange for window to disappear. | 109 ;; tmp-window: Show in small window and arrange for window to disappear. |
110 | 110 |
111 ;; Ensure access to scanning info | 111 ;; Ensure access to scanning info |
112 (reftex-access-scan-info (or arg current-prefix-arg)) | 112 (reftex-access-scan-info (or arg current-prefix-arg)) |
113 | 113 |
114 (if (eq how 'tmp-window) | 114 (if (eq how 'tmp-window) |
115 ;; Remember the window configuration | 115 ;; Remember the window configuration |
116 (put 'reftex-auto-view-crossref 'last-window-conf | 116 (put 'reftex-auto-view-crossref 'last-window-conf |
117 (current-window-configuration))) | 117 (current-window-configuration))) |
118 | 118 |
119 (let (files size item (pos (point)) (win (selected-window)) pop-win | 119 (let (files size item (pos (point)) (win (selected-window)) pop-win |
120 (bibtype (reftex-bib-or-thebib))) | 120 (bibtype (reftex-bib-or-thebib))) |
121 ;; Find the citation mode and the file list | 121 ;; Find the citation mode and the file list |
127 ; ((assq 'thebib (symbol-value reftex-docstruct-symbol)) | 127 ; ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
128 ((eq bibtype 'thebib) | 128 ((eq bibtype 'thebib) |
129 (setq item t | 129 (setq item t |
130 files (reftex-uniquify | 130 files (reftex-uniquify |
131 (mapcar 'cdr | 131 (mapcar 'cdr |
132 (reftex-all-assq | 132 (reftex-all-assq |
133 'thebib (symbol-value reftex-docstruct-symbol)))))) | 133 'thebib (symbol-value reftex-docstruct-symbol)))))) |
134 (reftex-default-bibliography | 134 (reftex-default-bibliography |
135 (setq item nil | 135 (setq item nil |
136 files (reftex-default-bibliography))) | 136 files (reftex-default-bibliography))) |
137 (how) ;; don't throw for special display | 137 (how) ;; don't throw for special display |
166 (goto-char pos) | 166 (goto-char pos) |
167 (when (equal arg 2) | 167 (when (equal arg 2) |
168 (select-window pop-win))))) | 168 (select-window pop-win))))) |
169 | 169 |
170 (defun reftex-view-cr-ref (arg label how) | 170 (defun reftex-view-cr-ref (arg label how) |
171 ;; View crossreference of a ref macro. HOW can have the values | 171 ;; View crossreference of a ref macro. HOW can have the values |
172 ;; nil: Show in another window. | 172 ;; nil: Show in another window. |
173 ;; echo: Show one-line info in echo area. | 173 ;; echo: Show one-line info in echo area. |
174 ;; tmp-window: Show in small window and arrange for window to disappear. | 174 ;; tmp-window: Show in small window and arrange for window to disappear. |
175 | 175 |
176 ;; Ensure access to scanning info | 176 ;; Ensure access to scanning info |
177 (reftex-access-scan-info (or arg current-prefix-arg)) | 177 (reftex-access-scan-info (or arg current-prefix-arg)) |
178 | 178 |
179 (if (eq how 'tmp-window) | 179 (if (eq how 'tmp-window) |
180 ;; Remember the window configuration | 180 ;; Remember the window configuration |
181 (put 'reftex-auto-view-crossref 'last-window-conf | 181 (put 'reftex-auto-view-crossref 'last-window-conf |
182 (current-window-configuration))) | 182 (current-window-configuration))) |
183 | 183 |
184 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) | 184 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) |
185 (xr-re (nth 2 xr-data)) | 185 (xr-re (nth 2 xr-data)) |
186 (entry (assoc label (symbol-value reftex-docstruct-symbol))) | 186 (entry (assoc label (symbol-value reftex-docstruct-symbol))) |
188 | 188 |
189 (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) | 189 (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) |
190 ;; Label is defined in external document | 190 ;; Label is defined in external document |
191 (save-excursion | 191 (save-excursion |
192 (save-match-data | 192 (save-match-data |
193 (set-buffer | 193 (set-buffer |
194 (or (reftex-get-file-buffer-force | 194 (or (reftex-get-file-buffer-force |
195 (cdr (assoc (match-string 1 label) (nth 1 | 195 (cdr (assoc (match-string 1 label) (nth 1 |
196 xr-data)))) | 196 xr-data)))) |
197 (error "Problem with external label %s" label)))) | 197 (error "Problem with external label %s" label)))) |
198 (setq label (substring label (match-end 1))) | 198 (setq label (substring label (match-end 1))) |
199 (reftex-access-scan-info) | 199 (reftex-access-scan-info) |
200 (setq entry | 200 (setq entry |
201 (assoc label (symbol-value reftex-docstruct-symbol))))) | 201 (assoc label (symbol-value reftex-docstruct-symbol))))) |
202 (if (eq how 'echo) | 202 (if (eq how 'echo) |
203 ;; Display in echo area | 203 ;; Display in echo area |
204 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | 204 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) |
205 (let ((window-conf (current-window-configuration))) | 205 (let ((window-conf (current-window-configuration))) |
241 ;; Make sure we are not already displaying this one | 241 ;; Make sure we are not already displaying this one |
242 (not (memq last-command '(reftex-view-crossref | 242 (not (memq last-command '(reftex-view-crossref |
243 reftex-mouse-view-crossref))) | 243 reftex-mouse-view-crossref))) |
244 ;; Quick precheck if this might be a relevant spot | 244 ;; Quick precheck if this might be a relevant spot |
245 ;; FIXME: Can fail with backslash in comment | 245 ;; FIXME: Can fail with backslash in comment |
246 (save-excursion | 246 (save-excursion |
247 (search-backward "\\" nil t) | 247 (search-backward "\\" nil t) |
248 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)")) | 248 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)")) |
249 | 249 |
250 (condition-case nil | 250 (condition-case nil |
251 (let ((current-prefix-arg nil)) | 251 (let ((current-prefix-arg nil)) |
259 | 259 |
260 (defun reftex-restore-window-conf () | 260 (defun reftex-restore-window-conf () |
261 (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) | 261 (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) |
262 (put 'reftex-auto-view-crossref 'last-window-conf nil) | 262 (put 'reftex-auto-view-crossref 'last-window-conf nil) |
263 (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) | 263 (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) |
264 | 264 |
265 (defun reftex-echo-ref (label entry docstruct) | 265 (defun reftex-echo-ref (label entry docstruct) |
266 ;; Display crossref info in echo area. | 266 ;; Display crossref info in echo area. |
267 (cond | 267 (cond |
268 ((null docstruct) | 268 ((null docstruct) |
269 (message (substitute-command-keys (format reftex-no-info-message "ref")))) | 269 (message (substitute-command-keys (format reftex-no-info-message "ref")))) |
290 | 290 |
291 ;; Need to look in the database | 291 ;; Need to look in the database |
292 (unless reftex-revisit-to-echo | 292 (unless reftex-revisit-to-echo |
293 (setq files (reftex-visited-files files))) | 293 (setq files (reftex-visited-files files))) |
294 | 294 |
295 (setq entry | 295 (setq entry |
296 (condition-case nil | 296 (condition-case nil |
297 (save-excursion | 297 (save-excursion |
298 (reftex-pop-to-bibtex-entry key files nil nil item t)) | 298 (reftex-pop-to-bibtex-entry key files nil nil item t)) |
299 (error | 299 (error |
300 (if (and files (= (length all-files) (length files))) | 300 (if (and files (= (length all-files) (length files))) |
301 (message "cite: no such database entry: %s" key) | 301 (message "cite: no such database entry: %s" key) |
302 (message (substitute-command-keys | 302 (message (substitute-command-keys |
303 (format reftex-no-info-message "cite")))) | 303 (format reftex-no-info-message "cite")))) |
304 nil))) | 304 nil))) |
305 (when entry | 305 (when entry |
306 (if item | 306 (if item |
307 (setq string (reftex-nicify-text entry)) | 307 (setq string (reftex-nicify-text entry)) |
335 (message "Automatic display of crossref information was turned off")) | 335 (message "Automatic display of crossref information was turned off")) |
336 (setq reftex-auto-view-crossref-timer | 336 (setq reftex-auto-view-crossref-timer |
337 (if (featurep 'xemacs) | 337 (if (featurep 'xemacs) |
338 (if reftex-use-itimer-in-xemacs | 338 (if reftex-use-itimer-in-xemacs |
339 (start-itimer "RefTeX Idle Timer" | 339 (start-itimer "RefTeX Idle Timer" |
340 'reftex-view-crossref-when-idle | 340 'reftex-view-crossref-when-idle |
341 reftex-idle-time reftex-idle-time t) | 341 reftex-idle-time reftex-idle-time t) |
342 (add-hook 'post-command-hook 'reftex-start-itimer-once) | 342 (add-hook 'post-command-hook 'reftex-start-itimer-once) |
343 t) | 343 t) |
344 (run-with-idle-timer | 344 (run-with-idle-timer |
345 reftex-idle-time t 'reftex-view-crossref-when-idle))) | 345 reftex-idle-time t 'reftex-view-crossref-when-idle))) |
350 (defun reftex-start-itimer-once () | 350 (defun reftex-start-itimer-once () |
351 (and reftex-mode | 351 (and reftex-mode |
352 (not (itimer-live-p reftex-auto-view-crossref-timer)) | 352 (not (itimer-live-p reftex-auto-view-crossref-timer)) |
353 (setq reftex-auto-view-crossref-timer | 353 (setq reftex-auto-view-crossref-timer |
354 (start-itimer "RefTeX Idle Timer" | 354 (start-itimer "RefTeX Idle Timer" |
355 'reftex-view-crossref-when-idle | 355 'reftex-view-crossref-when-idle |
356 reftex-idle-time nil t)))) | 356 reftex-idle-time nil t)))) |
357 | 357 |
358 (defun reftex-view-crossref-from-bibtex (&optional arg) | 358 (defun reftex-view-crossref-from-bibtex (&optional arg) |
359 "View location in a LaTeX document which cites the BibTeX entry at point. | 359 "View location in a LaTeX document which cites the BibTeX entry at point. |
360 Since BibTeX files can be used by many LaTeX documents, this function | 360 Since BibTeX files can be used by many LaTeX documents, this function |
361 prompts upon first use for a buffer in RefTeX mode. To reset this | 361 prompts upon first use for a buffer in RefTeX mode. To reset this |
362 link to a document, call the function with with a prefix arg. | 362 link to a document, call the function with with a prefix arg. |
363 Calling this function several times find successive citation locations." | 363 Calling this function several times find successive citation locations." |
364 (interactive "P") | 364 (interactive "P") |
365 (when arg | 365 (when arg |
366 ;; Break connection to reference buffer | 366 ;; Break connection to reference buffer |
367 (put 'reftex-bibtex-view-cite-locations :ref-buffer nil)) | 367 (put 'reftex-bibtex-view-cite-locations :ref-buffer nil)) |
368 (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) | 368 (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) |
369 ;; Establish connection to reference buffer | 369 ;; Establish connection to reference buffer |
370 (unless ref-buffer | 370 (unless ref-buffer |
371 (setq ref-buffer | 371 (setq ref-buffer |
372 (save-excursion | 372 (save-excursion |
373 (completing-read | 373 (completing-read |
374 "Reference buffer: " | 374 "Reference buffer: " |
375 (delq nil | 375 (delq nil |
376 (mapcar | 376 (mapcar |
377 (lambda (b) | 377 (lambda (b) |
378 (set-buffer b) | 378 (set-buffer b) |
379 (if reftex-mode (list (buffer-name b)) nil)) | 379 (if reftex-mode (list (buffer-name b)) nil)) |
380 (buffer-list))) | 380 (buffer-list))) |
381 nil t))) | 381 nil t))) |