aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2017-05-09 19:44:09 -0400
committerGlenn Morris2017-05-09 19:44:09 -0400
commitdb30296baed2d9c3c80eb89f6fae256e81ee2fbc (patch)
tree6f680bfa4af603e2a5d7a4ec92d267d07e56ac7f
parentd6d5020c2593a1e8ac2fe7ef4f217cfbcacfd32d (diff)
downloademacs-db30296baed2d9c3c80eb89f6fae256e81ee2fbc.tar.gz
emacs-db30296baed2d9c3c80eb89f6fae256e81ee2fbc.zip
Put re-loaded file back at start of load-history (bug#26837)
* 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.
-rw-r--r--src/lread.c3
-rw-r--r--test/data/somelib.el7
-rw-r--r--test/data/somelib2.el7
-rw-r--r--test/src/lread-tests.el13
4 files changed, 29 insertions, 1 deletions
diff --git a/src/lread.c b/src/lread.c
index 6467043b1da..f0ad0c28e56 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1885,7 +1885,7 @@ readevalloop (Lisp_Object readcharfun,
1885 /* On the first cycle, we can easily test here 1885 /* On the first cycle, we can easily test here
1886 whether we are reading the whole buffer. */ 1886 whether we are reading the whole buffer. */
1887 if (b && first_sexp) 1887 if (b && first_sexp)
1888 whole_buffer = (PT == BEG && ZV == Z); 1888 whole_buffer = (BUF_PT (b) == BUF_BEG (b) && BUF_ZV (b) == BUF_Z (b));
1889 1889
1890 instream = stream; 1890 instream = stream;
1891 read_next: 1891 read_next:
@@ -2008,6 +2008,7 @@ This function preserves the position of point. */)
2008 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 2008 record_unwind_protect (save_excursion_restore, save_excursion_save ());
2009 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf))); 2009 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2010 specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil); 2010 specbind (Qlexical_binding, lisp_file_lexically_bound_p (buf) ? Qt : Qnil);
2011 BUF_TEMP_SET_PT (XBUFFER (buf), BUF_BEGV (XBUFFER (buf)));
2011 readevalloop (buf, 0, filename, 2012 readevalloop (buf, 0, filename,
2012 !NILP (printflag), unibyte, Qnil, Qnil, Qnil); 2013 !NILP (printflag), unibyte, Qnil, Qnil, Qnil);
2013 unbind_to (count, Qnil); 2014 unbind_to (count, Qnil);
diff --git a/test/data/somelib.el b/test/data/somelib.el
new file mode 100644
index 00000000000..7b8d4037396
--- /dev/null
+++ b/test/data/somelib.el
@@ -0,0 +1,7 @@
1;;; -*- lexical-binding: t; -*-
2
3;; blah
4
5(defun somefunc () t)
6
7(provide 'somelib)
diff --git a/test/data/somelib2.el b/test/data/somelib2.el
new file mode 100644
index 00000000000..05156145a22
--- /dev/null
+++ b/test/data/somelib2.el
@@ -0,0 +1,7 @@
1;;; -*- lexical-binding: t; -*-
2
3;; blah
4
5(defun somefunc2 () t)
6
7(provide 'somelib2)
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 84342348d45..0427fe64e4a 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -142,4 +142,17 @@ literals (Bug#20852)."
142 "unescaped character literals " 142 "unescaped character literals "
143 "\", (, ), ;, [, ] detected!"))))) 143 "\", (, ), ;, [, ] detected!")))))
144 144
145(ert-deftest lread-test-bug26837 ()
146 "Test for http://debbugs.gnu.org/26837 ."
147 (let ((load-path (cons
148 (file-name-as-directory
149 (expand-file-name "data" (getenv "EMACS_TEST_DIRECTORY")))
150 load-path)))
151 (load "somelib" nil t)
152 (should (string-suffix-p "/somelib.el" (caar load-history)))
153 (load "somelib2" nil t)
154 (should (string-suffix-p "/somelib2.el" (caar load-history)))
155 (load "somelib" nil t)
156 (should (string-suffix-p "/somelib.el" (caar load-history)))))
157
145;;; lread-tests.el ends here 158;;; lread-tests.el ends here