GNU bug report logs -
#32850
27.0.50; window-swap-states doesn't swap window prev/next-buffers
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Thu, 27 Sep 2018 00:06:02 UTC
Severity: minor
Found in version 27.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #43 received at 32850 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> I'd like to make it customizable by using the existing customization in
>> the arg WRITABLE of window-state-get and window-persistent-parameters,
>> even though formally prev/next-buffers is not a window parameter (maybe
>> it should be, I don't know).
>
> Always keep in mind that prev_buffers and next_buffers need special
> treatment in mark_object to make sure that dead buffers from window
> configurations stored somewhere (for example in a register) get their
> entries deleted and can be eventually reclaimed. This is something I
> completely disregarded when writing the original code for navigating
> these buffer lists. Stefan then wrote the code to do that in
> mark_object.
When testing the previous patch, I noticed that killed buffers automatically
disappear from prev/next-buffers lists, so there are no #<killed buffer> remains.
Is it handled by code in kill-buffer?
>> Done, with a small change: even though set-marker is idempotent in regard
>> to its POSITION arg (i.e. if POSITION is a marker, it creates an identical
>> marker), I added a check to not create a new one. OTOH, get-buffer is
>> idempotent too, but it seems window-state-put never receives a structure
>> with buffer objects, and I'm not sure why window-state-get should always
>> use buffer-name regardless of the value WRITABLE, i.e. why should it return
>> buffer names as strings instead of buffer objects even when WRITABLE is nil?
>
> Maybe because I didn't care about non-writable states back then. But
> you're obviously right. Buffers can be renamed at will and in that
> case we might have a state with a non-existent buffer or even buffers
> with names switched and therefore invalid values of start or point.
What do you think about creating new functions to convert the existing
states from non-writable to writable and back? Then in the same session
it would be more optimal to use window states with buffer/mark objects,
and states to save to the desktop could be serialized by such functions.
> So yes: Please use a buffer object for non-writable states.
Here is a new patch:
[window-state-prev-next-buffers.2.patch (text/x-diff, inline)]
diff --git a/lisp/window.el b/lisp/window.el
index a7318308ef..77b650fda9 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -5579,7 +5579,7 @@ window--state-get-1
(let ((point (window-point window))
(start (window-start window)))
`((buffer
- ,(buffer-name buffer)
+ ,(if writable (buffer-name buffer) buffer)
(selected . ,selected)
(hscroll . ,(window-hscroll window))
(fringes . ,(window-fringes window))
@@ -5599,20 +5599,20 @@ window--state-get-1
(with-current-buffer buffer
(copy-marker start))))))))
,@(when next-buffers
- `((next-buffers . ,(mapcar (lambda (buffer)
- (buffer-name buffer))
- next-buffers))))
+ `((next-buffers
+ . ,(if writable
+ (mapcar (lambda (buffer) (buffer-name buffer))
+ next-buffers)
+ next-buffers))))
,@(when prev-buffers
- `((prev-buffers .
- ,(mapcar (lambda (entry)
- (list (buffer-name (nth 0 entry))
- (if writable
- (marker-position (nth 1 entry))
- (nth 1 entry))
- (if writable
- (marker-position (nth 2 entry))
- (nth 2 entry))))
- prev-buffers))))))
+ `((prev-buffers
+ . ,(if writable
+ (mapcar (lambda (entry)
+ (list (buffer-name (nth 0 entry))
+ (marker-position (nth 1 entry))
+ (marker-position (nth 2 entry))))
+ prev-buffers)
+ prev-buffers))))))
(tail
(when (memq type '(vc hc))
(let (list)
This bug report was last modified 6 years and 183 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.