unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Evgeny Zajcev <lg.zevlg@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Buffer local `switch-to-buffer-preserve-window-point'
Date: Mon, 30 Nov 2020 20:57:44 +0300	[thread overview]
Message-ID: <CAO=W_Zr64NEf045DxwfkhttFOxVPWZWkmTo++OstD6LXgJ7_EQ@mail.gmail.com> (raw)
In-Reply-To: <CAO=W_Zop=vToV-zcTvgHN4KFK+RG7WOiSgcmuC0hJ-chjC=1eQ@mail.gmail.com>


[-- 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


  reply	other threads:[~2020-11-30 17:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-11-30 19:01       ` martin rudalics
2020-12-01  9:32         ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO=W_Zr64NEf045DxwfkhttFOxVPWZWkmTo++OstD6LXgJ7_EQ@mail.gmail.com' \
    --to=lg.zevlg@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).