annotate lisp/textmodes/reftex-global.el @ 30633:3ea6ae5c3939

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Mon, 07 Aug 2000 10:34:08 +0000
parents 31536c6cf2e3
children 5eec8d1d09f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
1 ;;; reftex-global.el - Operations on entire documents with RefTeX
27192
f70a80cecdd3 New version number.
Carsten Dominik <dominik@science.uva.nl>
parents: 27035
diff changeset
2 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
3
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
4 ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
29775
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
5 ;; Version: 4.14
27192
f70a80cecdd3 New version number.
Carsten Dominik <dominik@science.uva.nl>
parents: 27035
diff changeset
6 ;;
27035
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
7
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
8 ;; This file is part of GNU Emacs.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
9
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
13 ;; any later version.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
14
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
18 ;; GNU General Public License for more details.
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
19
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
20 ;; You should have received a copy of the GNU General Public License
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
083669ed376a Supply licensing info.
Richard M. Stallman <rms@gnu.org>
parents: 26910
diff changeset
23 ;; Boston, MA 02111-1307, USA.
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
24
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
25 (eval-when-compile (require 'cl))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
26 (provide 'reftex-global)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
27 (require 'reftex)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
28 ;;;
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
29
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
30 (defun reftex-create-tags-file ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
31 "Create TAGS file by running `etags' on the current document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
32 The TAGS file is also immediately visited with `visit-tags-table'."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
33 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
34 (reftex-access-scan-info current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
35 (let* ((master (reftex-TeX-master-file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
36 (files (reftex-all-document-files))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
37 (cmd (format "etags %s" (mapconcat 'identity files " "))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
38 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
39 (set-buffer (reftex-get-buffer-visiting master))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
40 (message "Running etags to create TAGS file...")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
41 (shell-command cmd)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
42 (visit-tags-table "TAGS"))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
43
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
44 ;; History of grep commands.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
45 (defvar reftex-grep-history nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
46 (defvar reftex-grep-command "grep -n "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
47 "Last grep command used in \\[reftex-grep-document]; default for next grep.")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
48
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
49 (defun reftex-grep-document (grep-cmd)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
50 "Run grep query through all files related to this document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
51 With prefix arg, force to rescan document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
52 No active TAGS table is required."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
53
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
54 (interactive
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
55 (list (read-from-minibuffer "Run grep on document (like this): "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
56 reftex-grep-command nil nil
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
57 'reftex-grep-history)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
58 (reftex-access-scan-info current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
59 (let* ((files (reftex-all-document-files t))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
60 (cmd (format
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
61 "%s %s" grep-cmd
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
62 (mapconcat 'identity files " "))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
63 (grep cmd)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
64
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
65 (defun reftex-search-document (&optional regexp)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
66 "Regexp search through all files of the current document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
67 Starts always in the master file. Stops when a match is found.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
68 To continue searching for next match, use command \\[tags-loop-continue].
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
69 No active TAGS table is required."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
70 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
71 (let ((default (reftex-this-word)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
72 (unless regexp
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
73 (setq regexp (read-string (format "Search regexp in document [%s]: "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
74 default))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
75 (if (string= regexp "") (setq regexp (regexp-quote default)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
76
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
77 (reftex-access-scan-info current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
78 (tags-search regexp (list 'reftex-all-document-files))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
79
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
80 (defun reftex-query-replace-document (&optional from to delimited)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
81 "Run a query-replace-regexp of FROM with TO over the entire document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
82 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
83 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
84 with the command \\[tags-loop-continue].
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
85 No active TAGS table is required."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
86 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
87 (let ((default (reftex-this-word)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
88 (unless from
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
89 (setq from (read-string (format "Replace regexp in document [%s]: "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
90 default)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
91 (if (string= from "") (setq from (regexp-quote default))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
92 (unless to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
93 (setq to (read-string (format "Replace regexp %s with: " from))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
94 (reftex-access-scan-info current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
95 (tags-query-replace from to (or delimited current-prefix-arg)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
96 (list 'reftex-all-document-files))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
97
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
98 (defun reftex-find-duplicate-labels ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
99 "Produce a list of all duplicate labels in the document."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
100
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
101 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
102
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
103 ;; Rescan the document to make sure
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
104 (reftex-access-scan-info t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
105
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
106 (let ((master (reftex-TeX-master-file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
107 (cnt 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
108 (dlist
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
109 (mapcar
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
110 (lambda (x)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
111 (let (x1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
112 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
113 ((memq (car x)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
114 '(toc bof eof bib thebib label-numbers xr xr-doc
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
115 master-dir file-error bibview-cache appendix
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
116 is-multi index))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
117 nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
118 (t
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
119 (setq x1 (reftex-all-assoc-string
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
120 (car x) (symbol-value reftex-docstruct-symbol)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
121 (if (< 1 (length x1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
122 (append (list (car x))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
123 (mapcar (lambda(x)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
124 (abbreviate-file-name (nth 3 x)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
125 x1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
126 (list nil))))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
127 (reftex-uniquify-by-car (symbol-value reftex-docstruct-symbol)))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
128
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
129 (setq dlist (reftex-uniquify-by-car dlist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
130 (if (null dlist) (error "No duplicate labels in document"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
131 (switch-to-buffer-other-window "*Duplicate Labels*")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
132 (set (make-local-variable 'TeX-master) master)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
133 (erase-buffer)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
134 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
135 (insert
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
136 " Move point to label and type `r' to run a query-replace on the label\n"
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
137 " and its references. Type `q' to exit this buffer.\n\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
138 (insert " LABEL FILE\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
139 (insert " -------------------------------------------------------------\n")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
140 (use-local-map (make-sparse-keymap))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
141 (local-set-key [?q] (lambda () "Kill this buffer." (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
142 (kill-buffer (current-buffer)) (delete-window)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
143 (local-set-key [?r] 'reftex-change-label)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
144 (while dlist
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
145 (when (and (car (car dlist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
146 (cdr (car dlist)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
147 (incf cnt)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
148 (insert (mapconcat 'identity (car dlist) "\n ") "\n"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
149 (pop dlist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
150 (goto-char (point-min))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
151 (when (= cnt 0)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
152 (kill-buffer (current-buffer))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
153 (delete-window)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
154 (message "Document does not contain duplicate labels."))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
155
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
156 (defun reftex-change-label (&optional from to)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
157 "Query replace FROM with TO in all \\label and \\ref commands.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
158 Works on the entire multifile document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
159 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
160 with the command \\[tags-loop-continue].
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
161 No active TAGS table is required."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
162 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
163 (let ((default (reftex-this-word "-a-zA-Z0-9_*.:")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
164 (unless from
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
165 (setq from (read-string (format "Replace label globally [%s]: "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
166 default))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
167 (if (string= from "") (setq from default))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
168 (unless to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
169 (setq to (read-string (format "Replace label %s with: "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
170 from))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
171 (reftex-query-replace-document
27603
37b7d4f540f1 (reftex-change-label): add `A-Z' to char class in regexp.
Carsten Dominik <dominik@science.uva.nl>
parents: 27192
diff changeset
172 (concat "\\\\\\(label\\|[a-zA-Z]*ref\\){" (regexp-quote from) "}")
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
173 (format "\\\\\\1{%s}" to))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
174
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
175 (defun reftex-renumber-simple-labels ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
176 "Renumber all simple labels in the document to make them sequentially.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
177 Simple labels are the ones created by RefTeX, consisting only of the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
178 prefix and a number. After the command completes, all these labels will
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
179 have sequential numbers throughout the document. Any references to
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
180 the labels will be changed as well. For this, RefTeX looks at the
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
181 arguments of any macros which either start or end in the string `ref'.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
182 This command should be used with care, in particular in multifile
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
183 documents. You should not use it if another document refers to this
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
184 one with the `xr' package."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
185 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
186 ;; Resan the entire document
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
187 (reftex-access-scan-info 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
188 ;; Get some insurance
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
189 (if (and (reftex-is-multi)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
190 (not (yes-or-no-p "Replacing all simple labels in multiple files is risky. Continue? ")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
191 (error "Abort"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
192 ;; Make the translation list
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
193 (let* ((re-core (concat "\\("
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
194 (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
195 "\\)"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
196 (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
197 (search-re (concat "[{,]\\(" re-core "\\([0-9]+\\)\\)[,}]"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
198 (error-fmt "Undefined label or reference %s. Ignore and continue? ")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
199 (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
200 reftex-typekey-to-prefix-alist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
201 (files (reftex-all-document-files))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
202 (list (symbol-value reftex-docstruct-symbol))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
203 translate-alist n entry label new-label nr-cell changed-sequence)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
204
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
205 (while (setq entry (pop list))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
206 (when (and (stringp (car entry))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
207 (string-match label-re (car entry)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
208 (setq label (car entry)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
209 nr-cell (assoc (match-string 1 (car entry))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
210 label-numbers-alist))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
211 (if (assoc label translate-alist)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
212 (error "Duplicate label %s" label))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
213 (setq new-label (concat (match-string 1 (car entry))
26910
489a5439b988 * reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents: 25806
diff changeset
214 (int-to-string (incf (cdr nr-cell)))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
215 (push (cons label new-label) translate-alist)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
216 (or (string= label new-label) (setq changed-sequence t))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
217
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
218 (unless changed-sequence
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
219 (error "Simple labels are already in correct sequence"))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
220
29775
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
221 (reftex-ensure-write-access (reftex-all-document-files))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
222
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
223 ;; Save all document buffers before this operation
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
224 (reftex-save-all-document-buffers)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
225
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
226 ;; First test to check for erros
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
227 (setq n (reftex-translate
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
228 files search-re translate-alist error-fmt 'test))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
229
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
230 ;; Now the real thing.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
231 (if (yes-or-no-p
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
232 (format "Replace %d items at %d places in %d files? "
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
233 (length translate-alist) n (length files)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
234 (progn
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
235 (let ((inhibit-quit t)) ;; Do not disturb...
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
236 (reftex-translate
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
237 files search-re translate-alist error-fmt nil)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
238 (setq quit-flag nil))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
239 (if (and (reftex-is-multi)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
240 (yes-or-no-p "Save entire document? "))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
241 (reftex-save-all-document-buffers))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
242 ;; Rescan again...
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
243 (reftex-access-scan-info 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
244 (message "Done replacing simple labels."))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
245 (message "No replacements done"))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
246
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
247 (defun reftex-translate (files search-re translate-alist error-fmt test)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
248 ;; In FILES, look for SEARCH-RE and replace match 1 of it with
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
249 ;; its association in TRANSLATE-ALSIT.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
250 ;; If we do not find an association and TEST is non-nil, query
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
251 ;; to ignore the problematic string.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
252 ;; If TEST is nil, it is ignored without query.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
253 ;; Return the number of replacements.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
254 (let ((n 0) file label match-data buf macro pos cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
255 (while (setq file (pop files))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
256 (setq buf (reftex-get-file-buffer-force file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
257 (unless buf
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
258 (error "No such file %s" file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
259 (set-buffer buf)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
260 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
261 (save-restriction
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
262 (widen)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
263 (goto-char (point-min))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
264 (while (re-search-forward search-re nil t)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
265 (backward-char)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
266 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
267 (setq label (reftex-match-string 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
268 cell (assoc label translate-alist)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
269 match-data (match-data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
270 macro (reftex-what-macro 1)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
271 pos (cdr macro))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
272 (goto-char (or pos (point)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
273 (when (and macro
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
274 (or (looking-at "\\\\ref")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
275 (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
276 (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]")
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
277 (looking-at (format
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
278 reftex-find-label-regexp-format
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
279 (regexp-quote label)))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
280 ;; OK, we should replace it.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
281 (set-match-data match-data)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
282 (cond
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
283 ((and test (not cell))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
284 ;; We've got a problem
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
285 (unwind-protect
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
286 (progn
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
287 (reftex-highlight 1 (match-beginning 0) (match-end 0))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
288 (ding)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
289 (or (y-or-n-p (format error-fmt label))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
290 (error "Abort")))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
291 (reftex-unhighlight 1)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
292 ((and test cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
293 (incf n))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
294 ((and (not test) cell)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
295 ;; Replace
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
296 (goto-char (match-beginning 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
297 (delete-region (match-beginning 1) (match-end 1))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
298 (insert (cdr cell)))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
299 (t nil))))))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
300 n))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
301
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
302 (defun reftex-save-all-document-buffers ()
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
303 "Save all documents associated with the current document.
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
304 The function is useful after a global action like replacing or renumbering
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
305 labels."
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
306 (interactive)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
307 (let ((files (reftex-all-document-files))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
308 file buffer)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
309 (save-excursion
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
310 (while (setq file (pop files))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
311 (setq buffer (reftex-get-buffer-visiting file))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
312 (when buffer
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
313 (set-buffer buffer)
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
314 (save-buffer))))))
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
315
29775
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
316 (defun reftex-ensure-write-access (files)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
317 "Make sure we have write access to all files in FILES.
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
318 Also checks if buffers visiting the files are in read-only mode."
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
319 (let (file buf)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
320 (while (setq file (pop files))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
321 (unless (file-exists-p file)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
322 (ding)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
323 (or (y-or-n-p (format "No such file %s. Continue? " file))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
324 (error "Abort")))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
325 (unless (file-writable-p file)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
326 (ding)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
327 (or (y-or-n-p (format "No write access to %s. Continue? " file))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
328 (error "Abort")))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
329 (when (and (setq buf (reftex-get-buffer-visiting file))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
330 (save-excursion
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
331 (set-buffer buf)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
332 buffer-read-only))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
333 (ding)
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
334 (or (y-or-n-p (format "Buffer %s is read-only. Continue? "
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
335 (buffer-name buf)))
31536c6cf2e3 * textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents: 27603
diff changeset
336 (error "Abort"))))))
25280
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
337
9b601931b795 Initial revision
Carsten Dominik <dominik@science.uva.nl>
parents:
diff changeset
338 ;;; reftex-global.el ends here