/[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.15 by cdominik, Mon Jul 22 10:36:26 2002 UTC revision 1.16 by cdominik, Thu Jul 25 07:03:41 2002 UTC
# Line 2  Line 2 
2  ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.  ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3    
4  ;; Author: Carsten Dominik <dominik@science.uva.nl>  ;; Author: Carsten Dominik <dominik@science.uva.nl>
5  ;; Version: 4.17  ;; Version: 4.18
6    
7  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
8    
# Line 164  Line 164 
164    (let* (re-list first-re rest-re    (let* (re-list first-re rest-re
165                   (buffer-list (if (listp buffers) buffers (list buffers)))                   (buffer-list (if (listp buffers) buffers (list buffers)))
166                   found-list entry buffer1 buffer alist                   found-list entry buffer1 buffer alist
167                   key-point start-point end-point)                   key-point start-point end-point default)
168    
169      ;; Read a regexp, completing on known citation keys.      ;; Read a regexp, completing on known citation keys.
170        (setq default (regexp-quote (reftex-get-bibkey-default)))
171      (setq re-list      (setq re-list
172            (split-string            (split-string
173             (completing-read             (completing-read
174              "RegExp [ && RegExp...]: "              (concat
175                 "Regex { && Regex...}: "
176                 "[" default "]: ")
177              (if reftex-mode              (if reftex-mode
178                  (if (fboundp 'LaTeX-bibitem-list)                  (if (fboundp 'LaTeX-bibitem-list)
179                      (LaTeX-bibitem-list)                      (LaTeX-bibitem-list)
# Line 180  Line 183 
183              nil nil nil 'reftex-cite-regexp-hist)              nil nil nil 'reftex-cite-regexp-hist)
184             "[ \t]*&&[ \t]*"))             "[ \t]*&&[ \t]*"))
185    
186        (if (or (null re-list ) (equal re-list '("")))
187            (setq re-list (list default)))
188    
189      (setq first-re (car re-list)    ; We'll use the first re to find things,      (setq first-re (car re-list)    ; We'll use the first re to find things,
190            rest-re  (cdr re-list))   ; the others to narrow down.            rest-re  (cdr re-list))   ; the others to narrow down.
191      (if (string-match "\\`[ \t]*\\'" (or first-re ""))      (if (string-match "\\`[ \t]*\\'" (or first-re ""))
# Line 315  Line 321 
321    ;; Parsing is not as good as for the BibTeX database stuff.    ;; Parsing is not as good as for the BibTeX database stuff.
322    ;; The environment should be located in file FILE.    ;; The environment should be located in file FILE.
323    
324    (let* (start end buf entries re re-list file)    (let* (start end buf entries re re-list file default)
325      (unless files      (unless files
326        (error "Need file name to find thebibliography environment"))        (error "Need file name to find thebibliography environment"))
327      (while (setq file (pop files))      (while (setq file (pop files))
# Line 351  Line 357 
357      (unless entries      (unless entries
358        (error "No bibitems found"))        (error "No bibitems found"))
359    
360      (setq re-list (split-string      ;; Read a regexp, completing on known citation keys.
361                     (read-string "RegExp [ && RegExp...]: "      (setq default (regexp-quote (reftex-get-bibkey-default)))
362                                  nil 'reftex-cite-regexp-hist)      (setq re-list
363                     "[ \t]*&&[ \t]*"))            (split-string
364               (completing-read
365                (concat
366                 "Regex { && Regex...}: "
367                 "[" default "]: ")
368                (if reftex-mode
369                    (if (fboundp 'LaTeX-bibitem-list)
370                        (LaTeX-bibitem-list)
371                      (cdr (assoc 'bibview-cache
372                                  (symbol-value reftex-docstruct-symbol))))
373                  nil)
374                nil nil nil 'reftex-cite-regexp-hist)
375               "[ \t]*&&[ \t]*"))
376    
377        (if (or (null re-list ) (equal re-list '("")))
378            (setq re-list (list default)))
379    
380      (if (string-match "\\`[ \t]*\\'" (car re-list))      (if (string-match "\\`[ \t]*\\'" (car re-list))
381          (error "Empty regular expression"))          (error "Empty regular expression"))
382    
# Line 375  Line 397 
397    
398      entries))      entries))
399    
400    (defun reftex-get-bibkey-default ()
401      ;; Return the word before the cursor.  If the cursor is in a
402      ;; citation macro, return the word before the macro.
403      (let* ((macro (reftex-what-macro 1)))
404        (save-excursion
405          (if (and macro (string-match "cite" (car macro)))
406              (goto-char (cdr macro)))
407          (skip-chars-backward "^a-zA-Z0-9")
408          (reftex-this-word))))
409    
410  ;; Parse and format individual entries  ;; Parse and format individual entries
411    
412  (defun reftex-get-bib-names (field entry)  (defun reftex-get-bib-names (field entry)

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

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