[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bibtex-empty-field-re matches nonempty fields.
From: |
Roland Winkler |
Subject: |
Re: bibtex-empty-field-re matches nonempty fields. |
Date: |
Tue, 25 Jan 2005 14:57:02 +0100 |
On Tue Jan 25 2005 Lute Kamstra wrote:
> Currently, `bibtex-empty-field-re' in lisp/textmodes/bibtex.el is
> "\"\"\\|{}" which matches nonempty field strings like "{Wac\\l{}aw
> Sierpi\\'nski}". The patch below fixes this. Shall I commit it?
Thank you! Yes, bibtex-empty-field-re erroneously matches this
field string. However, your patch didn't work for me. It revealed
a bug in the setting of the local variable empty-field in
bibtex-format-entry. Furthermore, it required some changes in
bibtex-autofill-entry. If the patch below works for you, I suggest
that you commit it.
Roland
--- lisp/textmodes/bibtex.el 2004-12-20 11:06:16.000000000 +0100
+++ lisp/textmodes/bibtex.el 2005-01-25 14:32:38.727399469 +0100
@@ -1115,8 +1115,7 @@
t))
"Regexp matching the name of any valid BibTeX entry (including string).")
-
-(defconst bibtex-empty-field-re "\"\"\\|{}"
+(defconst bibtex-empty-field-re "\\`\\(\"\"\\|{}\\)\\'"
"Regexp matching an empty field.")
(defconst bibtex-font-lock-syntactic-keywords
@@ -1875,7 +1874,7 @@
(if opt-alt (+ beg-name 3) beg-name) end-name))
(empty-field (string-match bibtex-empty-field-re
(buffer-substring-no-properties
- beg-field end-field)))
+ beg-text end-text)))
deleted)
;; We have more elegant high-level functions for several
@@ -2960,9 +2959,13 @@
(while (setq bounds (bibtex-parse-field bibtex-field-name))
(let ((text (assoc-string (bibtex-name-in-field bounds t)
other t)))
- (goto-char (bibtex-start-of-text-in-field bounds))
- (if (not (and (looking-at bibtex-empty-field-re) text))
+ (if (not (and text
+ (string-match bibtex-empty-field-re
+ (buffer-substring-no-properties
+ (bibtex-start-of-text-in-field bounds)
+ (bibtex-end-of-text-in-field
bounds)))))
(goto-char (bibtex-end-of-field bounds))
+ (goto-char (bibtex-start-of-text-in-field bounds))
(delete-region (point) (bibtex-end-of-text-in-field bounds))
(insert (cdr text)))))
;; Finally try to update the text based on the difference between
- bibtex-empty-field-re matches nonempty fields., Lute Kamstra, 2005/01/25
- Re: bibtex-empty-field-re matches nonempty fields.,
Roland Winkler <=
- non-breaking spaces in view-mode, Roland Winkler, 2005/01/25
- Re: non-breaking spaces in view-mode, Richard Stallman, 2005/01/26
- Re: non-breaking spaces in view-mode, Roland Winkler, 2005/01/26
- Re: non-breaking spaces in view-mode, Stefan Monnier, 2005/01/26
- Re: non-breaking spaces in view-mode, Roland Winkler, 2005/01/26
- Re: non-breaking spaces in view-mode, Stefan Monnier, 2005/01/26
- Re: non-breaking spaces in view-mode, Roland Winkler, 2005/01/26
- Re: non-breaking spaces in view-mode, Stefan Monnier, 2005/01/26
- Re: non-breaking spaces in view-mode, Roland Winkler, 2005/01/27