unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 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

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 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).