Subject: BibTeX mode problems: non-existent directories, faulty regexp-opt

From: Michael Ernst <[email-masked]>
Date: Fri, 11 Dec 2009 22:40:14 -0800 (PST)

bibtex.el uses regexp-opt, which introduces new capturing parentheses that
throw off variables like bibtex-type-in-head, which is a regexp
subexpression number.  (Really, regexp-opt should be rewritten to only use
non-capturing parentheses!)

The below patch corrects the problem.

                    -Michael Ernst

My patches are against:
  GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.3) of 2009-11-10 on vernadsky, modified by Debian
but the problem also exists in the Emacs CVS repository.

ChangeLog entry:

2009-12-11  Michael Ernst  <[email-masked]>

	* bibtex.el (bibtex-entry-type): Remove regexp-opt, which throws
	off regexp subexpression numbering.

diff -u /home/mernst/emacs/fixes/bibtex.el-orig /home/mernst/emacs/fixes/bibtex.el
--- /home/mernst/emacs/fixes/bibtex.el-orig	2009-12-11 22:13:59.000000000 -0800
+++ /home/mernst/emacs/fixes/bibtex.el	2009-12-11 22:15:28.000000000 -0800
@@ -1219,7 +1219,7 @@
 
 (defvar bibtex-entry-type
   (concat "@[ \t]*\\(?:"
-          (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)")
+          (mapconcat 'car bibtex-entry-field-alist "\\|") "\\)")
   "Regexp matching the type of a BibTeX entry.")
 
 (defvar bibtex-entry-head