emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/textmodes/reftex-cite.el


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/textmodes/reftex-cite.el
Date: Fri, 04 Apr 2003 01:23:08 -0500

Index: emacs/lisp/textmodes/reftex-cite.el
diff -c emacs/lisp/textmodes/reftex-cite.el:1.17 
emacs/lisp/textmodes/reftex-cite.el:1.18
*** emacs/lisp/textmodes/reftex-cite.el:1.17    Tue Aug 20 06:41:00 2002
--- emacs/lisp/textmodes/reftex-cite.el Tue Feb  4 08:30:45 2003
***************
*** 68,74 ****
    (unless (eq (get 'reftex-default-bibliography :reftex-raw)
              reftex-default-bibliography)
      (put 'reftex-default-bibliography :reftex-expanded
!        (reftex-locate-bibliography-files 
          default-directory reftex-default-bibliography))
      (put 'reftex-default-bibliography :reftex-raw
         reftex-default-bibliography))
--- 68,74 ----
    (unless (eq (get 'reftex-default-bibliography :reftex-raw)
              reftex-default-bibliography)
      (put 'reftex-default-bibliography :reftex-expanded
!        (reftex-locate-bibliography-files
          default-directory reftex-default-bibliography))
      (put 'reftex-default-bibliography :reftex-raw
         reftex-default-bibliography))
***************
*** 127,133 ****
    ;; If RETURN is non-nil, just return the entry.
  
    (let* ((re
!         (if item 
              (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
            (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
                    "[, \t\r\n}]")))
--- 127,133 ----
    ;; If RETURN is non-nil, just return the entry.
  
    (let* ((re
!         (if item
              (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
            (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
                    "[, \t\r\n}]")))
***************
*** 149,155 ****
          (when return
            ;; Just return the relevant entry
            (if item (goto-char (match-end 0)))
!           (setq return (buffer-substring 
                          (point) (reftex-end-of-bib-entry item)))
            (set-buffer buffer-conf)
            (throw 'exit return))
--- 149,155 ----
          (when return
            ;; Just return the relevant entry
            (if item (goto-char (match-end 0)))
!           (setq return (buffer-substring
                          (point) (reftex-end-of-bib-entry item)))
            (set-buffer buffer-conf)
            (throw 'exit return))
***************
*** 165,173 ****
        (error "No BibTeX entry with citation key %s" key)))))
  
  (defun reftex-end-of-bib-entry (item)
!   (save-excursion 
      (condition-case nil
!       (if item 
            (progn (end-of-line)
                   (re-search-forward
                    "\\\\bibitem\\|\\end{thebibliography}")
--- 165,173 ----
        (error "No BibTeX entry with citation key %s" key)))))
  
  (defun reftex-end-of-bib-entry (item)
!   (save-excursion
      (condition-case nil
!       (if item
            (progn (end-of-line)
                   (re-search-forward
                    "\\\\bibitem\\|\\end{thebibliography}")
***************
*** 188,203 ****
  
      ;; Read a regexp, completing on known citation keys.
      (setq default (regexp-quote (reftex-get-bibkey-default)))
!     (setq re-list 
!         (split-string 
!          (completing-read 
            (concat
             "Regex { && Regex...}: "
             "[" default "]: ")
            (if reftex-mode
                (if (fboundp 'LaTeX-bibitem-list)
                    (LaTeX-bibitem-list)
!                 (cdr (assoc 'bibview-cache 
                              (symbol-value reftex-docstruct-symbol))))
              nil)
            nil nil nil 'reftex-cite-regexp-hist)
--- 188,203 ----
  
      ;; Read a regexp, completing on known citation keys.
      (setq default (regexp-quote (reftex-get-bibkey-default)))
!     (setq re-list
!         (split-string
!          (completing-read
            (concat
             "Regex { && Regex...}: "
             "[" default "]: ")
            (if reftex-mode
                (if (fboundp 'LaTeX-bibitem-list)
                    (LaTeX-bibitem-list)
!                 (cdr (assoc 'bibview-cache
                              (symbol-value reftex-docstruct-symbol))))
              nil)
            nil nil nil 'reftex-cite-regexp-hist)
***************
*** 244,250 ****
                   (error (goto-char key-point)
                            (throw 'search-again nil)))
                 (setq end-point (point))
!                
                 ;; Ignore @string, @comment and @c entries or things
                 ;; outside entries
                 (when (or (string= (downcase (match-string 2)) "string")
--- 244,250 ----
                   (error (goto-char key-point)
                            (throw 'search-again nil)))
                 (setq end-point (point))
! 
                 ;; Ignore @string, @comment and @c entries or things
                 ;; outside entries
                 (when (or (string= (downcase (match-string 2)) "string")
***************
*** 253,263 ****
                           (< (point) key-point)) ; this means match not in {}
                   (goto-char key-point)
                   (throw 'search-again nil))
!                
                 ;; Well, we have got a match
                 (setq entry (concat
                              (buffer-substring start-point (point)) "\n"))
!                
                 ;; Check if other regexp match as well
                 (setq re-list rest-re)
                 (while re-list
--- 253,263 ----
                           (< (point) key-point)) ; this means match not in {}
                   (goto-char key-point)
                   (throw 'search-again nil))
! 
                 ;; Well, we have got a match
                 (setq entry (concat
                              (buffer-substring start-point (point)) "\n"))
! 
                 ;; Check if other regexp match as well
                 (setq re-list rest-re)
                 (while re-list
***************
*** 265,288 ****
                     ;; nope - move on
                     (throw 'search-again nil))
                   (pop re-list))
!                
                 (setq alist (reftex-parse-bibtex-entry
                              nil start-point end-point))
                 (push (cons "&entry" entry) alist)
!                
                 ;; check for crossref entries
                 (if (assoc "crossref" alist)
                     (setq alist
                           (append
                            alist (reftex-get-crossref-alist alist))))
!                
                 ;; format the entry
                 (push (cons "&formatted" (reftex-format-bib-entry alist))
                       alist)
!                
                 ;; make key the first element
                 (push (reftex-get-bib-field "&key" alist) alist)
!                
                 ;; add it to the list
                 (push alist found-list)))))
          (reftex-kill-temporary-buffers))))
--- 265,288 ----
                     ;; nope - move on
                     (throw 'search-again nil))
                   (pop re-list))
! 
                 (setq alist (reftex-parse-bibtex-entry
                              nil start-point end-point))
                 (push (cons "&entry" entry) alist)
! 
                 ;; check for crossref entries
                 (if (assoc "crossref" alist)
                     (setq alist
                           (append
                            alist (reftex-get-crossref-alist alist))))
! 
                 ;; format the entry
                 (push (cons "&formatted" (reftex-format-bib-entry alist))
                       alist)
! 
                 ;; make key the first element
                 (push (reftex-get-bib-field "&key" alist) alist)
! 
                 ;; add it to the list
                 (push alist found-list)))))
          (reftex-kill-temporary-buffers))))
***************
*** 345,351 ****
      (unless files
        (error "Need file name to find thebibliography environment"))
      (while (setq file (pop files))
!       (setq buf (reftex-get-file-buffer-force 
                 file (not reftex-keep-temporary-buffers)))
        (unless buf
        (error "No such file %s" file))
--- 345,351 ----
      (unless files
        (error "Need file name to find thebibliography environment"))
      (while (setq file (pop files))
!       (setq buf (reftex-get-file-buffer-force
                 file (not reftex-keep-temporary-buffers)))
        (unless buf
        (error "No such file %s" file))
***************
*** 356,376 ****
        (save-restriction
          (widen)
          (goto-char (point-min))
!         (while (re-search-forward 
                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
            (beginning-of-line 2)
            (setq start (point))
!           (if (re-search-forward 
                 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
                (progn
                  (beginning-of-line 1)
                  (setq end (point))))
            (when (and start end)
!             (setq entries 
                    (append entries
                        (mapcar 'reftex-parse-bibitem
                        (delete ""
!                               (split-string 
                                 (buffer-substring-no-properties start end)
                                 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
            (goto-char end)))))
--- 356,376 ----
        (save-restriction
          (widen)
          (goto-char (point-min))
!         (while (re-search-forward
                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
            (beginning-of-line 2)
            (setq start (point))
!           (if (re-search-forward
                 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
                (progn
                  (beginning-of-line 1)
                  (setq end (point))))
            (when (and start end)
!             (setq entries
                    (append entries
                        (mapcar 'reftex-parse-bibitem
                        (delete ""
!                               (split-string
                                 (buffer-substring-no-properties start end)
                                 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
            (goto-char end)))))
***************
*** 379,394 ****
  
      ;; Read a regexp, completing on known citation keys.
      (setq default (regexp-quote (reftex-get-bibkey-default)))
!     (setq re-list 
!         (split-string 
!          (completing-read 
            (concat
             "Regex { && Regex...}: "
             "[" default "]: ")
            (if reftex-mode
                (if (fboundp 'LaTeX-bibitem-list)
                    (LaTeX-bibitem-list)
!                 (cdr (assoc 'bibview-cache 
                              (symbol-value reftex-docstruct-symbol))))
              nil)
            nil nil nil 'reftex-cite-regexp-hist)
--- 379,394 ----
  
      ;; Read a regexp, completing on known citation keys.
      (setq default (regexp-quote (reftex-get-bibkey-default)))
!     (setq re-list
!         (split-string
!          (completing-read
            (concat
             "Regex { && Regex...}: "
             "[" default "]: ")
            (if reftex-mode
                (if (fboundp 'LaTeX-bibitem-list)
                    (LaTeX-bibitem-list)
!                 (cdr (assoc 'bibview-cache
                              (symbol-value reftex-docstruct-symbol))))
              nil)
            nil nil nil 'reftex-cite-regexp-hist)
***************
*** 401,414 ****
          (error "Empty regular expression"))
  
      (while (and (setq re (pop re-list)) entries)
!       (setq entries 
            (delq nil (mapcar
                       (lambda (x)
                         (if (string-match re (cdr (assoc "&entry" x)))
                             x nil))
                       entries))))
!     (setq entries 
!         (mapcar 
            (lambda (x)
              (push (cons "&formatted" (reftex-format-bibitem x)) x)
              (push (reftex-get-bib-field "&key" x) x)
--- 401,414 ----
          (error "Empty regular expression"))
  
      (while (and (setq re (pop re-list)) entries)
!       (setq entries
            (delq nil (mapcar
                       (lambda (x)
                         (if (string-match re (cdr (assoc "&entry" x)))
                             x nil))
                       entries))))
!     (setq entries
!         (mapcar
            (lambda (x)
              (push (cons "&formatted" (reftex-format-bibitem x)) x)
              (push (reftex-get-bib-field "&key" x) x)
***************
*** 647,655 ****
        ;; All keys go into a single command - we need to trick a little
        (pop selected-entries)
        (let ((concat-keys (mapconcat 'car selected-entries ",")))
!       (setq insert-entries 
              (list (list concat-keys (cons "&key" concat-keys))))))
!     
      (unless no-insert
  
        ;; We shall insert this into the buffer...
--- 647,655 ----
        ;; All keys go into a single command - we need to trick a little
        (pop selected-entries)
        (let ((concat-keys (mapconcat 'car selected-entries ",")))
!       (setq insert-entries
              (list (list concat-keys (cons "&key" concat-keys))))))
! 
      (unless no-insert
  
        ;; We shall insert this into the buffer...
***************
*** 670,683 ****
        (delete-char 1))
  
        ;; Tell AUCTeX
!       (when (and reftex-mode 
                 (fboundp 'LaTeX-add-bibitems)
                 reftex-plug-into-AUCTeX)
        (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
!       
        ;; Produce the cite-view strings
        (when (and reftex-mode reftex-cache-cite-echo cite-view)
!       (mapcar (lambda (entry) 
                  (reftex-make-cite-echo-string entry docstruct-symbol))
                selected-entries))
  
--- 670,683 ----
        (delete-char 1))
  
        ;; Tell AUCTeX
!       (when (and reftex-mode
                 (fboundp 'LaTeX-add-bibitems)
                 reftex-plug-into-AUCTeX)
        (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
! 
        ;; Produce the cite-view strings
        (when (and reftex-mode reftex-cache-cite-echo cite-view)
!       (mapcar (lambda (entry)
                  (reftex-make-cite-echo-string entry docstruct-symbol))
                selected-entries))
  
***************
*** 685,700 ****
  
      (set-marker reftex-select-return-marker nil)
      (reftex-kill-buffer "*RefTeX Select*")
!     
      ;; Check if the prefix arg was numeric, and call recursively
      (when (integerp arg)
        (if (> arg 1)
!         (progn      
            (skip-chars-backward "}")
            (decf arg)
            (reftex-do-citation arg))
        (forward-char 1)))
!     
      ;; Return the citation key
      (car (car selected-entries))))
  
--- 685,700 ----
  
      (set-marker reftex-select-return-marker nil)
      (reftex-kill-buffer "*RefTeX Select*")
! 
      ;; Check if the prefix arg was numeric, and call recursively
      (when (integerp arg)
        (if (> arg 1)
!         (progn
            (skip-chars-backward "}")
            (decf arg)
            (reftex-do-citation arg))
        (forward-char 1)))
! 
      ;; Return the citation key
      (car (car selected-entries))))
  
***************
*** 708,714 ****
       (no-insert
        ;; Format does not really matter because nothing will be inserted.
        (setq format "%l"))
!      
       ((and (stringp macro)
           (string-match "\\`\\\\cite\\|cite\\'" macro))
        ;; We are already inside a cite macro
--- 708,714 ----
       (no-insert
        ;; Format does not really matter because nothing will be inserted.
        (setq format "%l"))
! 
       ((and (stringp macro)
           (string-match "\\`\\\\cite\\|cite\\'" macro))
        ;; We are already inside a cite macro
***************
*** 729,735 ****
        (when (listp format)
        (setq key
              (or format-key
!                 (reftex-select-with-char 
                   "" (concat "SELECT A CITATION FORMAT\n\n"
                              (mapconcat
                               (lambda (x)
--- 729,735 ----
        (when (listp format)
        (setq key
              (or format-key
!                 (reftex-select-with-char
                   "" (concat "SELECT A CITATION FORMAT\n\n"
                              (mapconcat
                               (lambda (x)
***************
*** 758,765 ****
  
    (let ((bibtype (reftex-bib-or-thebib))
        found-list rtn key data selected-entries)
!     (while 
!       (not 
         (catch 'done
           ;; Scan bibtex files
           (setq found-list
--- 758,765 ----
  
    (let ((bibtype (reftex-bib-or-thebib))
        found-list rtn key data selected-entries)
!     (while
!       (not
         (catch 'done
           ;; Scan bibtex files
           (setq found-list
***************
*** 774,793 ****
                (reftex-extract-bib-entries-from-thebibliography
                 (reftex-uniquify
                  (mapcar 'cdr
!                         (reftex-all-assq 
                           'thebib (symbol-value reftex-docstruct-symbol))))))
               (reftex-default-bibliography
                (message "Using default bibliography")
                (reftex-extract-bib-entries (reftex-default-bibliography)))
               (t (error "No valid bibliography in this document, and no 
default available"))))
!          
           (unless found-list
             (error "Sorry, no matches found"))
!     
          ;; Remember where we came from
          (setq reftex-call-back-to-this-buffer (current-buffer))
          (set-marker reftex-select-return-marker (point))
!     
          ;; Offer selection
          (save-window-excursion
            (delete-other-windows)
--- 774,793 ----
                (reftex-extract-bib-entries-from-thebibliography
                 (reftex-uniquify
                  (mapcar 'cdr
!                         (reftex-all-assq
                           'thebib (symbol-value reftex-docstruct-symbol))))))
               (reftex-default-bibliography
                (message "Using default bibliography")
                (reftex-extract-bib-entries (reftex-default-bibliography)))
               (t (error "No valid bibliography in this document, and no 
default available"))))
! 
           (unless found-list
             (error "Sorry, no matches found"))
! 
          ;; Remember where we came from
          (setq reftex-call-back-to-this-buffer (current-buffer))
          (set-marker reftex-select-return-marker (point))
! 
          ;; Offer selection
          (save-window-excursion
            (delete-other-windows)
***************
*** 828,842 ****
                (goto-char 1))
               ((eq key ?A)
                ;; Take all (marked)
!               (setq selected-entries 
                      (if reftex-select-marked
                          (mapcar 'car (nreverse reftex-select-marked))
                        found-list))
                (throw 'done t))
               ((eq key ?a)
                ;; Take all (marked), and push the symbol 'concat
!               (setq selected-entries 
!                     (cons 'concat 
                            (if reftex-select-marked
                                (mapcar 'car (nreverse reftex-select-marked))
                              found-list)))
--- 828,842 ----
                (goto-char 1))
               ((eq key ?A)
                ;; Take all (marked)
!               (setq selected-entries
                      (if reftex-select-marked
                          (mapcar 'car (nreverse reftex-select-marked))
                        found-list))
                (throw 'done t))
               ((eq key ?a)
                ;; Take all (marked), and push the symbol 'concat
!               (setq selected-entries
!                     (cons 'concat
                            (if reftex-select-marked
                                (mapcar 'car (nreverse reftex-select-marked))
                              found-list)))
***************
*** 844,852 ****
               ((or (eq key ?\C-m)
                    (eq key 'return))
                ;; Take selected
!               (setq selected-entries 
                      (if reftex-select-marked
!                         (cons 'concat 
                                (mapcar 'car (nreverse reftex-select-marked)))
                        (if data (list data) nil)))
                (throw 'done t))
--- 844,852 ----
               ((or (eq key ?\C-m)
                    (eq key 'return))
                ;; Take selected
!               (setq selected-entries
                      (if reftex-select-marked
!                         (cons 'concat
                                (mapcar 'car (nreverse reftex-select-marked)))
                        (if data (list data) nil)))
                (throw 'done t))
***************
*** 888,894 ****
             reftex-mouse-selected-face
           nil))
        tmp len)
!     (mapcar 
       (lambda (x)
         (setq tmp (cdr (assoc "&formatted" x))
             len (length tmp))
--- 888,894 ----
             reftex-mouse-selected-face
           nil))
        tmp len)
!     (mapcar
       (lambda (x)
         (setq tmp (cdr (assoc "&formatted" x))
             len (length tmp))
***************
*** 983,989 ****
  (defun reftex-make-cite-echo-string (entry docstruct-symbol)
    ;; Format a bibtex entry for the echo area and cache the result.
    (let* ((key (reftex-get-bib-field "&key" entry))
!        (string 
          (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
            (reftex-format-citation entry reftex-cite-view-format)))
         (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
--- 983,989 ----
  (defun reftex-make-cite-echo-string (entry docstruct-symbol)
    ;; Format a bibtex entry for the echo area and cache the result.
    (let* ((key (reftex-get-bib-field "&key" entry))
!        (string
          (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
            (reftex-format-citation entry reftex-cite-view-format)))
         (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
***************
*** 1025,1031 ****
          (setq bibfile-list
                (reftex-uniquify
                 (mapcar 'cdr
!                        (reftex-all-assq 
                          'thebib (symbol-value reftex-docstruct-symbol))))
                item t))
         (reftex-default-bibliography
--- 1025,1031 ----
          (setq bibfile-list
                (reftex-uniquify
                 (mapcar 'cdr
!                        (reftex-all-assq
                          'thebib (symbol-value reftex-docstruct-symbol))))
                item t))
         (reftex-default-bibliography
***************
*** 1036,1045 ****
        (setq bibfile-list (reftex-visited-files bibfile-list)))
  
        (condition-case nil
!         (reftex-pop-to-bibtex-entry 
           key bibfile-list (not reftex-keep-temporary-buffers) t item)
        (error (ding))))
!       
      (select-window win)))
  
  ;;; reftex-cite.el ends here
--- 1036,1045 ----
        (setq bibfile-list (reftex-visited-files bibfile-list)))
  
        (condition-case nil
!         (reftex-pop-to-bibtex-entry
           key bibfile-list (not reftex-keep-temporary-buffers) t item)
        (error (ding))))
! 
      (select-window win)))
  
  ;;; reftex-cite.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]