]> git.eshelyaron.com Git - emacs.git/commitdiff
Put re-loaded file back at start of load-history (bug#26837)
authorGlenn Morris <rgm@gnu.org>
Tue, 9 May 2017 23:44:09 +0000 (19:44 -0400)
committerGlenn Morris <rgm@gnu.org>
Tue, 9 May 2017 23:44:09 +0000 (19:44 -0400)
* src/lread.c (readevalloop): Fix the "whole buffer" check to
operate in the correct buffer.
(Feval_buffer): Move point back to the start after checking
for lexical binding.
* test/src/lread-tests.el (lread-test-bug26837): New test.
* test/data/somelib.el, test/data/somelib2.el: New test data files.

src/lread.c
test/data/somelib.el [new file with mode: 0644]
test/data/somelib2.el [new file with mode: 0644]
test/src/lread-tests.el

index 6467043b1daa23833d6c4acbb9ca0df948a5ed14..f0ad0c28e560d50ac6d7ba9e0e101c704172e571 100644 (file)
@@ -1885,7 +1885,7 @@ readevalloop (Lisp_Object readcharfun,
       /* On the first cycle, we can easily test here
         whether we are reading the whole buffer.  */
       if (b && first_sexp)
-       whole_buffer = (PT == BEG && ZV == Z);
+       whole_buffer = (BUF_PT (b) == BUF_BEG (b) && BUF_ZV (b) == BUF_Z (b));
 
       instream = stream;
     read_next:
@@ -2008,6 +2008,7 @@ This function preserves the position of point.  */)
   record_unwind_protect (save_excursion_restore, save_excursion_save ());
   BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
   specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
+  BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
   readevalloop (buf, 0, filename,
                !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
   unbind_to (count, Qnil);
diff --git a/test/data/somelib.el b/test/data/somelib.el
new file mode 100644 (file)
index 0000000..7b8d403
--- /dev/null
@@ -0,0 +1,7 @@
+;;; -*- lexical-binding: t; -*-
+
+;; blah
+
+(defun somefunc () t)
+
+(provide 'somelib)
diff --git a/test/data/somelib2.el b/test/data/somelib2.el
new file mode 100644 (file)
index 0000000..0515614
--- /dev/null
@@ -0,0 +1,7 @@
+;;; -*- lexical-binding: t; -*-
+
+;; blah
+
+(defun somefunc2 () t)
+
+(provide 'somelib2)
index 84342348d45c6979ab5000bbccfda53600fbeb3a..0427fe64e4a111812cbf9ffb62a3993f82b3123c 100644 (file)
@@ -142,4 +142,17 @@ literals (Bug#20852)."
                            "unescaped character literals "
                            "\", (, ), ;, [, ] detected!")))))
 
+(ert-deftest lread-test-bug26837 ()
+  "Test for http://debbugs.gnu.org/26837 ."
+  (let ((load-path (cons
+                    (file-name-as-directory
+                     (expand-file-name "data" (getenv "EMACS_TEST_DIRECTORY")))
+                    load-path)))
+    (load "somelib" nil t)
+    (should (string-suffix-p "/somelib.el" (caar load-history)))
+    (load "somelib2" nil t)
+    (should (string-suffix-p "/somelib2.el" (caar load-history)))
+    (load "somelib" nil t)
+    (should (string-suffix-p "/somelib.el" (caar load-history)))))
+
 ;;; lread-tests.el ends here