/[emacs]/emacs/lisp/textmodes/bibtex.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/bibtex.el

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

revision 1.84 by monnier, Fri Sep 10 21:24:49 2004 UTC revision 1.85 by monnier, Sun Sep 12 19:52:15 2004 UTC
# Line 1  Line 1 
1  ;;; bibtex.el --- BibTeX mode for GNU Emacs  ;;; bibtex.el --- BibTeX mode for GNU Emacs
2    
3  ;; Copyright (C) 1992,94,95,96,97,98,1999,2003,2004  ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2004
4  ;;           Free Software Foundation, Inc.  ;;           Free Software Foundation, Inc.
5    
6  ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>  ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
# Line 61  Line 61 
61    :type 'hook)    :type 'hook)
62    
63  (defcustom bibtex-field-delimiters 'braces  (defcustom bibtex-field-delimiters 'braces
64    "*Type of field delimiters. Allowed values are `braces' or `double-quotes'."    "*Type of field delimiters.  Allowed values are `braces' or `double-quotes'."
65    :group 'bibtex    :group 'bibtex
66    :type '(choice (const braces)    :type '(choice (const braces)
67                   (const double-quotes)))                   (const double-quotes)))
68    
69  (defcustom bibtex-entry-delimiters 'braces  (defcustom bibtex-entry-delimiters 'braces
70    "*Type of entry delimiters. Allowed values are `braces' or `parentheses'."    "*Type of entry delimiters.  Allowed values are `braces' or `parentheses'."
71    :group 'bibtex    :group 'bibtex
72    :type '(choice (const braces)    :type '(choice (const braces)
73                   (const parentheses)))                   (const parentheses)))
# Line 154  narrowed to just the entry." Line 154  narrowed to just the entry."
154  Allowed non-nil values are:  Allowed non-nil values are:
155  plain        All entries are sorted alphabetically.  plain        All entries are sorted alphabetically.
156  crossref     All entries are sorted alphabetically unless an entry has a  crossref     All entries are sorted alphabetically unless an entry has a
157               crossref field. These crossrefed entries are placed in               crossref field.  These crossrefed entries are placed in
158               alphabetical order immediately preceding the main entry.               alphabetical order immediately preceding the main entry.
159  entry-class  The entries are divided into classes according to their  entry-class  The entries are divided into classes according to their
160               entry name, see `bibtex-sort-entry-class'. Within each class               entry name, see `bibtex-sort-entry-class'.  Within each class
161               the entries are sorted alphabetically.               the entries are sorted alphabetically.
162  See also `bibtex-sort-ignore-string-entries'."  See also `bibtex-sort-ignore-string-entries'."
163    :group 'bibtex    :group 'bibtex
# Line 172  See also `bibtex-sort-ignore-string-entr Line 172  See also `bibtex-sort-ignore-string-entr
172      ("Book" "Proceedings"))      ("Book" "Proceedings"))
173    "*List of classes of BibTeX entry names, used for sorting entries.    "*List of classes of BibTeX entry names, used for sorting entries.
174  If value of `bibtex-maintain-sorted-entries' is `entry-class'  If value of `bibtex-maintain-sorted-entries' is `entry-class'
175  entries are ordered according to the classes they belong to. Each  entries are ordered according to the classes they belong to.  Each
176  class contains a list of entry names. An entry `catch-all' applies  class contains a list of entry names.  An entry `catch-all' applies
177  to all entries not explicitely mentioned.")  to all entries not explicitely mentioned.")
178    
179  (defcustom bibtex-sort-ignore-string-entries t  (defcustom bibtex-sort-ignore-string-entries t
# Line 763  If non-nil, the column for the equal sig Line 763  If non-nil, the column for the equal sig
763    :type '(repeat string))    :type '(repeat string))
764    
765  (defcustom bibtex-generate-url-list  (defcustom bibtex-generate-url-list
766    '((("url" . t) ("url" t)))    '((("url" . ".*:.*"))
767        ;; Example of a complex setup.
768        (("journal" . "\\<\\(PR[ABCDEL]?\\|RMP\\)\\>")
769         "http://publish.aps.org/abstract/"
770         ("journal" ".*" downcase)
771         "/v"
772         ("volume" ".*" 0)
773         "/p"
774         ("pages" "\\`\\([0-9]+\\)" 1)))
775    "List of schemes for generating the URL of a BibTeX entry.    "List of schemes for generating the URL of a BibTeX entry.
776  These schemes are used by `bibtex-url'.  These schemes are used by `bibtex-url'.
777    
778  Each scheme is of the form ((FIELD . REGEXP) STEPS).  Each scheme is of the form ((FIELD . REGEXP) STEP...).
779    
780  FIELD is a field name as returned by `bibtex-parse-entry'.  FIELD is a field name as returned by `bibtex-parse-entry'.
781  REGEXP is matched against the text of FIELD.  REGEXP is matched against the text of FIELD.  If the match succeed, then
782  If the match succeeds, the list STEPS is used to generate the URL.  this scheme will be used.  If no STEPS are specified the matched text is used
783  If REGEXP is t, always generate the URL if FIELD is present.  as the URL, otherwise the URL is built by concatenating the STEPS.
784    
785  If an element of STEPS is a list (FIELD MATCH FILTER),  A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case
786  the text of FIELD is matched against MATCH.  the text of FIELD is matched against REGEXP, and is replaced with REPLACE.
787  If MATCH is t, the text of FIELD is accepted as is.  REPLACE can be a string, or a number (which selects the corresponding submatch)
788  If MATCH is a cons cell (REGEXP . REPLACE), the text is matched against REGEXP.  or a function called with the field's text as argument and with the
789  If REPLACE is a string, the text is replaced with REPLACE. If REPLACE is a  `match-data' properly set.
 number, it specifies which parenthesized expression in the match is taken.  
 The optional element FILTER is a function for piping the match through it.  
 The text strings are then concatenated to generate the URL.  
790    
791  If an element of STEPS is a string, it is simply added to the URL.  Case is always ignored.  Always remove the field delimiters."
   
 Case is always ignored. Always remove the field delimiters."  
792    :group 'bibtex    :group 'bibtex
793    :type '(repeat    :type '(repeat
794            (list :tag "Scheme"            (list :tag "Scheme"
795                  (cons :tag "Matcher" :extra-offset 4                  (cons :tag "Matcher" :extra-offset 4
796                        (string :tag "BibTeX field")                        (string :tag "BibTeX field")
797                        (choice (regexp :tag "Regexp")                        (regexp :tag "Regexp"))
                               (const :tag "Accept as is" t)))  
798                  (repeat :tag "Steps to generate URL" :inline t                  (repeat :tag "Steps to generate URL" :inline t
799                          (choice                          (choice
800                           (string :tag "Literal text")                           (string :tag "Literal text")
801                           (list (string :tag "BibTeX field")                           (list (string :tag "BibTeX field")
802                                 (choice (const :tag "Accept as is" t)                                 (regexp :tag "Regexp")
803                                         (cons (string :tag "Field")                                 (choice (string :tag "Replacement")
804                                               (choice (regexp :tag "Regexp")                                         (integer :tag "Sub-match")
805                                                       (integer :tag "Matched parenthesis"))))                                         (function :tag "Filter"))))))))
                                (option (function :tag "Filter" :value ignore))))))))  
806    
807  ;; bibtex-font-lock-keywords is a user option as well, but since the  ;; bibtex-font-lock-keywords is a user option as well, but since the
808  ;; patterns used to define this variable are defined in a later  ;; patterns used to define this variable are defined in a later
# Line 1000  Initialized from `bibtex-predefined-stri Line 1001  Initialized from `bibtex-predefined-stri
1001  (make-variable-buffer-local 'bibtex-reference-keys)  (make-variable-buffer-local 'bibtex-reference-keys)
1002    
1003  (defvar bibtex-buffer-last-parsed-tick nil  (defvar bibtex-buffer-last-parsed-tick nil
1004    "Last value returned by `buffer-modified-tick' when buffer    "Value of `buffer-modified-tick' last time buffer was parsed for keys.")
 was parsed for keys the last time.")  
1005    
1006  (defvar bibtex-parse-idle-timer nil  (defvar bibtex-parse-idle-timer nil
1007    "Stores if timer is already installed.")    "Stores if timer is already installed.")
# Line 1103  was parsed for keys the last time.") Line 1103  was parsed for keys the last time.")
1103      (,(concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=")      (,(concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=")
1104       1 font-lock-variable-name-face)       1 font-lock-variable-name-face)
1105      ;; url      ;; url
1106      (bibtex-font-lock-url 0 '(face nil mouse-face highlight      (bibtex-font-lock-url 0 '(face nil mouse-face highlight
1107                                     keymap bibtex-url-map)))                                     keymap bibtex-url-map)))
1108    "*Default expressions to highlight in BibTeX mode.")    "*Default expressions to highlight in BibTeX mode.")
1109    
# Line 1113  was parsed for keys the last time.") Line 1113  was parsed for keys the last time.")
1113    "Regexp for `bibtex-font-lock-url'.")    "Regexp for `bibtex-font-lock-url'.")
1114    
1115  (defvar bibtex-field-name-for-parsing nil  (defvar bibtex-field-name-for-parsing nil
1116    "Temporary variable storing the name string to be parsed by the callback    "Regexp of field name to be parsed by function `bibtex-parse-field-name'.
1117  function `bibtex-parse-field-name'.")  Passed by dynamic scoping.")
1118    
1119  (defvar bibtex-sort-entry-class-alist  (defvar bibtex-sort-entry-class-alist
1120    (let ((i -1) alist)    (let ((i -1) alist)
# Line 1123  function `bibtex-parse-field-name'.") Line 1123  function `bibtex-parse-field-name'.")
1123        (dolist (entry class)        (dolist (entry class)
1124          ;; all entry names should be downcase (for ease of comparison)          ;; all entry names should be downcase (for ease of comparison)
1125          (push (cons (if (stringp entry) (downcase entry) entry) i) alist))))          (push (cons (if (stringp entry) (downcase entry) entry) i) alist))))
1126    "Alist for the classes of the entry types if the value of    "Alist mapping entry types to their sorting index.
1127  `bibtex-maintain-sorted-entries' is `entry-class'.")  Auto-generated from `bibtex-sort-entry-class'.
1128    Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
1129    
1130    
1131  ;; Special support taking care of variants  ;; Special support taking care of variants
# Line 1149  function `bibtex-parse-field-name'.") Line 1150  function `bibtex-parse-field-name'.")
1150    
1151  ;; Support for hideshow minor mode  ;; Support for hideshow minor mode
1152  (defun bibtex-hs-forward-sexp (arg)  (defun bibtex-hs-forward-sexp (arg)
1153    "Replacement for `forward-sexp' to be used by `hs-minor-mode'."    "Replacement for `forward-sexp' to be used by `hs-minor-mode'.
1154    (if (< arg 0)  ARG is ignored."
1155        (backward-sexp 1)    (if (looking-at "@\\S(*\\s(")
1156      (if (looking-at "@\\S(*\\s(")      (goto-char (1- (match-end 0))))
1157          (progn    (forward-sexp 1))
           (goto-char (match-end 0))  
           (forward-char -1)  
           (forward-sexp 1))  
       (forward-sexp 1))))  
1158    
1159  (add-to-list  (add-to-list
1160   'hs-special-modes-alist   'hs-special-modes-alist
# Line 1184  values of the functions PARSE-LHS and PA Line 1181  values of the functions PARSE-LHS and PA
1181    "Parse the field name stored in `bibtex-field-name-for-parsing'.    "Parse the field name stored in `bibtex-field-name-for-parsing'.
1182  If the field name is found, return a triple consisting of the position of the  If the field name is found, return a triple consisting of the position of the
1183  very first character of the match, the actual starting position of the name  very first character of the match, the actual starting position of the name
1184  part and end position of the match. Move point to end of field name.  part and end position of the match.  Move point to end of field name.
1185  If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding  If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding
1186  BibTeX field as necessary."  BibTeX field as necessary."
1187    (cond ((looking-at ",[ \t\n]*")    (cond ((looking-at ",[ \t\n]*")
# Line 1246  end position of the field string is retu Line 1243  end position of the field string is retu
1243  The text part is either a string, or an empty string, or a constant followed  The text part is either a string, or an empty string, or a constant followed
1244  by one or more <# (string|constant)> pairs.  If a syntactically correct text  by one or more <# (string|constant)> pairs.  If a syntactically correct text
1245  is found, a pair containing the start and end position of the text is  is found, a pair containing the start and end position of the text is
1246  returned, nil otherwise. Move point to end of field text."  returned, nil otherwise.  Move point to end of field text."
1247    (let ((starting-point (point))    (let ((starting-point (point))
1248          end-point failure boundaries)          end-point failure boundaries)
1249      (while (not (or end-point failure))      (while (not (or end-point failure))
# Line 1274  the name and text parts of the field is Line 1271  the name and text parts of the field is
1271    "Search forward to find a field of name NAME.    "Search forward to find a field of name NAME.
1272  If a syntactically correct field is found, a pair containing the boundaries of  If a syntactically correct field is found, a pair containing the boundaries of
1273  the name and text parts of the field is returned.  The search is limited by  the name and text parts of the field is returned.  The search is limited by
1274  optional arg BOUND. If BOUND is t the search is limited by the end of the current  optional arg BOUND.  If BOUND is t the search is limited by the end of the
1275  entry. Do not move point."  current entry.  Do not move point."
1276    (save-match-data    (save-match-data
1277      (save-excursion      (save-excursion
1278        (unless (integer-or-marker-p bound)        (unless (integer-or-marker-p bound)
# Line 1301  entry. Do not move point." Line 1298  entry. Do not move point."
1298    "Search backward to find a field of name NAME.    "Search backward to find a field of name NAME.
1299  If a syntactically correct field is found, a pair containing the boundaries of  If a syntactically correct field is found, a pair containing the boundaries of
1300  the name and text parts of the field is returned.  The search is limited by  the name and text parts of the field is returned.  The search is limited by
1301  optional arg BOUND. If BOUND is t the search is limited by the beginning of the  optional arg BOUND.  If BOUND is t the search is limited by the beginning of the
1302  current entry. Do not move point."  current entry.  Do not move point."
1303    (save-match-data    (save-match-data
1304      (save-excursion      (save-excursion
1305        (unless (integer-or-marker-p bound)        (unless (integer-or-marker-p bound)
# Line 1356  if present." Line 1353  if present."
1353        content)))        content)))
1354    
1355  (defun bibtex-text-in-field (field &optional follow-crossref)  (defun bibtex-text-in-field (field &optional follow-crossref)
1356    "Get content of field FIELD of current BibTeX entry. Return nil if not found.    "Get content of field FIELD of current BibTeX entry.  Return nil if not found.
1357  If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."  If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."
1358    (save-excursion    (save-excursion
1359      (save-restriction      (save-restriction
# Line 1396  reference key and the end position of th Line 1393  reference key and the end position of th
1393    "Parse the postfix part of a BibTeX string entry, including the text.    "Parse the postfix part of a BibTeX string entry, including the text.
1394  If the string postfix is found, return a triple consisting of the position of  If the string postfix is found, return a triple consisting of the position of
1395  the actual starting and ending position of the text and the very last  the actual starting and ending position of the text and the very last
1396  character of the string entry. Move point past BibTeX string entry."  character of the string entry.  Move point past BibTeX string entry."
1397    (let* ((case-fold-search t)    (let* ((case-fold-search t)
1398           (bounds (bibtex-parse-field-text)))           (bounds (bibtex-parse-field-text)))
1399      (when bounds      (when bounds
# Line 1418  Move point past BibTeX string entry." Line 1415  Move point past BibTeX string entry."
1415  (defun bibtex-search-forward-string ()  (defun bibtex-search-forward-string ()
1416    "Search forward to find a BibTeX string entry.    "Search forward to find a BibTeX string entry.
1417  If a syntactically correct entry is found, a pair containing the boundaries of  If a syntactically correct entry is found, a pair containing the boundaries of
1418  the reference key and text parts of the string is returned. Do not move point."  the reference key and text parts of the string is returned.  Do not move point."
1419    (save-excursion    (save-excursion
1420      (save-match-data      (save-match-data
1421        (let ((case-fold-search t)        (let ((case-fold-search t)
# Line 1434  the reference key and text parts of the Line 1431  the reference key and text parts of the
1431  (defun bibtex-search-backward-string ()  (defun bibtex-search-backward-string ()
1432    "Search backward to find a BibTeX string entry.    "Search backward to find a BibTeX string entry.
1433  If a syntactically correct entry is found, a pair containing the boundaries of  If a syntactically correct entry is found, a pair containing the boundaries of
1434  the reference key and text parts of the field is returned. Do not move point."  the reference key and text parts of the field is returned.  Do not move point."
1435    (save-excursion    (save-excursion
1436      (save-match-data      (save-match-data
1437        (let ((case-fold-search t)        (let ((case-fold-search t)
# Line 1475  delimiters if present." Line 1472  delimiters if present."
1472                                    (match-end bibtex-type-in-head)))                                    (match-end bibtex-type-in-head)))
1473    
1474  (defun bibtex-key-in-head (&optional empty)  (defun bibtex-key-in-head (&optional empty)
1475    "Extract BibTeX key in head. Return optional arg EMPTY if key is empty."    "Extract BibTeX key in head.  Return optional arg EMPTY if key is empty."
1476    (if (match-beginning bibtex-key-in-head)    (if (match-beginning bibtex-key-in-head)
1477        (buffer-substring-no-properties (match-beginning bibtex-key-in-head)        (buffer-substring-no-properties (match-beginning bibtex-key-in-head)
1478                                        (match-end bibtex-key-in-head))                                        (match-end bibtex-key-in-head))
# Line 1484  delimiters if present." Line 1481  delimiters if present."
1481  ;; Helper Functions  ;; Helper Functions
1482    
1483  (defsubst bibtex-string= (str1 str2)  (defsubst bibtex-string= (str1 str2)
1484    "Return t if two strings are equal, ignoring case."    "Return t if STR1 and STR2 are equal, ignoring case."
1485    (eq t (compare-strings str1 0 nil str2 0 nil t)))    (eq t (compare-strings str1 0 nil str2 0 nil t)))
1486    
1487  (defun bibtex-delete-whitespace ()  (defun bibtex-delete-whitespace ()
# Line 1498  delimiters if present." Line 1495  delimiters if present."
1495       (if (equal (current-column) 0) 1 0)))       (if (equal (current-column) 0) 1 0)))
1496    
1497  (defun bibtex-skip-to-valid-entry (&optional backward)  (defun bibtex-skip-to-valid-entry (&optional backward)
1498    "Unless at beginning of a valid BibTeX entry, move point to beginning of the    "Move point to beginning of the next valid BibTeX entry.
1499  next valid one. With optional argument BACKWARD non-nil, move backward to  Do not move if we are already at beginning of a valid BibTeX entry.
1500  beginning of previous valid one. A valid entry is a syntactical correct one  With optional argument BACKWARD non-nil, move backward to
1501    beginning of previous valid one.  A valid entry is a syntactical correct one
1502  with type contained in `bibtex-entry-field-alist' or, if  with type contained in `bibtex-entry-field-alist' or, if
1503  `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string  `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string
1504  entry. Return buffer position of beginning and ending of entry if a valid  entry.  Return buffer position of beginning and ending of entry if a valid
1505  entry is found, nil otherwise."  entry is found, nil otherwise."
1506    (interactive "P")    (interactive "P")
1507    (let ((case-fold-search t)    (let ((case-fold-search t)
# Line 1528  entry is found, nil otherwise." Line 1526  entry is found, nil otherwise."
1526    
1527  (defun bibtex-map-entries (fun)  (defun bibtex-map-entries (fun)
1528    "Call FUN for each BibTeX entry starting with the current.    "Call FUN for each BibTeX entry starting with the current.
1529  Do this to the end of the file. FUN is called with three arguments, the key of  Do this to the end of the file.  FUN is called with three arguments, the key of
1530  the entry and the buffer positions (marker) of beginning and end of entry.  the entry and the buffer positions (marker) of beginning and end of entry.
1531  Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil,  Point is inside the entry.  If `bibtex-sort-ignore-string-entries' is non-nil,
1532  FUN will not be called for @String entries."  FUN will not be called for @String entries."
1533    (let ((case-fold-search t))    (let ((case-fold-search t))
1534      (bibtex-beginning-of-entry)      (bibtex-beginning-of-entry)
# Line 1596  If FLAG is nil, a message is echoed if p Line 1594  If FLAG is nil, a message is echoed if p
1594    
1595  (defun bibtex-search-entry (empty-head &optional bound noerror backward)  (defun bibtex-search-entry (empty-head &optional bound noerror backward)
1596    "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t).    "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t).
1597  BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD  BOUND and NOERROR are exactly as in `re-search-forward'.  If BACKWARD
1598  is non-nil, search is done in reverse direction. Point is moved past the  is non-nil, search is done in reverse direction.  Point is moved past the
1599  closing delimiter (at the beginning of entry if BACKWARD is non-nil).  closing delimiter (at the beginning of entry if BACKWARD is non-nil).
1600  Return a cons pair with buffer positions of beginning and end of entry.  Return a cons pair with buffer positions of beginning and end of entry.
1601  After call to this function MATCH-BEGINNING and MATCH-END functions  After call to this function MATCH-BEGINNING and MATCH-END functions
# Line 1700  are defined, but only for the head part Line 1698  are defined, but only for the head part
1698      (skip-chars-forward " \t\n")))      (skip-chars-forward " \t\n")))
1699    
1700  (defun bibtex-beginning-of-first-entry ()  (defun bibtex-beginning-of-first-entry ()
1701    "Go to the beginning of the first BibTeX entry in buffer. Return point."    "Go to the beginning of the first BibTeX entry in buffer.  Return point."
1702    (goto-char (point-min))    (goto-char (point-min))
1703    (if (re-search-forward "^[ \t]*@" nil 'move)    (if (re-search-forward "^[ \t]*@" nil 'move)
1704        (beginning-of-line))        (beginning-of-line))
# Line 1725  are defined, but only for the head part Line 1723  are defined, but only for the head part
1723    
1724  (defun bibtex-enclosing-field (&optional noerr)  (defun bibtex-enclosing-field (&optional noerr)
1725    "Search for BibTeX field enclosing point.    "Search for BibTeX field enclosing point.
1726  Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil,  Use `match-beginning' and `match-end' to parse the field.  If NOERR is non-nil,
1727  no error is signalled. In this case, bounds are returned on success,  no error is signalled.  In this case, bounds are returned on success,
1728  nil otherwise. Does not move point."  nil otherwise.  Does not move point."
1729    (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))    (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))
1730      (if (and bounds      (if (and bounds
1731               (<= (bibtex-start-of-field bounds) (point))               (<= (bibtex-start-of-field bounds) (point))
# Line 1737  nil otherwise. Does not move point." Line 1735  nil otherwise. Does not move point."
1735          (error "Can't find enclosing BibTeX field")))))          (error "Can't find enclosing BibTeX field")))))
1736    
1737  (defun bibtex-enclosing-entry-maybe-empty-head ()  (defun bibtex-enclosing-entry-maybe-empty-head ()
1738    "Search for BibTeX entry enclosing point. Move point to end of entry.    "Search for BibTeX entry enclosing point.  Move point to end of entry.
1739  Beginning (but not end) of entry is given by (`match-beginning' 0)."  Beginning (but not end) of entry is given by (`match-beginning' 0)."
1740    (let ((case-fold-search t)    (let ((case-fold-search t)
1741          (old-point (point)))          (old-point (point)))
# Line 2016  Formats current entry according to varia Line 2014  Formats current entry according to varia
2014  (defun bibtex-autokey-abbrev (string len)  (defun bibtex-autokey-abbrev (string len)
2015    "Return an abbreviation of STRING with at least LEN characters.    "Return an abbreviation of STRING with at least LEN characters.
2016  If LEN is positive the abbreviation is terminated only after a consonant  If LEN is positive the abbreviation is terminated only after a consonant
2017  or at the word end. If LEN is negative the abbreviation is strictly  or at the word end.  If LEN is negative the abbreviation is strictly
2018  enforced using abs (LEN) characters. If LEN is not a number, STRING  enforced using abs (LEN) characters.  If LEN is not a number, STRING
2019  is returned unchanged."  is returned unchanged."
2020    (cond ((or (not (numberp len))    (cond ((or (not (numberp len))
2021               (<= (length string) (abs len)))               (<= (length string) (abs len)))
# Line 2033  is returned unchanged." Line 2031  is returned unchanged."
2031                 string)))))                 string)))))
2032    
2033  (defun bibtex-autokey-get-field (field &optional change-list)  (defun bibtex-autokey-get-field (field &optional change-list)
2034    "Get content of BibTeX field FIELD. Return empty string if not found.    "Get content of BibTeX field FIELD.  Return empty string if not found.
2035  Optional arg CHANGE-LIST is a list of substitution patterns that is  Optional arg CHANGE-LIST is a list of substitution patterns that is
2036  applied to the content of FIELD. It is an alist with pairs  applied to the content of FIELD.  It is an alist with pairs
2037  \(OLD-REGEXP . NEW-STRING\)."  \(OLD-REGEXP . NEW-STRING\)."
2038    (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref))    (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref))
2039          case-fold-search)          case-fold-search)
# Line 2058  and return results as a list." Line 2056  and return results as a list."
2056                (split-string names "[ \t\n]+and[ \t\n]+")))))                (split-string names "[ \t\n]+and[ \t\n]+")))))
2057    
2058  (defun bibtex-autokey-demangle-name (fullname)  (defun bibtex-autokey-demangle-name (fullname)
2059    "Get the last part from a well-formed name and perform abbreviations."    "Get the last part from a well-formed FULLNAME and perform abbreviations."
2060    (let* (case-fold-search    (let* (case-fold-search
2061           (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname)           (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname)
2062                        ;; Name is of the form "von Last, First" or                        ;; Name is of the form "von Last, First" or
# Line 2150  The generation algorithm works as follow Line 2148  The generation algorithm works as follow
2148      `bibtex-autokey-name-change-strings' to the corresponding new      `bibtex-autokey-name-change-strings' to the corresponding new
2149      one (see documentation of this variable for further detail).      one (see documentation of this variable for further detail).
2150   4. For every of at least first `bibtex-autokey-names' names in   4. For every of at least first `bibtex-autokey-names' names in
2151      the name field, determine the last name. If there are maximal      the name field, determine the last name.  If there are maximal
2152      `bibtex-autokey-names' + `bibtex-autokey-names-stretch'      `bibtex-autokey-names' + `bibtex-autokey-names-stretch'
2153      names, all names are used.      names, all names are used.
2154   5. From every last name, take at least `bibtex-autokey-name-length'   5. From every last name, take at least `bibtex-autokey-name-length'
# Line 2159  The generation algorithm works as follow Line 2157  The generation algorithm works as follow
2157      `bibtex-autokey-name-case-convert'.      `bibtex-autokey-name-case-convert'.
2158   7. Build the name part of the key by concatenating all   7. Build the name part of the key by concatenating all
2159      abbreviated last names with the string      abbreviated last names with the string
2160      `bibtex-autokey-name-separator' between any two. If there are      `bibtex-autokey-name-separator' between any two.  If there are
2161      more names than are used in the name part, prepend the string      more names than are used in the name part, prepend the string
2162      contained in `bibtex-autokey-additional-names'.      contained in `bibtex-autokey-additional-names'.
2163   8. Build the year part of the key by truncating the contents of   8. Build the year part of the key by truncating the contents of
2164      the year field to the rightmost `bibtex-autokey-year-length'      the year field to the rightmost `bibtex-autokey-year-length'
2165      digits (useful values are 2 and 4). If the year field (or any      digits (useful values are 2 and 4).  If the year field (or any
2166      other field required to generate the key) is absent, but the entry      other field required to generate the key) is absent, but the entry
2167      has a valid crossref field and the variable      has a valid crossref field and the variable
2168      `bibtex-autokey-use-crossref' is non-nil, use the field of the      `bibtex-autokey-use-crossref' is non-nil, use the field of the
# Line 2180  The generation algorithm works as follow Line 2178  The generation algorithm works as follow
2178      appear in `bibtex-autokey-titleword-ignore'.      appear in `bibtex-autokey-titleword-ignore'.
2179      Build the title part of the key by using at least the first      Build the title part of the key by using at least the first
2180      `bibtex-autokey-titlewords' words from this      `bibtex-autokey-titlewords' words from this
2181      abbreviated title. If the abbreviated title ends after      abbreviated title.  If the abbreviated title ends after
2182      maximal `bibtex-autokey-titlewords' +      maximal `bibtex-autokey-titlewords' +
2183      `bibtex-autokey-titlewords-stretch' words, all      `bibtex-autokey-titlewords-stretch' words, all
2184      words from the abbreviated title are used.      words from the abbreviated title are used.
# Line 2201  The generation algorithm works as follow Line 2199  The generation algorithm works as follow
2199      and the title part with `bibtex-autokey-name-year-separator'      and the title part with `bibtex-autokey-name-year-separator'
2200      between the name part and the year part if both are non-empty      between the name part and the year part if both are non-empty
2201      and `bibtex-autokey-year-title-separator' between the year      and `bibtex-autokey-year-title-separator' between the year
2202      part and the title part if both are non-empty. If the year      part and the title part if both are non-empty.  If the year
2203      part is empty, but not the other two parts,      part is empty, but not the other two parts,
2204      `bibtex-autokey-year-title-separator' is used as well.      `bibtex-autokey-year-title-separator' is used as well.
2205  16. If the value of `bibtex-autokey-before-presentation-function'  16. If the value of `bibtex-autokey-before-presentation-function'
2206      is non-nil, it must be a function taking one argument. This      is non-nil, it must be a function taking one argument.  This
2207      function is then called with the generated key as the      function is then called with the generated key as the
2208      argument. The return value of this function (a string) is      argument.  The return value of this function (a string) is
2209      used as the key.      used as the key.
2210  17. If the value of `bibtex-autokey-edit-before-use' is non-nil,  17. If the value of `bibtex-autokey-edit-before-use' is non-nil,
2211      the key is then presented in the minibuffer to the user,      the key is then presented in the minibuffer to the user,
# Line 2261  The generation algorithm works as follow Line 2259  The generation algorithm works as follow
2259  The buffer might possibly be restricted.  The buffer might possibly be restricted.
2260  Find both entry keys and crossref entries.  Find both entry keys and crossref entries.
2261  If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of  If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of
2262  simply resetting it. If ADD is an alist of keys, also add ADD to  simply resetting it.  If ADD is an alist of keys, also add ADD to
2263  `bibtex-reference-keys'. If ABORTABLE is non-nil abort on user  `bibtex-reference-keys'.  If ABORTABLE is non-nil abort on user
2264  input. If VERBOSE is non-nil gives messages about progress.  input.  If VERBOSE is non-nil gives messages about progress.
2265  Return alist of keys if parsing was completed, `aborted' otherwise."  Return alist of keys if parsing was completed, `aborted' otherwise."
2266    (let ((reference-keys (if (and add    (let ((reference-keys (if (and add
2267                                   (listp bibtex-reference-keys))                                   (listp bibtex-reference-keys))
# Line 2327  Return alist of keys if parsing was comp Line 2325  Return alist of keys if parsing was comp
2325    "Set `bibtex-strings' to the string definitions in the whole buffer.    "Set `bibtex-strings' to the string definitions in the whole buffer.
2326  The buffer might possibly be restricted.  The buffer might possibly be restricted.
2327  If ADD is non-nil add the new strings to `bibtex-strings' instead of  If ADD is non-nil add the new strings to `bibtex-strings' instead of
2328  simply resetting it. If ADD is an alist of strings, also add ADD to  simply resetting it.  If ADD is an alist of strings, also add ADD to
2329  `bibtex-strings'. If ABORTABLE is non-nil abort on user input.  `bibtex-strings'.  If ABORTABLE is non-nil abort on user input.
2330  Return alist of strings if parsing was completed, `aborted' otherwise."  Return alist of strings if parsing was completed, `aborted' otherwise."
2331    (save-excursion    (save-excursion
2332      (save-match-data      (save-match-data
# Line 2388  Use `bibtex-predefined-strings' and bib Line 2386  Use `bibtex-predefined-strings' and bib
2386        (append bibtex-predefined-strings (nreverse compl)))))        (append bibtex-predefined-strings (nreverse compl)))))
2387    
2388  (defun bibtex-parse-buffers-stealthily ()  (defun bibtex-parse-buffers-stealthily ()
2389    "Called by `bibtex-run-with-idle-timer'. Whenever emacs has been idle    "Parse buffer in the background during idle time.
2390    Called by `bibtex-run-with-idle-timer'.  Whenever Emacs has been idle
2391  for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting  for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting
2392  with the current) are parsed."  with the current) are parsed."
2393    (save-excursion    (save-excursion
# Line 2412  with the current) are parsed." Line 2411  with the current) are parsed."
2411          (setq buffers (cdr buffers))))))          (setq buffers (cdr buffers))))))
2412    
2413  (defun bibtex-complete-internal (completions)  (defun bibtex-complete-internal (completions)
2414    "Complete word fragment before point to longest prefix of one    "Complete word fragment before point to longest prefix of COMPLETIONS.
2415  string defined in list COMPLETIONS.  If point is not after the part  COMPLETIONS should be a list of strings.  If point is not after the part
2416  of a word, all strings are listed. Return completion."  of a word, all strings are listed.  Return completion."
2417    (let* ((case-fold-search t)    (let* ((case-fold-search t)
2418           (beg (save-excursion           (beg (save-excursion
2419                  (re-search-backward "[ \t{\"]")                  (re-search-backward "[ \t{\"]")
# Line 2514  expansion of STR using expansion list ST Line 2513  expansion of STR using expansion list ST
2513      (set-window-point window (point))))      (set-window-point window (point))))
2514    
2515  (defun bibtex-pop (arg direction)  (defun bibtex-pop (arg direction)
2516    "Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."    "Fill current field from the ARG'th same field's text in DIRECTION.
2517    Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."
2518    (let (bibtex-help-message)    (let (bibtex-help-message)
2519      (bibtex-find-text nil))      (bibtex-find-text nil))
2520    (save-excursion    (save-excursion
# Line 2577  expansion of STR using expansion list ST Line 2577  expansion of STR using expansion list ST
2577  General information on working with BibTeX mode:  General information on working with BibTeX mode:
2578    
2579  You should use commands such as \\[bibtex-Book] to get a template for a  You should use commands such as \\[bibtex-Book] to get a template for a
2580  specific entry. You should then fill in all desired fields using  specific entry.  You should then fill in all desired fields using
2581  \\[bibtex-next-field] to jump from field to field. After having filled  \\[bibtex-next-field] to jump from field to field.  After having filled
2582  in all desired fields in the entry, you should clean the new entry  in all desired fields in the entry, you should clean the new entry
2583  with the command \\[bibtex-clean-entry].  with the command \\[bibtex-clean-entry].
2584    
2585  Some features of BibTeX mode are available only by setting the variable  Some features of BibTeX mode are available only by setting the variable
2586  `bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will  `bibtex-maintain-sorted-entries' to non-nil.  However, then BibTeX mode will
2587  work only with buffers containing valid (syntactical correct) entries  work only with buffers containing valid (syntactical correct) entries
2588  and with entries being sorted. This is usually the case, if you have  and with entries being sorted.  This is usually the case, if you have
2589  created a buffer completely with BibTeX mode and finished every new  created a buffer completely with BibTeX mode and finished every new
2590  entry with \\[bibtex-clean-entry].  entry with \\[bibtex-clean-entry].
2591    
# Line 2736  names for ENTRY-TYPE according to `bibte Line 2736  names for ENTRY-TYPE according to `bibte
2736      (cons required optional)))      (cons required optional)))
2737    
2738  (defun bibtex-entry (entry-type)  (defun bibtex-entry (entry-type)
2739    "Insert a new BibTeX entry.    "Insert a new BibTeX entry of type ENTRY-TYPE.
2740  After insertion it calls the functions in `bibtex-add-entry-hook'."  After insertion it calls the functions in `bibtex-add-entry-hook'."
2741    (interactive (let* ((completion-ignore-case t)    (interactive (let* ((completion-ignore-case t)
2742                        (e-t (completing-read                        (e-t (completing-read
# Line 2753  After insertion it calls the functions i Line 2753  After insertion it calls the functions i
2753      (insert "@" entry-type (bibtex-entry-left-delimiter))      (insert "@" entry-type (bibtex-entry-left-delimiter))
2754      (if key (insert key))      (if key (insert key))
2755      (save-excursion      (save-excursion
2756        (mapcar 'bibtex-make-field (car field-list))        (mapc 'bibtex-make-field (car field-list))
2757        (mapcar 'bibtex-make-optional-field (cdr field-list))        (mapc 'bibtex-make-optional-field (cdr field-list))
2758        (if bibtex-comma-after-last-field        (if bibtex-comma-after-last-field
2759            (insert ","))            (insert ","))
2760        (insert "\n")        (insert "\n")
# Line 2887  Move point to the end of the last field. Line 2887  Move point to the end of the last field.
2887    "Make a field named FIELD in current BibTeX entry.    "Make a field named FIELD in current BibTeX entry.
2888  FIELD is either a string or a list of the form  FIELD is either a string or a list of the form
2889  \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in  \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
2890  `bibtex-entry-field-alist'."  `bibtex-entry-field-alist'.
2891    If CALLED-BY-YANK is non-nil, don't insert delimiters."
2892    (interactive    (interactive
2893     (list (let ((completion-ignore-case t)     (list (let ((completion-ignore-case t)
2894                 (field-list (bibtex-field-list                 (field-list (bibtex-field-list
# Line 2929  FIELD is either a string or a list of th Line 2930  FIELD is either a string or a list of th
2930  (defun bibtex-beginning-of-entry ()  (defun bibtex-beginning-of-entry ()
2931    "Move to beginning of BibTeX entry (beginning of line).    "Move to beginning of BibTeX entry (beginning of line).
2932  If inside an entry, move to the beginning of it, otherwise move to the  If inside an entry, move to the beginning of it, otherwise move to the
2933  beginning of the previous entry. If point is ahead of all BibTeX entries  beginning of the previous entry.  If point is ahead of all BibTeX entries
2934  move point to the beginning of buffer. Return the new location of point."  move point to the beginning of buffer.  Return the new location of point."
2935    (interactive)    (interactive)
2936    (skip-chars-forward " \t")    (skip-chars-forward " \t")
2937    (if (looking-at "@")    (if (looking-at "@")
# Line 2941  move point to the beginning of buffer. R Line 2942  move point to the beginning of buffer. R
2942  (defun bibtex-end-of-entry ()  (defun bibtex-end-of-entry ()
2943    "Move to end of BibTeX entry (past the closing brace).    "Move to end of BibTeX entry (past the closing brace).
2944  If inside an entry, move to the end of it, otherwise move to the end  If inside an entry, move to the end of it, otherwise move to the end
2945  of the previous entry. Do not move if ahead of first entry.  of the previous entry.  Do not move if ahead of first entry.
2946  Return the new location of point."  Return the new location of point."
2947    (interactive)    (interactive)
2948    (let ((case-fold-search t)    (let ((case-fold-search t)
# Line 3041  If mark is active it counts entries in r Line 3042  If mark is active it counts entries in r
3042                        (bibtex-end-of-entry))))                        (bibtex-end-of-entry))))
3043    
3044  (defun bibtex-entry-index ()  (defun bibtex-entry-index ()
3045    "Return the index of the BibTeX entry at point. Move point.    "Return the index of the BibTeX entry at point.  Move point.
3046  The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting  The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting
3047  the entries of the BibTeX buffer. Return nil if no entry found."  the entries of the BibTeX buffer.  Return nil if no entry found."
3048    (let ((case-fold-search t))    (let ((case-fold-search t))
3049      (if (re-search-forward bibtex-entry-maybe-empty-head nil t)      (if (re-search-forward bibtex-entry-maybe-empty-head nil t)
3050          (let ((key (bibtex-key-in-head))          (let ((key (bibtex-key-in-head))
# Line 3093  If its value is nil use plain sorting." Line 3094  If its value is nil use plain sorting."
3094  (defun bibtex-sort-buffer ()  (defun bibtex-sort-buffer ()
3095    "Sort BibTeX buffer alphabetically by key.    "Sort BibTeX buffer alphabetically by key.
3096  The predicate for sorting is defined via `bibtex-maintain-sorted-entries'.  The predicate for sorting is defined via `bibtex-maintain-sorted-entries'.
3097  If its value is nil use plain sorting. Text outside of BibTeX entries is not  If its value is nil use plain sorting.  Text outside of BibTeX entries is not
3098  affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries  affected.  If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
3099  will be ignored."  will be ignored."
3100    (interactive)    (interactive)
3101    (save-restriction    (save-restriction
# Line 3156  With prefix arg, the value of START is p Line 3157  With prefix arg, the value of START is p
3157  INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME).  INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME).
3158  Move point where the entry KEY should be placed.  Move point where the entry KEY should be placed.
3159  If `bibtex-maintain-sorted-entries' is non-nil, perform a binary  If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
3160  search to look for place for KEY. This will fail if buffer is not in  search to look for place for KEY.  This will fail if buffer is not in
3161  sorted order, see \\[bibtex-validate].)  sorted order, see \\[bibtex-validate].)
3162  Return t if preparation was successful or nil if entry KEY already exists."  Return t if preparation was successful or nil if entry KEY already exists."
3163    (let ((key (nth 0 index))    (let ((key (nth 0 index))
# Line 3562  intermixed with \\[bibtex-pop-previous] Line 3563  intermixed with \\[bibtex-pop-previous]
3563  Check that no required fields are empty and formats entry dependent  Check that no required fields are empty and formats entry dependent
3564  on the value of `bibtex-entry-format'.  on the value of `bibtex-entry-format'.
3565  If the reference key of the entry is empty or a prefix argument is given,  If the reference key of the entry is empty or a prefix argument is given,
3566  calculate a new reference key. (Note: this will only work if fields in entry  calculate a new reference key.  (Note: this will only work if fields in entry
3567  begin on separate lines prior to calling `bibtex-clean-entry' or if  begin on separate lines prior to calling `bibtex-clean-entry' or if
3568  'realign is contained in `bibtex-entry-format'.)  'realign is contained in `bibtex-entry-format'.)
3569  Don't call `bibtex-clean-entry' on @Preamble entries.  Don't call `bibtex-clean-entry' on @Preamble entries.
# Line 3962  signaled if point is outside key or BibT Line 3963  signaled if point is outside key or BibT
3963  (defun bibtex-url (&optional event)  (defun bibtex-url (&optional event)
3964    "Browse a URL for the BibTeX entry at position PNT.    "Browse a URL for the BibTeX entry at position PNT.
3965  The URL is generated using the schemes defined in `bibtex-generate-url-list'  The URL is generated using the schemes defined in `bibtex-generate-url-list'
3966  \(see there\). Then the URL is passed to `browse-url'."  \(see there\).  Then the URL is passed to `browse-url'."
3967    (interactive (list last-input-event))    (interactive (list last-input-event))
3968    (save-excursion    (save-excursion
3969      (if event (posn-set-point (event-end event)))      (if event (posn-set-point (event-end event)))
# Line 3972  The URL is generated using the schemes d Line 3973  The URL is generated using the schemes d
3973            (lst bibtex-generate-url-list)            (lst bibtex-generate-url-list)
3974            field url scheme)            field url scheme)
3975        (while (setq scheme (car lst))        (while (setq scheme (car lst))
3976          (when (and (setq field (assoc-string (caar scheme) fields-alist t))          (when (and (setq field (cdr (assoc-string (caar scheme)
3977                     (or (eq t (cdar scheme))                                                    fields-alist t)))
3978                         (string-match (cdar scheme) (cdr field))))                     (progn
3979            (setq lst nil)                       (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" field)
3980                             (setq field (match-string 1 field)))
3981                         (string-match (cdar scheme) field)))
3982              (setq lst nil)
3983              (if (null (cdr scheme))
3984                  (setq url (match-string 0 field)))
3985            (dolist (step (cdr scheme))            (dolist (step (cdr scheme))
3986              (cond ((stringp step)              (cond ((stringp step)
3987                     (setq url (concat url step)))                     (setq url (concat url step)))
3988                    ((setq field (assoc-string (car step) fields-alist t))                    ((setq field (assoc-string (car step) fields-alist t))
3989                     ;; always remove field delimiters                     ;; always remove field delimiters
3990                     (let* ((text (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'"                     (let* ((text (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'"
3991                                                    (cdr field))                                                    (cdr field))
3992                                      (match-string 1 (cdr field))                                      (match-string 1 (cdr field))
3993                                    (cdr field)))                                    (cdr field)))
3994                            (str (cond ((eq t (nth 1 step))                            (str (if (string-match (nth 1 step) text)
3995                                        text)                                     (cond
3996                                       ((and (consp (nth 1 step))                                      ((functionp (nth 2 step))
3997                                             (string-match (car (nth 1 step))                                       (funcall (nth 2 step) text))
3998                                                           text))                                      ((numberp (nth 2 step))
3999                                        (if (numberp (cdr (nth 1 step)))                                       (match-string (nth 2 step) text))
4000                                            (match-string (cdr (nth 1 step))                                      (t
4001                                                          text)                                       (replace-match (nth 2 step) nil nil text)))
4002                                          (replace-match (cdr (nth 1 step))                                   ;; If the scheme is set up correctly,
4003                                                         nil nil text)))                                   ;; we should never reach this point
4004                                       ;; If the scheme is set up correctly,                                   (error "Match failed: %s" text))))
4005                                       ;; we should never reach this point                       (setq url (concat url str))))
4006                                       (t (error "Match failed: %s" text)))))                    ;; If the scheme is set up correctly,
4007                       (setq url (concat url (if (fboundp (nth 2 step))                    ;; we should never reach this point
4008                                                 (funcall (nth 2 step) str)                    (t (error "Step failed: %s" step))))
4009                                               str)))))            (message "%s" url)
                   ;; If the scheme is set up correctly,  
                   ;; we should never reach this point  
                   (t (error "Step failed: %s" step))))  
           (message "%s" url)  
4010            (browse-url url))            (browse-url url))
4011          (setq lst (cdr lst)))          (setq lst (cdr lst)))
4012      (unless url (message "No URL known.")))))      (unless url (message "No URL known.")))))
# Line 4014  The URL is generated using the schemes d Line 4016  The URL is generated using the schemes d
4016    (let ((case-fold-search t)    (let ((case-fold-search t)
4017          (bounds (bibtex-enclosing-field t))          (bounds (bibtex-enclosing-field t))
4018          (pnt (point))          (pnt (point))
4019          found url)          found field)
4020      ;; We use start-of-field as syntax-begin      ;; We use start-of-field as syntax-begin
4021      (goto-char (if bounds (bibtex-start-of-field bounds) pnt))      (goto-char (if bounds (bibtex-start-of-field bounds) pnt))
4022      (while (and (not found)      (while (and (not found)
4023                  (search-forward-regexp bibtex-font-lock-url-regexp bound t)                  (prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
4024                  (save-match-data (setq bounds (bibtex-parse-field-text)))                    (setq field (match-string-no-properties 1)))
4025                  (>= bound (car bounds)))                  (setq bounds (bibtex-parse-field-text))
4026        (let ((field (match-string-no-properties 1))                  (>= bound (car bounds))
4027              (lst bibtex-generate-url-list))                  (>= (car bounds) pnt))
4028          (while (and (not found)        (let ((lst bibtex-generate-url-list) url)
4029                      (setq url (caar lst)))          (goto-char (car bounds))
4030            (when (bibtex-string= field (car url))          (while (and (not found)
4031              (if (eq t (cdr url))                      (setq url (caar lst)))
4032                  (progn            (when (bibtex-string= field (car url))
4033                    (goto-char (min bound (cdr bounds)))              (setq found (re-search-forward (cdr url) (cdr bounds) t)))
4034                    (set-match-data (list (car bounds) (point)))            (setq lst (cdr lst))))
4035                    (setq found t))        (goto-char (cdr bounds)))
               (goto-char (car bounds))  
               (setq found (search-forward-regexp (cdr url)  
                                                  (min bound (cdr bounds)) t)))  
             (if (< (match-beginning 0) pnt)  
                 (setq found nil)))  
           (setq lst (cdr lst)))))  
4036      found))      found))
4037    
4038    

Legend:
Removed from v.1.84  
changed lines
  Added in v.1.85

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