diff options
| author | Martin Rudalics | 2024-03-15 10:35:27 +0100 |
|---|---|---|
| committer | Martin Rudalics | 2024-03-15 10:35:27 +0100 |
| commit | 5bba1b95b8088048808b306bf8b00eb9b342ce92 (patch) | |
| tree | 0320ea25b5ea77cd7224134a69dd73dcf8996753 /src/buffer.c | |
| parent | 1c4233b9a391ba5d5746acf6b6fd4b352b8c3a58 (diff) | |
| download | emacs-5bba1b95b8088048808b306bf8b00eb9b342ce92.tar.gz emacs-5bba1b95b8088048808b306bf8b00eb9b342ce92.zip | |
Further adjustments for restoring killed buffer windows (Bug#68235)
* etc/NEWS: Announce 'window-restore-killed-buffer-windows'.
* src/buffer.h (struct buffer) : New field last_name_.
* src/buffer.c (Fbuffer_last_name): New function to return last
name of buffer before it was killed or renamed.
(bset_last_name, Fget_buffer_create, Fmake_indirect_buffer)
(Frename_buffer, Fkill_buffer, init_buffer_once): Set buffer's
last_name_ field accordingly.
* src/window.c (window_restore_killed_buffer_windows): New
variable replacing Vwindow_kept_windows_functions.
(Fset_window_configuration): Use
window_restore_killed_buffer_windows instead of
Vwindow_kept_windows_functions.
* lisp/window.el (window--state-put-2, window-state-put): Use
'window-restore-killed-buffer-windows' instead of
'window-kept-windows-functions'.
* doc/lispref/windows.texi (Window Configurations): Describe
'window-restore-killed-buffer-windows' which replaces
'window-kept-windows-functions'.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c index 43a9249528c..07d19dfc078 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -327,6 +327,11 @@ bset_name (struct buffer *b, Lisp_Object val) | |||
| 327 | b->name_ = val; | 327 | b->name_ = val; |
| 328 | } | 328 | } |
| 329 | static void | 329 | static void |
| 330 | bset_last_name (struct buffer *b, Lisp_Object val) | ||
| 331 | { | ||
| 332 | b->last_name_ = val; | ||
| 333 | } | ||
| 334 | static void | ||
| 330 | bset_overwrite_mode (struct buffer *b, Lisp_Object val) | 335 | bset_overwrite_mode (struct buffer *b, Lisp_Object val) |
| 331 | { | 336 | { |
| 332 | b->overwrite_mode_ = val; | 337 | b->overwrite_mode_ = val; |
| @@ -647,6 +652,7 @@ even if it is dead. The return value is never nil. */) | |||
| 647 | name = Fcopy_sequence (buffer_or_name); | 652 | name = Fcopy_sequence (buffer_or_name); |
| 648 | set_string_intervals (name, NULL); | 653 | set_string_intervals (name, NULL); |
| 649 | bset_name (b, name); | 654 | bset_name (b, name); |
| 655 | bset_last_name (b, name); | ||
| 650 | 656 | ||
| 651 | b->inhibit_buffer_hooks = !NILP (inhibit_buffer_hooks); | 657 | b->inhibit_buffer_hooks = !NILP (inhibit_buffer_hooks); |
| 652 | bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt); | 658 | bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt); |
| @@ -866,6 +872,7 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */) | |||
| 866 | name = Fcopy_sequence (name); | 872 | name = Fcopy_sequence (name); |
| 867 | set_string_intervals (name, NULL); | 873 | set_string_intervals (name, NULL); |
| 868 | bset_name (b, name); | 874 | bset_name (b, name); |
| 875 | bset_last_name (b, name); | ||
| 869 | 876 | ||
| 870 | /* An indirect buffer shares undo list of its base (Bug#18180). */ | 877 | /* An indirect buffer shares undo list of its base (Bug#18180). */ |
| 871 | bset_undo_list (b, BVAR (b->base_buffer, undo_list)); | 878 | bset_undo_list (b, BVAR (b->base_buffer, undo_list)); |
| @@ -1282,6 +1289,17 @@ Return nil if BUFFER has been killed. */) | |||
| 1282 | return BVAR (decode_buffer (buffer), name); | 1289 | return BVAR (decode_buffer (buffer), name); |
| 1283 | } | 1290 | } |
| 1284 | 1291 | ||
| 1292 | DEFUN ("buffer-last-name", Fbuffer_last_name, Sbuffer_last_name, 0, 1, 0, | ||
| 1293 | doc: /* Return last name of BUFFER, as a string. | ||
| 1294 | BUFFER defaults to the current buffer. | ||
| 1295 | |||
| 1296 | This is the name BUFFER had before the last time it was renamed or | ||
| 1297 | immediately before it was killed. */) | ||
| 1298 | (Lisp_Object buffer) | ||
| 1299 | { | ||
| 1300 | return BVAR (decode_buffer (buffer), last_name); | ||
| 1301 | } | ||
| 1302 | |||
| 1285 | DEFUN ("buffer-file-name", Fbuffer_file_name, Sbuffer_file_name, 0, 1, 0, | 1303 | DEFUN ("buffer-file-name", Fbuffer_file_name, Sbuffer_file_name, 0, 1, 0, |
| 1286 | doc: /* Return name of file BUFFER is visiting, or nil if none. | 1304 | doc: /* Return name of file BUFFER is visiting, or nil if none. |
| 1287 | No argument or nil as argument means use the current buffer. */) | 1305 | No argument or nil as argument means use the current buffer. */) |
| @@ -1652,6 +1670,7 @@ This does not change the name of the visited file (if any). */) | |||
| 1652 | (register Lisp_Object newname, Lisp_Object unique) | 1670 | (register Lisp_Object newname, Lisp_Object unique) |
| 1653 | { | 1671 | { |
| 1654 | register Lisp_Object tem, buf; | 1672 | register Lisp_Object tem, buf; |
| 1673 | Lisp_Object oldname = BVAR (current_buffer, name); | ||
| 1655 | Lisp_Object requestedname = newname; | 1674 | Lisp_Object requestedname = newname; |
| 1656 | 1675 | ||
| 1657 | CHECK_STRING (newname); | 1676 | CHECK_STRING (newname); |
| @@ -1669,12 +1688,12 @@ This does not change the name of the visited file (if any). */) | |||
| 1669 | if (NILP (unique) && XBUFFER (tem) == current_buffer) | 1688 | if (NILP (unique) && XBUFFER (tem) == current_buffer) |
| 1670 | return BVAR (current_buffer, name); | 1689 | return BVAR (current_buffer, name); |
| 1671 | if (!NILP (unique)) | 1690 | if (!NILP (unique)) |
| 1672 | newname = Fgenerate_new_buffer_name (newname, | 1691 | newname = Fgenerate_new_buffer_name (newname, oldname); |
| 1673 | BVAR (current_buffer, name)); | ||
| 1674 | else | 1692 | else |
| 1675 | error ("Buffer name `%s' is in use", SDATA (newname)); | 1693 | error ("Buffer name `%s' is in use", SDATA (newname)); |
| 1676 | } | 1694 | } |
| 1677 | 1695 | ||
| 1696 | bset_last_name (current_buffer, oldname); | ||
| 1678 | bset_name (current_buffer, newname); | 1697 | bset_name (current_buffer, newname); |
| 1679 | 1698 | ||
| 1680 | /* Catch redisplay's attention. Unless we do this, the mode lines for | 1699 | /* Catch redisplay's attention. Unless we do this, the mode lines for |
| @@ -2095,6 +2114,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 2095 | This gets rid of them for certain. */ | 2114 | This gets rid of them for certain. */ |
| 2096 | reset_buffer_local_variables (b, 1); | 2115 | reset_buffer_local_variables (b, 1); |
| 2097 | 2116 | ||
| 2117 | bset_last_name (b, BVAR (b, name)); | ||
| 2098 | bset_name (b, Qnil); | 2118 | bset_name (b, Qnil); |
| 2099 | 2119 | ||
| 2100 | block_input (); | 2120 | block_input (); |
| @@ -4666,6 +4686,7 @@ init_buffer_once (void) | |||
| 4666 | /* These used to be stuck at 0 by default, but now that the all-zero value | 4686 | /* These used to be stuck at 0 by default, but now that the all-zero value |
| 4667 | means Qnil, we have to initialize them explicitly. */ | 4687 | means Qnil, we have to initialize them explicitly. */ |
| 4668 | bset_name (&buffer_local_flags, make_fixnum (0)); | 4688 | bset_name (&buffer_local_flags, make_fixnum (0)); |
| 4689 | bset_last_name (&buffer_local_flags, make_fixnum (0)); | ||
| 4669 | bset_mark (&buffer_local_flags, make_fixnum (0)); | 4690 | bset_mark (&buffer_local_flags, make_fixnum (0)); |
| 4670 | bset_local_var_alist (&buffer_local_flags, make_fixnum (0)); | 4691 | bset_local_var_alist (&buffer_local_flags, make_fixnum (0)); |
| 4671 | bset_keymap (&buffer_local_flags, make_fixnum (0)); | 4692 | bset_keymap (&buffer_local_flags, make_fixnum (0)); |
| @@ -6026,6 +6047,7 @@ There is no reason to change that value except for debugging purposes. */); | |||
| 6026 | defsubr (&Smake_indirect_buffer); | 6047 | defsubr (&Smake_indirect_buffer); |
| 6027 | defsubr (&Sgenerate_new_buffer_name); | 6048 | defsubr (&Sgenerate_new_buffer_name); |
| 6028 | defsubr (&Sbuffer_name); | 6049 | defsubr (&Sbuffer_name); |
| 6050 | defsubr (&Sbuffer_last_name); | ||
| 6029 | defsubr (&Sbuffer_file_name); | 6051 | defsubr (&Sbuffer_file_name); |
| 6030 | defsubr (&Sbuffer_base_buffer); | 6052 | defsubr (&Sbuffer_base_buffer); |
| 6031 | defsubr (&Sbuffer_local_value); | 6053 | defsubr (&Sbuffer_local_value); |