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

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

bug#21764: 25.0.50; bibtex-set-dialect not called for bibtex buffers


From: Lars Ingebrigtsen
Subject: bug#21764: 25.0.50; bibtex-set-dialect not called for bibtex buffers
Date: Wed, 12 Aug 2020 14:34:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Grégoire Jadi <gregoire.jadi@univ-nantes.fr> writes:
>
>> Below a patch that fixes this bug and with regression tests.
>
> Thanks for writing the test.
>
> This needs a comment on why bibtex-set-dialect is being called, when it
> is also being added to the hook. Better would be to check if there is a
> file associated with the current buffer.
>
> This sets the global value of bibtex-* variables; is that appropriate?

I've re-spun the patch (included below) -- some paths have changed.

Stephen, I'm not sure I understand your questions about this patch -- as
far as I can see, bibtex-set-dialect isn't being added to any hooks?
But I may be misreading the code (I'm not very familiar with it).

You also say that it says the global bibtex variables, but it calls the
function with LOCAL set to t, which the documentation says sets the
local value...

diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 0018b89d85..910bd7dbb9 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -3445,6 +3445,7 @@ bibtex-mode
   (set (make-local-variable 'syntax-propertize-function)
        (syntax-propertize-via-font-lock
         bibtex-font-lock-syntactic-keywords))
+  (bibtex-set-dialect nil t)
   ;; Allow `bibtex-dialect' as a file-local variable.
   (add-hook 'hack-local-variables-hook #'bibtex-set-dialect nil t))
 
diff --git a/test/lisp/textmodes/bibtex-tests.el 
b/test/lisp/textmodes/bibtex-tests.el
new file mode 100644
index 0000000000..b3858de9e6
--- /dev/null
+++ b/test/lisp/textmodes/bibtex-tests.el
@@ -0,0 +1,57 @@
+;;; bibtex-tests.el --- Test suite for bibtex.
+
+;; Copyright (C) 2013-2020 Free Software Foundation, Inc.
+
+;; Keywords: bibtex
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'bibtex)
+
+(ert-deftest bibtex-test-set-dialect ()
+  "Tests if `bibtex-set-dialect' is executed."
+  (with-temp-buffer
+    (insert "@article{someID,
+  author = {some author},
+  title = {some title},
+}")
+    (bibtex-mode)
+    (should-not (null bibtex-dialect))
+    (should-not (null bibtex-entry-type))
+    (should-not (null bibtex-entry-head))
+    (should-not (null bibtex-reference-key))
+    (should-not (null bibtex-entry-head))
+    (should-not (null bibtex-entry-maybe-empty-head))
+    (should-not (null bibtex-any-valid-entry-type))))
+
+(ert-deftest bibtex-test-parse-buffers-stealthily ()
+  "Tests if `bibtex-parse-buffers-stealthily' can be executed."
+  (with-temp-buffer
+    (insert "@article{someID,
+  author = {some author},
+  title = {some title},
+}")
+    (bibtex-mode)
+    (should (progn (bibtex-parse-buffers-stealthily) t))))
+
+(provide 'bibtex-tests)
+
+;;; bibtex-tests.el ends here


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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