/[emacs]/emacs/lisp/textmodes/reftex-cite.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/reftex-cite.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by ttn, Sat Aug 6 17:41:15 2005 UTC revision 1.31 by cdominik, Fri Sep 16 10:01:33 2005 UTC
# Line 1  Line 1 
1  ;;; reftex-cite.el --- creating citations with RefTeX  ;;; reftex-cite.el --- creating citations with RefTeX
2    ;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005
3  ;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,  ;;  Free Software Foundation, Inc.
 ;;   2005 Free Software Foundation, Inc.  
4    
5  ;; Author: Carsten Dominik <dominik@science.uva.nl>  ;; Author: Carsten Dominik <dominik@science.uva.nl>
6  ;; Version: 4.28  ;; Version: VERSIONTAG
7    
8  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
9    
# Line 20  Line 19 
19    
20  ;; You should have received a copy of the GNU General Public License  ;; You should have received a copy of the GNU General Public License
21  ;; along with GNU Emacs; see the file COPYING.  If not, write to the  ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22  ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,  ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  ;; Boston, MA 02110-1301, USA.  ;; Boston, MA 02111-1307, USA.
24    
25  ;;; Commentary:  ;;; Commentary:
26    
# Line 70  Line 69 
69    (unless (eq (get 'reftex-default-bibliography :reftex-raw)    (unless (eq (get 'reftex-default-bibliography :reftex-raw)
70                reftex-default-bibliography)                reftex-default-bibliography)
71      (put 'reftex-default-bibliography :reftex-expanded      (put 'reftex-default-bibliography :reftex-expanded
72           (reftex-locate-bibliography-files           (reftex-locate-bibliography-files
73            default-directory reftex-default-bibliography))            default-directory reftex-default-bibliography))
74      (put 'reftex-default-bibliography :reftex-raw      (put 'reftex-default-bibliography :reftex-raw
75           reftex-default-bibliography))           reftex-default-bibliography))
# Line 129  Line 128 
128    ;; If RETURN is non-nil, just return the entry.    ;; If RETURN is non-nil, just return the entry.
129    
130    (let* ((re    (let* ((re
131            (if item            (if item
132                (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")                (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
133              (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)              (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
134                      "[, \t\r\n}]")))                      "[, \t\r\n}]")))
# Line 151  Line 150 
150            (when return            (when return
151              ;; Just return the relevant entry              ;; Just return the relevant entry
152              (if item (goto-char (match-end 0)))              (if item (goto-char (match-end 0)))
153              (setq return (buffer-substring              (setq return (buffer-substring
154                            (point) (reftex-end-of-bib-entry item)))                            (point) (reftex-end-of-bib-entry item)))
155              (set-buffer buffer-conf)              (set-buffer buffer-conf)
156              (throw 'exit return))              (throw 'exit return))
# Line 167  Line 166 
166          (error "No BibTeX entry with citation key %s" key)))))          (error "No BibTeX entry with citation key %s" key)))))
167    
168  (defun reftex-end-of-bib-entry (item)  (defun reftex-end-of-bib-entry (item)
169    (save-excursion    (save-excursion
170      (condition-case nil      (condition-case nil
171          (if item          (if item
172              (progn (end-of-line)              (progn (end-of-line)
173                     (re-search-forward                     (re-search-forward
174                      "\\\\bibitem\\|\\end{thebibliography}")                      "\\\\bibitem\\|\\end{thebibliography}")
# Line 190  Line 189 
189    
190      ;; Read a regexp, completing on known citation keys.      ;; Read a regexp, completing on known citation keys.
191      (setq default (regexp-quote (reftex-get-bibkey-default)))      (setq default (regexp-quote (reftex-get-bibkey-default)))
192      (setq re-list      (setq re-list
193            (split-string            (split-string
194             (completing-read             (completing-read
195              (concat              (concat
196               "Regex { && Regex...}: "               "Regex { && Regex...}: "
197               "[" default "]: ")               "[" default "]: ")
198              (if reftex-mode              (if reftex-mode
199                  (if (fboundp 'LaTeX-bibitem-list)                  (if (fboundp 'LaTeX-bibitem-list)
200                      (LaTeX-bibitem-list)                      (LaTeX-bibitem-list)
201                    (cdr (assoc 'bibview-cache                    (cdr (assoc 'bibview-cache
202                                (symbol-value reftex-docstruct-symbol))))                                (symbol-value reftex-docstruct-symbol))))
203                nil)                nil)
204              nil nil nil 'reftex-cite-regexp-hist)              nil nil nil 'reftex-cite-regexp-hist)
# Line 246  Line 245 
245                     (error (goto-char key-point)                     (error (goto-char key-point)
246                            (throw 'search-again nil)))                            (throw 'search-again nil)))
247                   (setq end-point (point))                   (setq end-point (point))
248                    
249                   ;; Ignore @string, @comment and @c entries or things                   ;; Ignore @string, @comment and @c entries or things
250                   ;; outside entries                   ;; outside entries
251                   (when (or (string= (downcase (match-string 2)) "string")                   (when (or (string= (downcase (match-string 2)) "string")
# Line 255  Line 254 
254                             (< (point) key-point)) ; this means match not in {}                             (< (point) key-point)) ; this means match not in {}
255                     (goto-char key-point)                     (goto-char key-point)
256                     (throw 'search-again nil))                     (throw 'search-again nil))
257                    
258                   ;; Well, we have got a match                   ;; Well, we have got a match
259                   ;;(setq entry (concat                   ;;(setq entry (concat
260                   ;;             (buffer-substring start-point (point)) "\n"))                   ;;             (buffer-substring start-point (point)) "\n"))
261                   (setq entry (buffer-substring start-point (point)))                   (setq entry (buffer-substring start-point (point)))
262                    
263                   ;; Check if other regexp match as well                   ;; Check if other regexp match as well
264                   (setq re-list rest-re)                   (setq re-list rest-re)
265                   (while re-list                   (while re-list
# Line 268  Line 267 
267                       ;; nope - move on                       ;; nope - move on
268                       (throw 'search-again nil))                       (throw 'search-again nil))
269                     (pop re-list))                     (pop re-list))
270                    
271                   (setq alist (reftex-parse-bibtex-entry                   (setq alist (reftex-parse-bibtex-entry
272                                nil start-point end-point))                                nil start-point end-point))
273                   (push (cons "&entry" entry) alist)                   (push (cons "&entry" entry) alist)
274                    
275                   ;; check for crossref entries                   ;; check for crossref entries
276                   (if (assoc "crossref" alist)                   (if (assoc "crossref" alist)
277                       (setq alist                       (setq alist
278                             (append                             (append
279                              alist (reftex-get-crossref-alist alist))))                              alist (reftex-get-crossref-alist alist))))
280                    
281                   ;; format the entry                   ;; format the entry
282                   (push (cons "&formatted" (reftex-format-bib-entry alist))                   (push (cons "&formatted" (reftex-format-bib-entry alist))
283                         alist)                         alist)
284                    
285                   ;; make key the first element                   ;; make key the first element
286                   (push (reftex-get-bib-field "&key" alist) alist)                   (push (reftex-get-bib-field "&key" alist) alist)
287                    
288                   ;; add it to the list                   ;; add it to the list
289                   (push alist found-list)))))                   (push alist found-list)))))
290            (reftex-kill-temporary-buffers))))            (reftex-kill-temporary-buffers))))
# Line 348  Line 347 
347      (unless files      (unless files
348        (error "Need file name to find thebibliography environment"))        (error "Need file name to find thebibliography environment"))
349      (while (setq file (pop files))      (while (setq file (pop files))
350        (setq buf (reftex-get-file-buffer-force        (setq buf (reftex-get-file-buffer-force
351                   file (not reftex-keep-temporary-buffers)))                   file (not reftex-keep-temporary-buffers)))
352        (unless buf        (unless buf
353          (error "No such file %s" file))          (error "No such file %s" file))
# Line 359  Line 358 
358          (save-restriction          (save-restriction
359            (widen)            (widen)
360            (goto-char (point-min))            (goto-char (point-min))
361            (while (re-search-forward            (while (re-search-forward
362                    "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)                    "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
363              (beginning-of-line 2)              (beginning-of-line 2)
364              (setq start (point))              (setq start (point))
365              (if (re-search-forward              (if (re-search-forward
366                   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)                   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
367                  (progn                  (progn
368                    (beginning-of-line 1)                    (beginning-of-line 1)
369                    (setq end (point))))                    (setq end (point))))
370              (when (and start end)              (when (and start end)
371                (setq entries                (setq entries
372                      (append entries                      (append entries
373                        (mapcar 'reftex-parse-bibitem                        (mapcar 'reftex-parse-bibitem
374                          (delete ""                          (delete ""
375                                  (split-string                                  (split-string
376                                   (buffer-substring-no-properties start end)                                   (buffer-substring-no-properties start end)
377                                   "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))                                   "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
378              (goto-char end)))))              (goto-char end)))))
# Line 382  Line 381 
381    
382      ;; Read a regexp, completing on known citation keys.      ;; Read a regexp, completing on known citation keys.
383      (setq default (regexp-quote (reftex-get-bibkey-default)))      (setq default (regexp-quote (reftex-get-bibkey-default)))
384      (setq re-list      (setq re-list
385            (split-string            (split-string
386             (completing-read             (completing-read
387              (concat              (concat
388               "Regex { && Regex...}: "               "Regex { && Regex...}: "
389               "[" default "]: ")               "[" default "]: ")
390              (if reftex-mode              (if reftex-mode
391                  (if (fboundp 'LaTeX-bibitem-list)                  (if (fboundp 'LaTeX-bibitem-list)
392                      (LaTeX-bibitem-list)                      (LaTeX-bibitem-list)
393                    (cdr (assoc 'bibview-cache                    (cdr (assoc 'bibview-cache
394                                (symbol-value reftex-docstruct-symbol))))                                (symbol-value reftex-docstruct-symbol))))
395                nil)                nil)
396              nil nil nil 'reftex-cite-regexp-hist)              nil nil nil 'reftex-cite-regexp-hist)
# Line 404  Line 403 
403          (error "Empty regular expression"))          (error "Empty regular expression"))
404    
405      (while (and (setq re (pop re-list)) entries)      (while (and (setq re (pop re-list)) entries)
406        (setq entries        (setq entries
407              (delq nil (mapcar              (delq nil (mapcar
408                         (lambda (x)                         (lambda (x)
409                           (if (string-match re (cdr (assoc "&entry" x)))                           (if (string-match re (cdr (assoc "&entry" x)))
410                               x nil))                               x nil))
411                         entries))))                         entries))))
412      (setq entries      (setq entries
413            (mapcar            (mapcar
414              (lambda (x)              (lambda (x)
415                (push (cons "&formatted" (reftex-format-bibitem x)) x)                (push (cons "&formatted" (reftex-format-bibitem x)) x)
416                (push (reftex-get-bib-field "&key" x) x)                (push (reftex-get-bib-field "&key" x) x)
# Line 632  While entering the regexp, completion on Line 631  While entering the regexp, completion on
631    ;; This really does the work of reftex-citation.    ;; This really does the work of reftex-citation.
632    
633    (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))    (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
          (start 0)  
634           (docstruct-symbol reftex-docstruct-symbol)           (docstruct-symbol reftex-docstruct-symbol)
635           (selected-entries (reftex-offer-bib-menu))           (selected-entries (reftex-offer-bib-menu))
636           (insert-entries selected-entries)           (insert-entries selected-entries)
# Line 655  While entering the regexp, completion on Line 653  While entering the regexp, completion on
653        ;; FIXME: Unfortunately, this meens that commenting does not work right.        ;; FIXME: Unfortunately, this meens that commenting does not work right.
654        (pop selected-entries)        (pop selected-entries)
655        (let ((concat-keys (mapconcat 'car selected-entries ",")))        (let ((concat-keys (mapconcat 'car selected-entries ",")))
656          (setq insert-entries          (setq insert-entries
657                (list (list concat-keys (cons "&key" concat-keys))))))                (list (list concat-keys (cons "&key" concat-keys))))))
658        
659      (unless no-insert      (unless no-insert
660    
661        ;; We shall insert this into the buffer...        ;; We shall insert this into the buffer...
# Line 684  While entering the regexp, completion on Line 682  While entering the regexp, completion on
682          ;; it has to go.  If there is only a single arg and empty, it can go          ;; it has to go.  If there is only a single arg and empty, it can go
683          ;; as well.          ;; as well.
684          (when reftex-cite-cleanup-optional-args          (when reftex-cite-cleanup-optional-args
685            (cond            (cond
686             ((string-match "\\([a-zA-Z0-9]\\)\\[\\]{" string)             ((string-match "\\([a-zA-Z0-9]\\)\\[\\]{" string)
687              (setq string (replace-match "\\1{" nil nil string)))              (setq string (replace-match "\\1{" nil nil string)))
688             ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string)             ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string)
# Line 699  While entering the regexp, completion on Line 697  While entering the regexp, completion on
697          (delete-char 1))          (delete-char 1))
698    
699        ;; Tell AUCTeX        ;; Tell AUCTeX
700        (when (and reftex-mode        (when (and reftex-mode
701                   (fboundp 'LaTeX-add-bibitems)                   (fboundp 'LaTeX-add-bibitems)
702                   reftex-plug-into-AUCTeX)                   reftex-plug-into-AUCTeX)
703          (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))          (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
704          
705        ;; Produce the cite-view strings        ;; Produce the cite-view strings
706        (when (and reftex-mode reftex-cache-cite-echo cite-view)        (when (and reftex-mode reftex-cache-cite-echo cite-view)
707          (mapcar (lambda (entry)          (mapcar (lambda (entry)
708                    (reftex-make-cite-echo-string entry docstruct-symbol))                    (reftex-make-cite-echo-string entry docstruct-symbol))
709                  selected-entries))                  selected-entries))
710    
# Line 714  While entering the regexp, completion on Line 712  While entering the regexp, completion on
712    
713      (set-marker reftex-select-return-marker nil)      (set-marker reftex-select-return-marker nil)
714      (reftex-kill-buffer "*RefTeX Select*")      (reftex-kill-buffer "*RefTeX Select*")
715        
716      ;; Check if the prefix arg was numeric, and call recursively      ;; Check if the prefix arg was numeric, and call recursively
717      (when (integerp arg)      (when (integerp arg)
718        (if (> arg 1)        (if (> arg 1)
719            (progn            (progn      
720              (skip-chars-backward "}")              (skip-chars-backward "}")
721              (decf arg)              (decf arg)
722              (reftex-do-citation arg))              (reftex-do-citation arg))
723          (forward-char 1)))          (forward-char 1)))
724        
725      ;; Return the citation key      ;; Return the citation key
726      (car (car selected-entries))))      (car (car selected-entries))))
727    
# Line 737  While entering the regexp, completion on Line 735  While entering the regexp, completion on
735       (no-insert       (no-insert
736        ;; Format does not really matter because nothing will be inserted.        ;; Format does not really matter because nothing will be inserted.
737        (setq format "%l"))        (setq format "%l"))
738        
739       ((and (stringp macro)       ((and (stringp macro)
740             (string-match "\\`\\\\cite\\|cite\\'" macro))             (string-match "\\`\\\\cite\\|cite\\'" macro))
741        ;; We are already inside a cite macro        ;; We are already inside a cite macro
# Line 758  While entering the regexp, completion on Line 756  While entering the regexp, completion on
756        (when (listp format)        (when (listp format)
757          (setq key          (setq key
758                (or format-key                (or format-key
759                    (reftex-select-with-char                    (reftex-select-with-char
760                     "" (concat "SELECT A CITATION FORMAT\n\n"                     "" (concat "SELECT A CITATION FORMAT\n\n"
761                                (mapconcat                                (mapconcat
762                                 (lambda (x)                                 (lambda (x)
# Line 787  While entering the regexp, completion on Line 785  While entering the regexp, completion on
785    
786    (let ((bibtype (reftex-bib-or-thebib))    (let ((bibtype (reftex-bib-or-thebib))
787          found-list rtn key data selected-entries)          found-list rtn key data selected-entries)
788      (while      (while
789          (not          (not
790           (catch 'done           (catch 'done
791             ;; Scan bibtex files             ;; Scan bibtex files
792             (setq found-list             (setq found-list
# Line 803  While entering the regexp, completion on Line 801  While entering the regexp, completion on
801                  (reftex-extract-bib-entries-from-thebibliography                  (reftex-extract-bib-entries-from-thebibliography
802                   (reftex-uniquify                   (reftex-uniquify
803                    (mapcar 'cdr                    (mapcar 'cdr
804                            (reftex-all-assq                            (reftex-all-assq
805                             'thebib (symbol-value reftex-docstruct-symbol))))))                             'thebib (symbol-value reftex-docstruct-symbol))))))
806                 (reftex-default-bibliography                 (reftex-default-bibliography
807                  (message "Using default bibliography")                  (message "Using default bibliography")
808                  (reftex-extract-bib-entries (reftex-default-bibliography)))                  (reftex-extract-bib-entries (reftex-default-bibliography)))
809                 (t (error "No valid bibliography in this document, and no default available"))))                 (t (error "No valid bibliography in this document, and no default available"))))
810              
811             (unless found-list             (unless found-list
812               (error "Sorry, no matches found"))               (error "Sorry, no matches found"))
813        
814            ;; Remember where we came from            ;; Remember where we came from
815            (setq reftex-call-back-to-this-buffer (current-buffer))            (setq reftex-call-back-to-this-buffer (current-buffer))
816            (set-marker reftex-select-return-marker (point))            (set-marker reftex-select-return-marker (point))
817        
818            ;; Offer selection            ;; Offer selection
819            (save-window-excursion            (save-window-excursion
820              (delete-other-windows)              (delete-other-windows)
# Line 857  While entering the regexp, completion on Line 855  While entering the regexp, completion on
855                  (goto-char 1))                  (goto-char 1))
856                 ((eq key ?A)                 ((eq key ?A)
857                  ;; Take all (marked)                  ;; Take all (marked)
858                  (setq selected-entries                  (setq selected-entries
859                        (if reftex-select-marked                        (if reftex-select-marked
860                            (mapcar 'car (nreverse reftex-select-marked))                            (mapcar 'car (nreverse reftex-select-marked))
861                          found-list))                          found-list))
862                  (throw 'done t))                  (throw 'done t))
863                 ((eq key ?a)                 ((eq key ?a)
864                  ;; Take all (marked), and push the symbol 'concat                  ;; Take all (marked), and push the symbol 'concat
865                  (setq selected-entries                  (setq selected-entries
866                        (cons 'concat                        (cons 'concat
867                              (if reftex-select-marked                              (if reftex-select-marked
868                                  (mapcar 'car (nreverse reftex-select-marked))                                  (mapcar 'car (nreverse reftex-select-marked))
869                                found-list)))                                found-list)))
# Line 884  While entering the regexp, completion on Line 882  While entering the regexp, completion on
882                 ((or (eq key ?\C-m)                 ((or (eq key ?\C-m)
883                      (eq key 'return))                      (eq key 'return))
884                  ;; Take selected                  ;; Take selected
885                  (setq selected-entries                  (setq selected-entries
886                        (if reftex-select-marked                        (if reftex-select-marked
887                            (cons 'concat                            (cons 'concat
888                                  (mapcar 'car (nreverse reftex-select-marked)))                                  (mapcar 'car (nreverse reftex-select-marked)))
889                          (if data (list data) nil)))                          (if data (list data) nil)))
890                  (throw 'done t))                  (throw 'done t))
# Line 926  While entering the regexp, completion on Line 924  While entering the regexp, completion on
924    (let ((file (read-file-name "File to create: ")))    (let ((file (read-file-name "File to create: ")))
925      (find-file-other-window file)      (find-file-other-window file)
926      (if (> (buffer-size) 0)      (if (> (buffer-size) 0)
927          (unless (yes-or-no-p          (unless (yes-or-no-p
928                   (format "Overwrite non-empty file %s? " file))                   (format "Overwrite non-empty file %s? " file))
929            (error "Abort")))            (error "Abort")))
930      (erase-buffer)      (erase-buffer)
# Line 951  While entering the regexp, completion on Line 949  While entering the regexp, completion on
949               reftex-mouse-selected-face               reftex-mouse-selected-face
950             nil))             nil))
951          tmp len)          tmp len)
952      (mapcar      (mapcar
953       (lambda (x)       (lambda (x)
954         (setq tmp (cdr (assoc "&formatted" x))         (setq tmp (cdr (assoc "&formatted" x))
955               len (length tmp))               len (length tmp))
# Line 1046  While entering the regexp, completion on Line 1044  While entering the regexp, completion on
1044  (defun reftex-make-cite-echo-string (entry docstruct-symbol)  (defun reftex-make-cite-echo-string (entry docstruct-symbol)
1045    ;; Format a bibtex entry for the echo area and cache the result.    ;; Format a bibtex entry for the echo area and cache the result.
1046    (let* ((key (reftex-get-bib-field "&key" entry))    (let* ((key (reftex-get-bib-field "&key" entry))
1047           (string           (string
1048            (let* ((reftex-cite-punctuation '(" " " & " " etal.")))            (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
1049              (reftex-format-citation entry reftex-cite-view-format)))              (reftex-format-citation entry reftex-cite-view-format)))
1050           (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))           (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
# Line 1088  While entering the regexp, completion on Line 1086  While entering the regexp, completion on
1086            (setq bibfile-list            (setq bibfile-list
1087                  (reftex-uniquify                  (reftex-uniquify
1088                   (mapcar 'cdr                   (mapcar 'cdr
1089                           (reftex-all-assq                           (reftex-all-assq
1090                            'thebib (symbol-value reftex-docstruct-symbol))))                            'thebib (symbol-value reftex-docstruct-symbol))))
1091                  item t))                  item t))
1092           (reftex-default-bibliography           (reftex-default-bibliography
# Line 1099  While entering the regexp, completion on Line 1097  While entering the regexp, completion on
1097          (setq bibfile-list (reftex-visited-files bibfile-list)))          (setq bibfile-list (reftex-visited-files bibfile-list)))
1098    
1099        (condition-case nil        (condition-case nil
1100            (reftex-pop-to-bibtex-entry            (reftex-pop-to-bibtex-entry
1101             key bibfile-list (not reftex-keep-temporary-buffers) t item)             key bibfile-list (not reftex-keep-temporary-buffers) t item)
1102          (error (ding))))          (error (ding))))
1103          
1104      (select-window win)))      (select-window win)))
1105    
1106  ;;; Global BibTeX file  ;;; Global BibTeX file
1107  (defun reftex-all-used-citation-keys ()  (defun reftex-all-used-citation-keys ()
1108    (reftex-access-scan-info)    (reftex-access-scan-info)
1109    (let ((files (reftex-all-document-files)) file keys kkk kk k)    (let ((files (reftex-all-document-files)) file keys kk k)
1110      (save-excursion      (save-excursion
1111        (while (setq file (pop files))        (while (setq file (pop files))
1112          (set-buffer (reftex-get-file-buffer-force file 'mark))          (set-buffer (reftex-get-file-buffer-force file 'mark))
# Line 1131  While entering the regexp, completion on Line 1129  While entering the regexp, completion on
1129    "Create a new BibTeX database file with all entries referenced in document.    "Create a new BibTeX database file with all entries referenced in document.
1130  The command prompts for a filename and writes the collected entries to  The command prompts for a filename and writes the collected entries to
1131  that file.  Only entries referenced in the current document with  that file.  Only entries referenced in the current document with
1132  any \\cite-like macros are used.  any \\cite-like macros are used.
1133  The sequence in the new file is the same as it was in the old database."  The sequence in the new file is the same as it was in the old database."
1134    (interactive "FNew BibTeX file: ")    (interactive "FNew BibTeX file: ")
1135    (let ((keys (reftex-all-used-citation-keys))    (let ((keys (reftex-all-used-citation-keys))
# Line 1145  The sequence in the new file is the same Line 1143  The sequence in the new file is the same
1143             (save-restriction             (save-restriction
1144               (widen)               (widen)
1145               (goto-char (point-min))               (goto-char (point-min))
1146               (while (re-search-forward               (while (re-search-forward
1147                       "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"                       "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
1148                       nil t)                       nil t)
1149                 (setq key (match-string 1)                 (setq key (match-string 1)
# Line 1162  The sequence in the new file is the same Line 1160  The sequence in the new file is the same
1160                         keys (delete key keys)))))))))                         keys (delete key keys)))))))))
1161      (find-file-other-window bibfile)      (find-file-other-window bibfile)
1162      (if (> (buffer-size) 0)      (if (> (buffer-size) 0)
1163          (unless (yes-or-no-p          (unless (yes-or-no-p
1164                   (format "Overwrite non-empty file %s? " bibfile))                   (format "Overwrite non-empty file %s? " bibfile))
1165            (error "Abort")))            (error "Abort")))
1166      (erase-buffer)      (erase-buffer)

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26