diff options
author | Eli Zaretskii <eliz@gnu.org> | 2022-07-07 11:56:31 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-07-07 11:56:31 +0300 |
commit | 74f43f82e6b4702027d99edb6ca125f3243ce4ba (patch) | |
tree | 7d8fbfec626fe32b87ea7518219a5365d47bfd3e /src/fileio.c | |
parent | b075a59a1a4ddfd0668da4fb2312a6ec747dd53b (diff) | |
download | emacs-74f43f82e6b4702027d99edb6ca125f3243ce4ba.tar.gz |
Fix undo of changes in cloned indirect buffers
* lisp/simple.el (primitive-undo): If the visited-modtime of the
indirect buffer's file is bogus, use the modtime of the file
visited by its base buffer.
* src/undo.c (record_first_change): Call
'buffer_visited_file_modtime' with the correct buffer, instead of
always calling 'Fvisited_file_modtime', which returns possibly
bogus values for indirect buffers.
* src/fileio.c (Fset_visited_file_modtime): Signal a meaningful
error for indirect buffers.
(buffer_visited_file_modtime): New function, with implementation
taken from 'Fvisited_file_modtime'.
(Fvisited_file_modtime): Call 'buffer_visited_file_modtime'.
* src/lisp.h: Add prototype for 'buffer_visited_file_modtime'.
(Bug#56397)
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c index 10d4b8bc15e..d07e62a1212 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5832,6 +5832,15 @@ See Info node `(elisp)Modification Time' for more details. */) return Qnil; } +Lisp_Object +buffer_visited_file_modtime (struct buffer *buf) +{ + int ns = buf->modtime.tv_nsec; + if (ns < 0) + return make_fixnum (UNKNOWN_MODTIME_NSECS - ns); + return make_lisp_time (buf->modtime); +} + DEFUN ("visited-file-modtime", Fvisited_file_modtime, Svisited_file_modtime, 0, 0, 0, doc: /* Return the current buffer's recorded visited file modification time. @@ -5841,10 +5850,7 @@ visited file doesn't exist. See Info node `(elisp)Modification Time' for more details. */) (void) { - int ns = current_buffer->modtime.tv_nsec; - if (ns < 0) - return make_fixnum (UNKNOWN_MODTIME_NSECS - ns); - return make_lisp_time (current_buffer->modtime); + return buffer_visited_file_modtime (current_buffer); } DEFUN ("set-visited-file-modtime", Fset_visited_file_modtime, @@ -5871,6 +5877,8 @@ in `current-time' or an integer flag as returned by `visited-file-modtime'. */) current_buffer->modtime = mtime; current_buffer->modtime_size = -1; } + else if (current_buffer->base_buffer) + error ("An indirect buffer does not have a visited file"); else { register Lisp_Object filename; |