Mercurial > emacs
comparison lisp/textmodes/reftex-global.el @ 65265:b1bd53759945
(isearch-next-buffer-function, TeX-master): Add defvars.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Wed, 31 Aug 2005 10:29:27 +0000 |
parents | 5b1a238fcbb4 |
children | 253cad16882d a3716f7538f2 |
comparison
equal
deleted
inserted
replaced
65264:a95981ee377b | 65265:b1bd53759945 |
---|---|
29 | 29 |
30 (eval-when-compile (require 'cl)) | 30 (eval-when-compile (require 'cl)) |
31 (provide 'reftex-global) | 31 (provide 'reftex-global) |
32 (require 'reftex) | 32 (require 'reftex) |
33 ;;; | 33 ;;; |
34 | |
35 (defvar isearch-next-buffer-function) | |
36 (defvar TeX-master) | |
34 | 37 |
35 (defun reftex-create-tags-file () | 38 (defun reftex-create-tags-file () |
36 "Create TAGS file by running `etags' on the current document. | 39 "Create TAGS file by running `etags' on the current document. |
37 The TAGS file is also immediately visited with `visit-tags-table'." | 40 The TAGS file is also immediately visited with `visit-tags-table'." |
38 (interactive) | 41 (interactive) |
135 (if (null dlist) (error "No duplicate labels in document")) | 138 (if (null dlist) (error "No duplicate labels in document")) |
136 (switch-to-buffer-other-window "*Duplicate Labels*") | 139 (switch-to-buffer-other-window "*Duplicate Labels*") |
137 (set (make-local-variable 'TeX-master) master) | 140 (set (make-local-variable 'TeX-master) master) |
138 (erase-buffer) | 141 (erase-buffer) |
139 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") | 142 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") |
140 (insert | 143 (insert |
141 " Move point to label and type `r' to run a query-replace on the label\n" | 144 " Move point to label and type `r' to run a query-replace on the label\n" |
142 " and its references. Type `q' to exit this buffer.\n\n") | 145 " and its references. Type `q' to exit this buffer.\n\n") |
143 (insert " LABEL FILE\n") | 146 (insert " LABEL FILE\n") |
144 (insert " -------------------------------------------------------------\n") | 147 (insert " -------------------------------------------------------------\n") |
145 (use-local-map (make-sparse-keymap)) | 148 (use-local-map (make-sparse-keymap)) |
193 ;; Get some insurance | 196 ;; Get some insurance |
194 (if (and (reftex-is-multi) | 197 (if (and (reftex-is-multi) |
195 (not (yes-or-no-p "Replacing all simple labels in multiple files is risky. Continue? "))) | 198 (not (yes-or-no-p "Replacing all simple labels in multiple files is risky. Continue? "))) |
196 (error "Abort")) | 199 (error "Abort")) |
197 ;; Make the translation list | 200 ;; Make the translation list |
198 (let* ((re-core (concat "\\(" | 201 (let* ((re-core (concat "\\(" |
199 (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|") | 202 (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|") |
200 "\\)")) | 203 "\\)")) |
201 (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'")) | 204 (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'")) |
202 (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]")) | 205 (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]")) |
203 (error-fmt "Undefined label or reference %s. Ignore and continue? ") | 206 (error-fmt "Undefined label or reference %s. Ignore and continue? ") |
204 (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0)) | 207 (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0)) |
227 | 230 |
228 ;; Save all document buffers before this operation | 231 ;; Save all document buffers before this operation |
229 (reftex-save-all-document-buffers) | 232 (reftex-save-all-document-buffers) |
230 | 233 |
231 ;; First test to check for erros | 234 ;; First test to check for erros |
232 (setq n (reftex-translate | 235 (setq n (reftex-translate |
233 files search-re translate-alist error-fmt 'test)) | 236 files search-re translate-alist error-fmt 'test)) |
234 | 237 |
235 ;; Now the real thing. | 238 ;; Now the real thing. |
236 (if (yes-or-no-p | 239 (if (yes-or-no-p |
237 (format "Replace %d items at %d places in %d files? " | 240 (format "Replace %d items at %d places in %d files? " |
238 (length translate-alist) n (length files))) | 241 (length translate-alist) n (length files))) |
239 (progn | 242 (progn |
240 (let ((inhibit-quit t)) ;; Do not disturb... | 243 (let ((inhibit-quit t)) ;; Do not disturb... |
241 (reftex-translate | 244 (reftex-translate |
249 (message "Done replacing simple labels.")) | 252 (message "Done replacing simple labels.")) |
250 (message "No replacements done")))) | 253 (message "No replacements done")))) |
251 | 254 |
252 (defun reftex-translate (files search-re translate-alist error-fmt test) | 255 (defun reftex-translate (files search-re translate-alist error-fmt test) |
253 ;; In FILES, look for SEARCH-RE and replace match 1 of it with | 256 ;; In FILES, look for SEARCH-RE and replace match 1 of it with |
254 ;; its association in TRANSLATE-ALSIT. | 257 ;; its association in TRANSLATE-ALSIT. |
255 ;; If we do not find an association and TEST is non-nil, query | 258 ;; If we do not find an association and TEST is non-nil, query |
256 ;; to ignore the problematic string. | 259 ;; to ignore the problematic string. |
257 ;; If TEST is nil, it is ignored without query. | 260 ;; If TEST is nil, it is ignored without query. |
258 ;; Return the number of replacements. | 261 ;; Return the number of replacements. |
259 (let ((n 0) file label match-data buf macro pos cell) | 262 (let ((n 0) file label match-data buf macro pos cell) |
260 (while (setq file (pop files)) | 263 (while (setq file (pop files)) |
261 (setq buf (reftex-get-file-buffer-force file)) | 264 (setq buf (reftex-get-file-buffer-force file)) |
277 (goto-char (or pos (point))) | 280 (goto-char (or pos (point))) |
278 (when (and macro | 281 (when (and macro |
279 (or (looking-at "\\\\ref") | 282 (or (looking-at "\\\\ref") |
280 (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]") | 283 (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]") |
281 (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]") | 284 (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]") |
282 (looking-at (format | 285 (looking-at (format |
283 reftex-find-label-regexp-format | 286 reftex-find-label-regexp-format |
284 (regexp-quote label))))) | 287 (regexp-quote label))))) |
285 ;; OK, we should replace it. | 288 ;; OK, we should replace it. |
286 (set-match-data match-data) | 289 (set-match-data match-data) |
287 (cond | 290 (cond |
340 (buffer-name buf))) | 343 (buffer-name buf))) |
341 (error "Abort")))))) | 344 (error "Abort")))))) |
342 | 345 |
343 (defun reftex-isearch-wrap-function () | 346 (defun reftex-isearch-wrap-function () |
344 (if (not isearch-word) | 347 (if (not isearch-word) |
345 (switch-to-buffer | 348 (switch-to-buffer |
346 (funcall isearch-next-buffer-function (current-buffer) t))) | 349 (funcall isearch-next-buffer-function (current-buffer) t))) |
347 (goto-char (if isearch-forward (point-min) (point-max)))) | 350 (goto-char (if isearch-forward (point-min) (point-max)))) |
348 | 351 |
349 (defun reftex-isearch-push-state-function () | 352 (defun reftex-isearch-push-state-function () |
350 `(lambda (cmd) | 353 `(lambda (cmd) |
426 With no argument, this command toggles | 429 With no argument, this command toggles |
427 `reftex-isearch-minor-mode'. With a prefix argument ARG, turn | 430 `reftex-isearch-minor-mode'. With a prefix argument ARG, turn |
428 `reftex-isearch-minor-mode' on iff ARG is positive." | 431 `reftex-isearch-minor-mode' on iff ARG is positive." |
429 (interactive "P") | 432 (interactive "P") |
430 (let ((old-reftex-isearch-minor-mode reftex-isearch-minor-mode)) | 433 (let ((old-reftex-isearch-minor-mode reftex-isearch-minor-mode)) |
431 (setq reftex-isearch-minor-mode | 434 (setq reftex-isearch-minor-mode |
432 (not (or (and (null arg) reftex-isearch-minor-mode) | 435 (not (or (and (null arg) reftex-isearch-minor-mode) |
433 (<= (prefix-numeric-value arg) 0)))) | 436 (<= (prefix-numeric-value arg) 0)))) |
434 (unless (eq reftex-isearch-minor-mode old-reftex-isearch-minor-mode) | 437 (unless (eq reftex-isearch-minor-mode old-reftex-isearch-minor-mode) |
435 (if reftex-isearch-minor-mode | 438 (if reftex-isearch-minor-mode |
436 (progn | 439 (progn |
457 (setq reftex-isearch-minor-mode nil)))) | 460 (setq reftex-isearch-minor-mode nil)))) |
458 (remove-hook 'reftex-mode-hook 'reftex-isearch-minor-mode))) | 461 (remove-hook 'reftex-mode-hook 'reftex-isearch-minor-mode))) |
459 ;; Force modeline redisplay. | 462 ;; Force modeline redisplay. |
460 (set-buffer-modified-p (buffer-modified-p)))) | 463 (set-buffer-modified-p (buffer-modified-p)))) |
461 | 464 |
462 (add-minor-mode 'reftex-isearch-minor-mode "/I" nil nil | 465 (add-minor-mode 'reftex-isearch-minor-mode "/I" nil nil |
463 'reftex-isearch-minor-mode) | 466 'reftex-isearch-minor-mode) |
464 | 467 |
465 ;;; arch-tag: 2dbf7633-92c8-4340-8656-7aa019d0f80d | 468 ;;; arch-tag: 2dbf7633-92c8-4340-8656-7aa019d0f80d |
466 ;;; reftex-global.el ends here | 469 ;;; reftex-global.el ends here |