comparison lisp/textmodes/reftex-cite.el @ 26910:489a5439b988

* reftex.el (reftex-compile-variables): respect new structure of `reftex-index-macro' (reftex-compile-variables): Use the changed structure of `reftex-label-alist'. * reftex-vars.el (reftex-index-math-format, (reftex-toc-max-level): New option. reftex-index-phrases-search-whole-words, reftex-index-phrases-case-fold-search, reftex-index-phrases-skip-indexed-matches, reftex-index-phrases-wrap-long-lines, reftex-index-phrases-sort-prefers-entry, reftex-index-phrases-sort-in-blocks): New options. (reftex-index-macros): Option structure changed. (reftex-index-macros-builtin): Added `repeat' item to each entry. (reftex-label-alist): Additional item in each entry to specify if the environment should be listed in the TOC. (eval-when-compile (require 'cl)) added. * reftex-index.el (reftex-index-selection-or-word): No longer deals with "repeat". (reftex-index): "repeat property in `reftex-index-macro-alist' is now used. (reftex-index-phrases-comment-regexp, reftex-index-phrases-macrodef-regexp, reftex-index-phrases-phrase-regexp1, reftex-index-phrases-phrase-regexp2, reftex-index-phrases-phrase-regexp12, reftex-index-phrases-help): New constants. (reftex-index-phrases-macro-data, reftex-index-phrases-files, reftex-index-phrases-font-lock-keywords, reftex-index-phrases-font-lock-defaults, reftex-index-phrases-map, reftex-index-phrases-restrict-file): New variables. (reftex-index-phrase-selection-or-word, reftex-index-visit-phrases-buffer, reftex-index-initialize-phrases-buffer, reftex-index-phrases-save-and-return, reftex-index-phrases-mode, reftex-index-next-phrase, reftex-index-this-phrase, reftex-index-all-phrases, reftex-index-region-phrases, reftex-index-phrases-parse-header, reftex-index-phrases-toggle-restricted, reftex-index-new-phrase, reftex-index-find-next-conflict-phrase, reftex-index-phrases-info, reftex-index-phrases-set-macro-key, reftex-index-sort-phrases, reftex-compare-phrase-lines, reftex-index-make-phrase-regexp, reftex-index-simplify-phrase, reftex-index-phrases-find-dup-re, reftex-index-make-replace-string, reftex-query-index-phrase-globally, reftex-query-index-phrase, reftex-index-phrase-match-is-indexed, reftex-index-phrases-fixup-line, reftex-index-phrases-replace-space, reftex-index-select-phrases-macro): New functions. (reftex-index-globalize, reftex-index-globally): functions removed (eval-when-compile (require 'cl)) added. * reftex-toc.el (reftex-toc-mode): Create new indicator for max level. (reftex-toc-max-level-indicator): New variable. (reftex-toc-max-level): New command. (reftex-toc-map): New keybinding `t'. (reftex-toc-help): Constant updated. (eval-when-compile (require 'cl)) added. * reftex-ref.el (reftex-offer-label-menu): Prefix to `t' command key can change `reftex-toc-max-level' (eval-when-compile (require 'cl)) added. * reftex-sel (reftex-insert-docstruct): Respect `reftex-toc-max-level' (eval-when-compile (require 'cl)) added. * reftex-auc.el (eval-when-compile (require 'cl)) added. * reftex-vcr.el (eval-when-compile (require 'cl)) added. * reftex-cite.el (reftex-citep, reftex-citet): New commands. (reftex-citation, reftex-do-citation, reftex-figure-out-cite-format): Additional argument FORMAT-KEY to preselect a citation format. (eval-when-compile (require 'cl)) added. * reftex-parse.el (reftex-context-substring): Optional parameter to-end (reftex-section-info): Deal with environment matches. (eval-when-compile (require 'cl)) added. * reftex-global.el (eval-when-compile (require 'cl)) added.
author Carsten Dominik <dominik@science.uva.nl>
date Wed, 15 Dec 1999 17:02:38 +0000
parents 7ed67319c5aa
children 083669ed376a
comparison
equal deleted inserted replaced
26909:5a2ef05e2490 26910:489a5439b988
1 ;;; reftex-cite.el - Creating citations with RefTeX 1 ;;; reftex-cite.el - Creating citations with RefTeX
2 ;;; Version: 4.6 2 ;;; Version: 4.9
3 ;;; 3 ;;;
4 ;;; See main file reftex.el for licensing information 4 ;;; See main file reftex.el for licensing information
5 5
6 (eval-when-compile (require 'cl))
6 (provide 'reftex-cite) 7 (provide 'reftex-cite)
7 (require 'reftex) 8 (require 'reftex)
8 ;;; 9 ;;;
9 10
10 ;; Variables and constants 11 ;; Variables and constants
499 (concat key "\n " text "\n\n"))) 500 (concat key "\n " text "\n\n")))
500 501
501 ;; Make a citation 502 ;; Make a citation
502 503
503 ;;;###autoload 504 ;;;###autoload
504 (defun reftex-citation (&optional no-insert) 505 (defun reftex-citation (&optional no-insert format-key)
505 "Make a citation using BibTeX database files. 506 "Make a citation using BibTeX database files.
506 After prompting for a regular expression, scans the buffers with 507 After prompting for a regular expression, scans the buffers with
507 bibtex entries (taken from the \\bibliography command) and offers the 508 bibtex entries (taken from the \\bibliography command) and offers the
508 matching entries for selection. The selected entry is formated according 509 matching entries for selection. The selected entry is formated according
509 to `reftex-cite-format' and inserted into the buffer. 510 to `reftex-cite-format' and inserted into the buffer.
510 511
511 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. 512 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
512 513
514 FORAT-KEY can be used to pre-select a citation format.
515
513 When called with one or two `C-u' prefixes, first rescans the document. 516 When called with one or two `C-u' prefixes, first rescans the document.
514 When called with a numeric prefix, make that many citations. When 517 When called with a numeric prefix, make that many citations. When
515 called with point inside the braces of a `\cite' command, it will 518 called with point inside the braces of a `\cite' command, it will
516 add another key, ignoring the value of `reftex-cite-format'. 519 add another key, ignoring the value of `reftex-cite-format'.
517 520
531 (when reftex-mode 534 (when reftex-mode
532 (reftex-access-scan-info current-prefix-arg)) 535 (reftex-access-scan-info current-prefix-arg))
533 536
534 ;; Call reftex-do-citation, but protected 537 ;; Call reftex-do-citation, but protected
535 (unwind-protect 538 (unwind-protect
536 (reftex-do-citation current-prefix-arg no-insert) 539 (reftex-do-citation current-prefix-arg no-insert format-key)
537 (reftex-kill-temporary-buffers))) 540 (reftex-kill-temporary-buffers)))
538 541
539 (defun reftex-do-citation (&optional arg no-insert) 542 (defun reftex-do-citation (&optional arg no-insert format-key)
540 ;; This really does the work of reftex-citation. 543 ;; This really does the work of reftex-citation.
541 544
542 (let* ((format (reftex-figure-out-cite-format arg no-insert)) 545 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key))
543 (docstruct-symbol reftex-docstruct-symbol) 546 (docstruct-symbol reftex-docstruct-symbol)
544 (selected-entries (reftex-offer-bib-menu)) 547 (selected-entries (reftex-offer-bib-menu))
545 (insert-entries selected-entries) 548 (insert-entries selected-entries)
546 entry string cite-view) 549 entry string cite-view)
547 550
608 (forward-char 1))) 611 (forward-char 1)))
609 612
610 ;; Return the citation key 613 ;; Return the citation key
611 (car (car selected-entries)))) 614 (car (car selected-entries))))
612 615
613 (defun reftex-figure-out-cite-format (arg no-insert) 616 (defun reftex-figure-out-cite-format (arg &optional no-insert format-key)
614 ;; Check if there is already a cite command at point and change cite format 617 ;; Check if there is already a cite command at point and change cite format
615 ;; in order to only add another reference in the same cite command. 618 ;; in order to only add another reference in the same cite command.
616 (let ((macro (car (reftex-what-macro 1))) 619 (let ((macro (car (reftex-what-macro 1)))
617 (cite-format-value (reftex-get-cite-format)) 620 (cite-format-value (reftex-get-cite-format))
618 key format) 621 key format)
638 (assq cite-format-value reftex-cite-format-builtin)) 641 (assq cite-format-value reftex-cite-format-builtin))
639 (nth 2 (assq cite-format-value reftex-cite-format-builtin)) 642 (nth 2 (assq cite-format-value reftex-cite-format-builtin))
640 cite-format-value)) 643 cite-format-value))
641 (when (listp format) 644 (when (listp format)
642 (setq key 645 (setq key
643 (reftex-select-with-char 646 (or format-key
644 "" (concat "SELECT A CITATION FORMAT\n\n" 647 (reftex-select-with-char
645 (mapconcat 648 "" (concat "SELECT A CITATION FORMAT\n\n"
646 (lambda (x) 649 (mapconcat
647 (format "[%c] %s %s" (car x) 650 (lambda (x)
648 (if (> (car x) 31) " " "") 651 (format "[%c] %s %s" (car x)
649 (cdr x))) 652 (if (> (car x) 31) " " "")
650 format "\n")))) 653 (cdr x)))
654 format "\n")))))
651 (if (assq key format) 655 (if (assq key format)
652 (setq format (cdr (assq key format))) 656 (setq format (cdr (assq key format)))
653 (error "No citation format associated with key `%c'" key))))) 657 (error "No citation format associated with key `%c'" key)))))
654 format)) 658 format))
659
660 (defun reftex-citep ()
661 "Call `reftex-citation' with a format selector `?p'."
662 (interactive)
663 (reftex-citation nil ?p))
664
665 (defun reftex-citet ()
666 "Call `reftex-citation' with a format selector `?t'."
667 (interactive)
668 (reftex-citation nil ?t))
655 669
656 (defvar reftex-select-bib-map) 670 (defvar reftex-select-bib-map)
657 (defun reftex-offer-bib-menu () 671 (defun reftex-offer-bib-menu ()
658 ;; Offer bib menu and return list of selected items 672 ;; Offer bib menu and return list of selected items
659 673