all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bastian Beischer <bastian.beischer@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: bug#28645 <28645@debbugs.gnu.org>, Brief Busters <dgutov@yandex.ru>
Subject: bug#28645: Status: 26.0.50; semantic-ia-fast-jump jumps to a random place in buffer
Date: Wed, 4 Oct 2017 13:11:13 +0200	[thread overview]
Message-ID: <CAK9AuB_wzJpsOqWfUBBQF1wB=fM9aVyXt7NSjNcBr0md1u0KSw@mail.gmail.com> (raw)
In-Reply-To: <59D4A3D5.2030005@gmx.at>

Hey Martin,

On Wed, Oct 4, 2017 at 11:03 AM, martin rudalics <rudalics@gmx.at> wrote:
>> I would also be grateful for a little bit of background information. At
>> which point did it become necessary to use 'pop-to-buffer' instead of
>> 'switch-to-buffer'? Apparently 'semantic-ia-fast-jump' et al worked fine
>> in older emacs versions.
>>
>> When is it ok to use 'switch-to-buffer'? There are numerous occurences
>> of it throughout emacs...
>
> Consider the following scenario:
>
> (1) ‘switch-to-buffer-preserve-window-point’ is t (it is so by default).
>
> (2) An application explicitly sets point in a buffer that is currently
>     not displayed in the selected window to a value different from the
>     value of ‘window-point’ of that window at the last time this buffer
>     was displayed there.
>
> (3) The application wants to switch to the buffer in the selected window
>     with ‘window-point’ at the position of point assigned in (2).
>
> If the application used ‘switch-to-buffer’ in (3), then ‘window-point’
> will be reset to the old location of ‘window-point’ which is obviously
> not what the application wants.  So to get what it wants, an application
> either has to bind ‘switch-to-buffer-preserve-window-point’ to nil
> around the ‘switch-to-buffer’ call or use ‘pop-to-buffer-same-window’
> (‘display-buffer-same-window’ if the window may remain unselected)
> instead.
>
> IMHO applications should never call ‘switch-to-buffer’.  They should
> either call ‘pop-to-buffer’ - if the user is supposed to now continue
> working in the window showing the buffer - and ‘display-buffer’ in all
> other cases.  Both allow the user to control how to display the buffer.
>
> Only if there is a clear preference that the buffer should be shown in
> the _selected_ window, the ‘-same-window’ functions should be called.
> And programmers should be aware that at the time they want to show a
> buffer in the selected window, that window might be the minibuffer
> window or a window dedicated to some other buffer.

I understand. Then this must mean that the change in behavior in CEDET
was triggered with this commit:

commit ee297210cffb9e8d05912686a39fa158414ba050
Author: Mark Oteiza <mvoteiza@udel.edu>
Date:   Thu May 26 21:47:18 2016 -0400

   Preserve buffer point in windows by default (Bug#4041).

   * doc/lispref/windows.texi: Mention new default.
   * etc/NEWS: Mention new default.
   * lisp/window.el (switch-to-buffer-preserve-window-point): Default to t.

which is part of master and emacs-26 but was not part of any previous releases.

I also understand your other arguments. But the question is: While
your recommendation makes sense, there clearly still is a lot of code
which uses switch-to-buffer without binding
switch-to-buffer-preserve-window-point to nil and it wasn't fixed when
this variable's default was changed. This is true in lisp code shipped
in emacs and it is probably also true for lots of third party code in
the wild. Who is going to fix all this code? And if it turns out that
the fixing all this code is too difficult / impossible, is it
justified to fix bug #4041 at the cost of causing numerous other bugs
(which arguably are due to misuse of switch-to-buffer, but they will
have to be fixed either way)?

>
> martin
>

Cheers and thanks again for your answer.
Bastian





  reply	other threads:[~2017-10-04 11:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 13:23 bug#28645: 26.0.50; semantic-ia-fast-jump jumps to a random place in buffer Constantine
2017-09-29 14:42 ` Dmitry Gutov
2017-09-29 14:57   ` Constantine
2017-09-29 18:18   ` martin rudalics
2017-09-30 14:19     ` Dmitry Gutov
2017-10-03  9:40 ` bug#28645: Status: " Bastian Beischer
2017-10-04  9:03   ` martin rudalics
2017-10-04 11:11     ` Bastian Beischer [this message]
2017-10-05  8:09       ` martin rudalics
2017-10-15 23:06   ` Dmitry Gutov
2017-10-16 10:21     ` Bastian Beischer
2017-10-17  8:58       ` martin rudalics
2017-10-17 10:44       ` Dmitry Gutov
2017-10-17 12:30         ` Bastian Beischer
2017-10-18 23:46           ` Dmitry Gutov
2017-10-19  9:41             ` Bastian Beischer
2017-10-19 10:03               ` Dmitry Gutov

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

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

  git send-email \
    --in-reply-to='CAK9AuB_wzJpsOqWfUBBQF1wB=fM9aVyXt7NSjNcBr0md1u0KSw@mail.gmail.com' \
    --to=bastian.beischer@gmail.com \
    --cc=28645@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --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 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.