diff options
author | Carsten Dominik <dominik@science.uva.nl> | 2005-01-14 10:12:03 +0000 |
---|---|---|
committer | Carsten Dominik <dominik@science.uva.nl> | 2005-01-14 10:12:03 +0000 |
commit | f3c18bd097dfc12ce31e3002c1b1743ffa811f1f (patch) | |
tree | d9f2e551aa1182ec885d5143784ecf3c73ae92c1 /lisp/textmodes/reftex-ref.el | |
parent | 1b1c49e1b3d20b1f4222cdd22371cc1b235fa7d8 (diff) | |
download | emacs-f3c18bd097dfc12ce31e3002c1b1743ffa811f1f.tar.gz |
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
* reftex-cite.el (reftex-bib-sort-year): Catch the case if the
year is not given.
* reftex-ref.el (reftex-replace-prefix-escapes): Added new escapes
%m and %M, fixed bug with %F by adding save-match-data.
(reftex-reference): Removed ?. from list of spaces.
(reftex-label-info): Added automatic label prefix recognition
* reftex-index.el (reftex-index-next-phrase): Added slave
parameter to call of `reftex-index-this-phrase'
(reftex-index-this-phrase): New optional argument
(reftex-index-region-phrases): Added slave parameter to call of
`reftex-index-this-phrase'
(reftex-display-index): New argument redo
(reftex-index-rescan): Added 'redo to arguments of
`reftex-display-index'
(reftex-index-Rescan, reftex-index-revert)
(reftex-index-switch-index-tag): Added 'redo to arguments of
`reftex-display-index'
(reftex-index-make-phrase-regexp): Fixed bug with case-sensitive
indexing. Fixed bug with matching is there is a quote before or
after the word.
* reftex-cite.el (reftex-all-used-citation-keys): Fix bug when
collecting citation keys in lines with comments.
(reftex-citation): Prefix argument no longer rescans the document,
but forces prompting for optional arguments of cite macros.
(reftex-do-citation): Prompting for optional arguments
implemented.
* reftex-vars.el (reftex-cite-format-builtin): Added optional
arguments to most cite commands.
(reftex-cite-cleanup-optional-args): New option
(reftex-cite-prompt-optional-args): New option.
(reftex-trust-label-prefix): New option
* reftex-toc.el (reftex-toc-find-section): Added push-mark before
changing the position in the buffer.
* reftex.el (reftex-prefix-to-typekey-alist): New variable
(reftex-compile-variables): Compute reftex-prefix-to-typekey-alist
Diffstat (limited to 'lisp/textmodes/reftex-ref.el')
-rw-r--r-- | lisp/textmodes/reftex-ref.el | 97 |
1 files changed, 59 insertions, 38 deletions
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el index 2d4935aedde..43095e2d684 100644 --- a/lisp/textmodes/reftex-ref.el +++ b/lisp/textmodes/reftex-ref.el @@ -1,8 +1,8 @@ ;;; reftex-ref.el --- code to create labels and references with RefTeX -;; Copyright (c) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. +;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004 Free Software Foundation, Inc. ;; Author: Carsten Dominik <dominik@science.uva.nl> -;; Version: 4.21 +;; Version: 4.26 ;; This file is part of GNU Emacs. @@ -96,14 +96,27 @@ If optional BOUND is an integer, limit backward searches to that point." (defun reftex-label-info (label &optional file bound derive env-or-mac) ;; Return info list on LABEL at point. - (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) - (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) + (let* ((prefix (if (string-match "^[a-zA-Z0-9]+:" label) + (match-string 0 label))) + (typekey (cdr (assoc prefix reftex-prefix-to-typekey-alist))) (file (or file (buffer-file-name))) - (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist))) - (text (reftex-short-context env-or-mac parse reftex-location-start - derive)) + (trust reftex-trust-label-prefix) (in-comment (reftex-in-comment))) - (list label typekey text file in-comment))) + (if (and typekey + (cond ((eq trust t) t) + ((null trust) nil) + ((stringp trust) (string-match trust typekey)) + ((listp trust) (member typekey trust)) + (t nil))) + (list label typekey + (reftex-nicify-text (reftex-context-substring)) + file in-comment) + (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) + (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) + (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist))) + (text (reftex-short-context env-or-mac parse reftex-location-start + derive))) + (list label typekey text file in-comment))))) ;;; Creating labels --------------------------------------------------------- @@ -296,35 +309,43 @@ also applies `reftex-translate-to-ascii-function' to the string." (while (string-match "\\%\\([a-zA-Z]\\)" prefix num) (setq letter (match-string 1 prefix)) (setq replace - (cond - ((equal letter "f") - (file-name-sans-extension - (file-name-nondirectory (buffer-file-name)))) - ((equal letter "F") - (let ((masterdir (file-name-directory (reftex-TeX-master-file))) - (file (file-name-sans-extension (buffer-file-name)))) - (if (string-match (concat "\\`" (regexp-quote masterdir)) - file) - (substring file (length masterdir)) - file))) - ((equal letter "u") - (or (user-login-name) "")) - ((equal letter "S") - (let* (macro level-exp level) - (save-excursion - (save-match-data - (when (re-search-backward reftex-section-regexp nil t) - (setq macro (reftex-match-string 2) - level-exp (cdr (assoc macro reftex-section-levels-all)) - level (if (symbolp level-exp) - (abs (save-match-data - (funcall level-exp))) - (abs level-exp)))) - (cdr (or (assoc macro reftex-section-prefixes) - (assoc level reftex-section-prefixes) - (assq t reftex-section-prefixes) - (list t "sec:"))))))) - (t ""))) + (save-match-data + (cond + ((equal letter "f") + (file-name-sans-extension + (file-name-nondirectory (buffer-file-name)))) + ((equal letter "F") + (let ((masterdir (file-name-directory (reftex-TeX-master-file))) + (file (file-name-sans-extension (buffer-file-name)))) + (if (string-match (concat "\\`" (regexp-quote masterdir)) + file) + (substring file (length masterdir)) + file))) + ((equal letter "m") + (file-name-sans-extension + (file-name-nondirectory (reftex-TeX-master-file)))) + ((equal letter "M") + (file-name-nondirectory + (substring (file-name-directory (reftex-TeX-master-file)) + 0 -1))) + ((equal letter "u") + (or (user-login-name) "")) + ((equal letter "S") + (let* (macro level-exp level) + (save-excursion + (save-match-data + (when (re-search-backward reftex-section-regexp nil t) + (setq macro (reftex-match-string 2) + level-exp (cdr (assoc macro reftex-section-levels-all)) + level (if (symbolp level-exp) + (abs (save-match-data + (funcall level-exp))) + (abs level-exp)))) + (cdr (or (assoc macro reftex-section-prefixes) + (assoc level reftex-section-prefixes) + (assq t reftex-section-prefixes) + (list t "sec:"))))))) + (t "")))) (setq num (1- (+ (match-beginning 1) (length replace))) prefix (replace-match replace nil nil prefix))) prefix))) @@ -449,7 +470,7 @@ When called with 2 C-u prefix args, disable magic word recognition." ;; remove ~ if we do already have a space (when (and (= ?~ (string-to-char form)) - (member (preceding-char) '(?\ ?\t ?\n ?. ?~))) + (member (preceding-char) '(?\ ?\t ?\n ?~))) (setq form (substring form 1))) ;; do we have a special format? (setq reftex-format-ref-function |