* Buffer local `switch-to-buffer-preserve-window-point'
@ 2020-11-30 8:03 Evgeny Zajcev
2020-11-30 9:06 ` martin rudalics
2020-11-30 17:30 ` martin rudalics
0 siblings, 2 replies; 8+ messages in thread
From: Evgeny Zajcev @ 2020-11-30 8:03 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]
I think we should add to the documentation that buffer local values for
`switch-to-buffer-obey-display-actions' and
`switch-to-buffer-preserve-window-point' won't work as user would expect.
The problem with their buffer local values is that they are used for buffer
logic *before* buffer is set as current, see `switch-to-buffer'. We should
either use `(buffer-local-value NAME buffer)' to get their values in
`switch-to-buffer', or add to the documentation that they should not have
buffer local values.
Here is code snippet to trigger unexpected behaviour:
;; Switch to scratch and eval
(progn
(setq switch-to-buffer-preserve-window-point t)
(with-current-buffer (get-buffer-create "pwp")
(setq-local switch-to-buffer-preserve-window-point nil)
(insert "asnoteh asoensnaot heusnatoeh usanotehu aeosntuhaoe")
(point))
(switch-to-buffer "pwp")
(switch-to-other-buffer 1)
(with-current-buffer "pwp"
(goto-char 10)
(point))
(switch-to-buffer "pwp")
;; Expecting point to be at 10 position, but it remains at the end
;; of the line
)
What do you think?
Thanks
--
lg
[-- Attachment #2: Type: text/html, Size: 1553 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 8:03 Buffer local `switch-to-buffer-preserve-window-point' Evgeny Zajcev
@ 2020-11-30 9:06 ` martin rudalics
2020-11-30 10:34 ` Evgeny Zajcev
2020-11-30 17:30 ` martin rudalics
1 sibling, 1 reply; 8+ messages in thread
From: martin rudalics @ 2020-11-30 9:06 UTC (permalink / raw)
To: Evgeny Zajcev, emacs-devel
> (switch-to-other-buffer 1)
Please also provide the code for this function.
Thanks, martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 9:06 ` martin rudalics
@ 2020-11-30 10:34 ` Evgeny Zajcev
0 siblings, 0 replies; 8+ messages in thread
From: Evgeny Zajcev @ 2020-11-30 10:34 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
пн, 30 нояб. 2020 г. в 12:06, martin rudalics <rudalics@gmx.at>:
> > (switch-to-other-buffer 1)
>
> Please also provide the code for this function.
>
Ah, sorry, I thought that is in Emacs, but it was from my init.el :)),
replace with (switch-to-buffer (other-buffer))
--
lg
[-- Attachment #2: Type: text/html, Size: 682 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 8:03 Buffer local `switch-to-buffer-preserve-window-point' Evgeny Zajcev
2020-11-30 9:06 ` martin rudalics
@ 2020-11-30 17:30 ` martin rudalics
2020-11-30 17:54 ` Evgeny Zajcev
1 sibling, 1 reply; 8+ messages in thread
From: martin rudalics @ 2020-11-30 17:30 UTC (permalink / raw)
To: Evgeny Zajcev, emacs-devel
> Ah, sorry, I thought that is in Emacs, but it was from my init.el :)),
> replace with (switch-to-buffer (other-buffer))
OK.
> The problem with their buffer local values is that they are used for buffer
> logic *before* buffer is set as current, see `switch-to-buffer'. We should
> either use `(buffer-local-value NAME buffer)' to get their values in
> `switch-to-buffer',
Good idea. Could you write a patch?
martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 17:30 ` martin rudalics
@ 2020-11-30 17:54 ` Evgeny Zajcev
2020-11-30 17:57 ` Evgeny Zajcev
0 siblings, 1 reply; 8+ messages in thread
From: Evgeny Zajcev @ 2020-11-30 17:54 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 723 bytes --]
пн, 30 нояб. 2020 г. в 20:30, martin rudalics <rudalics@gmx.at>:
> > Ah, sorry, I thought that is in Emacs, but it was from my init.el :)),
> > replace with (switch-to-buffer (other-buffer))
>
> OK.
>
> > The problem with their buffer local values is that they are used for
> buffer
> > logic *before* buffer is set as current, see `switch-to-buffer'. We
> should
> > either use `(buffer-local-value NAME buffer)' to get their values in
> > `switch-to-buffer',
>
> Good idea. Could you write a patch?
>
>
Sure, here it is
Probably same should be done for `switch-to-buffer-obey-display-actions',
but at the moment I care more about `switch-to-buffer-preserve-window-point'
--
lg
[-- Attachment #1.2: Type: text/html, Size: 1193 bytes --]
[-- Attachment #2: 0001-Fix-use-of-switch-to-buffer-preserve-window-point.patch --]
[-- Type: text/x-patch, Size: 1417 bytes --]
From 2e25a05e0b9eb3a891be369bc7428fb017d8902f Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Mon, 30 Nov 2020 20:51:18 +0300
Subject: [PATCH] Fix use of switch-to-buffer-preserve-window-point
* lisp/window.el (switch-to-buffer): Regard buffer local value
for switch-to-buffer-preserve-window-point variable
---
lisp/window.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/window.el b/lisp/window.el
index 82976bf836..ea3f581a2f 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8566,13 +8566,13 @@ switch-to-buffer
(when set-window-start-and-point
(let* ((entry (assq buffer (window-prev-buffers)))
- (displayed (and (eq switch-to-buffer-preserve-window-point
- 'already-displayed)
+ (preserver-win-point
+ (buffer-local-value 'switch-to-buffer-preserve-window-point
+ buffer))
+ (displayed (and (eq preserver-win-point 'already-displayed)
(get-buffer-window buffer 0))))
(set-window-buffer nil buffer)
- (when (and entry
- (or (eq switch-to-buffer-preserve-window-point t)
- displayed))
+ (when (and entry (or (eq preserver-win-point t) displayed))
;; Try to restore start and point of buffer in the selected
;; window (Bug#4041).
(set-window-start (selected-window) (nth 1 entry) t)
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 17:54 ` Evgeny Zajcev
@ 2020-11-30 17:57 ` Evgeny Zajcev
2020-11-30 19:01 ` martin rudalics
0 siblings, 1 reply; 8+ messages in thread
From: Evgeny Zajcev @ 2020-11-30 17:57 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 912 bytes --]
пн, 30 нояб. 2020 г. в 20:54, Evgeny Zajcev <lg.zevlg@gmail.com>:
>
>
> пн, 30 нояб. 2020 г. в 20:30, martin rudalics <rudalics@gmx.at>:
>
>> > Ah, sorry, I thought that is in Emacs, but it was from my init.el :)),
>> > replace with (switch-to-buffer (other-buffer))
>>
>> OK.
>>
>> > The problem with their buffer local values is that they are used for
>> buffer
>> > logic *before* buffer is set as current, see `switch-to-buffer'. We
>> should
>> > either use `(buffer-local-value NAME buffer)' to get their values in
>> > `switch-to-buffer',
>>
>> Good idea. Could you write a patch?
>>
>>
> Sure, here it is
>
> Probably same should be done for `switch-to-buffer-obey-display-actions',
> but at the moment I care more about `switch-to-buffer-preserve-window-point'
>
Sorry, there was a typo: preserver instead of preserve, here is the update
--
lg
[-- Attachment #1.2: Type: text/html, Size: 1680 bytes --]
[-- Attachment #2: 0001-Fix-use-of-switch-to-buffer-preserve-window-point.patch --]
[-- Type: text/x-patch, Size: 1418 bytes --]
From 2e25a05e0b9eb3a891be369bc7428fb017d8902f Mon Sep 17 00:00:00 2001
From: Zajcev Evgeny <zevlg@yandex.ru>
Date: Mon, 30 Nov 2020 20:51:18 +0300
Subject: [PATCH 1/2] Fix use of switch-to-buffer-preserve-window-point
* lisp/window.el (switch-to-buffer): Regard buffer local value
for switch-to-buffer-preserve-window-point variable
---
lisp/window.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/window.el b/lisp/window.el
index 82976bf836..ea3f581a2f 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8566,13 +8566,13 @@ switch-to-buffer
(when set-window-start-and-point
(let* ((entry (assq buffer (window-prev-buffers)))
- (displayed (and (eq switch-to-buffer-preserve-window-point
- 'already-displayed)
+ (preserve-win-point
+ (buffer-local-value 'switch-to-buffer-preserve-window-point
+ buffer))
+ (displayed (and (eq preserve-win-point 'already-displayed)
(get-buffer-window buffer 0))))
(set-window-buffer nil buffer)
- (when (and entry
- (or (eq switch-to-buffer-preserve-window-point t)
- displayed))
+ (when (and entry (or (eq preserve-win-point t) displayed))
;; Try to restore start and point of buffer in the selected
;; window (Bug#4041).
(set-window-start (selected-window) (nth 1 entry) t)
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 17:57 ` Evgeny Zajcev
@ 2020-11-30 19:01 ` martin rudalics
2020-12-01 9:32 ` martin rudalics
0 siblings, 1 reply; 8+ messages in thread
From: martin rudalics @ 2020-11-30 19:01 UTC (permalink / raw)
To: Evgeny Zajcev; +Cc: emacs-devel
>> Sure, here it is
>>
>> Probably same should be done for `switch-to-buffer-obey-display-actions',
Probably.
>> but at the moment I care more about `switch-to-buffer-preserve-window-point'
>>
>
> Sorry, there was a typo: preserver instead of preserve, here is the update
Thanks. I suppose you can't install it yourself so I will do so tomorrow
if the state of my machines permits it.
martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Buffer local `switch-to-buffer-preserve-window-point'
2020-11-30 19:01 ` martin rudalics
@ 2020-12-01 9:32 ` martin rudalics
0 siblings, 0 replies; 8+ messages in thread
From: martin rudalics @ 2020-12-01 9:32 UTC (permalink / raw)
To: Evgeny Zajcev; +Cc: emacs-devel
> Thanks. I suppose you can't install it yourself so I will do so tomorrow
> if the state of my machines permits it.
I've got the permission so this is done.
martin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-12-01 9:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-30 8:03 Buffer local `switch-to-buffer-preserve-window-point' Evgeny Zajcev
2020-11-30 9:06 ` martin rudalics
2020-11-30 10:34 ` Evgeny Zajcev
2020-11-30 17:30 ` martin rudalics
2020-11-30 17:54 ` Evgeny Zajcev
2020-11-30 17:57 ` Evgeny Zajcev
2020-11-30 19:01 ` martin rudalics
2020-12-01 9:32 ` martin rudalics
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.