emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BibTeX-mode: bibtex-user-optional-fields: INIT without {}


From: Roland Winkler
Subject: Re: BibTeX-mode: bibtex-user-optional-fields: INIT without {}
Date: Sat, 14 Apr 2007 15:57:44 -0500

Glenn Morris wrote
> Christian Schlauer wrote:
> > So the curly braces are missing.
> I think this patch fixes it.

The following patch appears much clearer to me. Also, it handles
properly the case that INIT can be a lambda expression. Finally, the
first part fixes an old bug in the handling of bibtex-include-OPTkey.

Should I check it in?


--- bibtex.el~  2007-01-21 07:37:51.000000000 -0600
+++ bibtex.el   2007-04-14 15:35:57.000000000 -0500
@@ -2831,7 +2831,7 @@
         (push (list "key"
                     "Used for reference key creation if author and editor 
fields are missing"
                     (if (or (stringp bibtex-include-OPTkey)
-                            (fboundp bibtex-include-OPTkey))
+                            (functionp bibtex-include-OPTkey))
                         bibtex-include-OPTkey))
               optional))
     (if (member-ignore-case entry-type bibtex-include-OPTcrossref)
@@ -3058,10 +3058,14 @@
     (indent-to-column (+ bibtex-entry-offset
                          bibtex-text-indentation)))
   (let ((init (nth 2 field)))
-    (insert (cond ((stringp init) init)
-                  ((fboundp init) (funcall init))
-                  (t (concat (bibtex-field-left-delimiter)
-                             (bibtex-field-right-delimiter))))))
+    (if (not init) (setq init (concat (bibtex-field-left-delimiter)
+                                      (bibtex-field-right-delimiter)))
+      (if (functionp init) (setq init (funcall init)))
+      (unless (stringp init) (error "%s is not a string" init))
+      (unless (string-match "\\`\\({.*}\\|\".*\"\\)\\'" init)
+        (setq init (concat (bibtex-field-left-delimiter) init
+                           (bibtex-field-right-delimiter)))))
+    (insert init))
   (when interactive
     ;; (bibtex-find-text nil nil bibtex-help-message)
     (if (memq (preceding-char) '(?} ?\")) (forward-char -1))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]