unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Setting point
@ 2018-04-13 19:56 Lars Ingebrigtsen
  2018-04-13 20:32 ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-13 19:56 UTC (permalink / raw)
  To: emacs-devel

If you're in an Emacs with *scratch* not displayed, this is a noop:

(progn (set-buffer (get-buffer "*scratch*")) (goto-char (point-max)))

When you switch to *scratch*, point will be wherever it used to be.

I don't think Emacs has always behaved this way?  It changed perhaps
5-10 years ago?

Anyway, how do you set point in buffers these days?  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 19:56 Setting point Lars Ingebrigtsen
@ 2018-04-13 20:32 ` Eli Zaretskii
  2018-04-13 20:39   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2018-04-13 20:32 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Fri, 13 Apr 2018 21:56:13 +0200
> 
> If you're in an Emacs with *scratch* not displayed, this is a noop:
> 
> (progn (set-buffer (get-buffer "*scratch*")) (goto-char (point-max)))
> 
> When you switch to *scratch*, point will be wherever it used to be.
> 
> I don't think Emacs has always behaved this way?  It changed perhaps
> 5-10 years ago?

That's switch-to-buffer-preserve-window-point in action.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 20:32 ` Eli Zaretskii
@ 2018-04-13 20:39   ` Lars Ingebrigtsen
  2018-04-13 20:41     ` Lars Ingebrigtsen
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-13 20:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> That's switch-to-buffer-preserve-window-point in action.

Ah, thanks.  Even if there's no window displaying the buffer?

I guess Gnus will have to bind that variable before manipulating point
in the *Group* buffer...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 20:39   ` Lars Ingebrigtsen
@ 2018-04-13 20:41     ` Lars Ingebrigtsen
  2018-04-13 21:40     ` Stefan Monnier
  2018-04-14  6:17     ` Eli Zaretskii
  2 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-13 20:41 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> That's switch-to-buffer-preserve-window-point in action.
>
> Ah, thanks.  Even if there's no window displaying the buffer?
>
> I guess Gnus will have to bind that variable before manipulating point
> in the *Group* buffer...

Hm.  Binding (switch-to-buffer-preserve-window-point nil) didn't seem to
have any effect.  And I'm not using switch-to-buffer, only set-buffer...

*scratches head*

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 20:39   ` Lars Ingebrigtsen
  2018-04-13 20:41     ` Lars Ingebrigtsen
@ 2018-04-13 21:40     ` Stefan Monnier
  2018-04-13 21:52       ` Lars Ingebrigtsen
  2018-04-14  6:17     ` Eli Zaretskii
  2 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2018-04-13 21:40 UTC (permalink / raw)
  To: emacs-devel

>> That's switch-to-buffer-preserve-window-point in action.
> Ah, thanks.  Even if there's no window displaying the buffer?
> I guess Gnus will have to bind that variable before manipulating point
> in the *Group* buffer...

That variable takes effect when the buffer is displayed, not when its
point is moved.

So you should probably set it buffer-locally instead.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 21:40     ` Stefan Monnier
@ 2018-04-13 21:52       ` Lars Ingebrigtsen
  2018-04-13 22:14         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-13 21:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> That's switch-to-buffer-preserve-window-point in action.
>> Ah, thanks.  Even if there's no window displaying the buffer?
>> I guess Gnus will have to bind that variable before manipulating point
>> in the *Group* buffer...
>
> That variable takes effect when the buffer is displayed, not when its
> point is moved.
>
> So you should probably set it buffer-locally instead.

Hm...  But I don't really want to interfere permanently with any user
settings: I just want to move the point in the *Group* buffer the way it
used to move before whatever was introduced recently (i.e., during the
past ten years :-)).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 21:52       ` Lars Ingebrigtsen
@ 2018-04-13 22:14         ` Stefan Monnier
  2018-04-13 22:24           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2018-04-13 22:14 UTC (permalink / raw)
  To: emacs-devel

>>>> That's switch-to-buffer-preserve-window-point in action.
>>> Ah, thanks.  Even if there's no window displaying the buffer?
>>> I guess Gnus will have to bind that variable before manipulating point
>>> in the *Group* buffer...
>> That variable takes effect when the buffer is displayed, not when its
>> point is moved.
>> So you should probably set it buffer-locally instead.
> Hm...  But I don't really want to interfere permanently with any user
> settings:

I believe you do, tho only for a particular circumstance.

> I just want to move the point in the *Group* buffer the way it
> used to move before whatever was introduced recently (i.e., during the
> past ten years :-)).

What you describe is called "interfere with user settings".

switch-to-buffer-preserve-window-point was introduced mainly so that if
you have a buffer displayed in 2 windows or more, switching to some
other buffer and back will get you to the original point instead of
moving you to one of the points of one of the other windows displaying
that buffer.

That seems to be fundamentally incompatible with your desire to move
point programmatically while the buffer is not displayed.

BTW, I'm not sure exactly what is the circumstance where you want Gnus
to do that, but maybe a better solution is to move point at another
moment, i.e. either before *Group* is un-displayed, or after *Group* is
re-displayed.  E.g. instead of moving point to the next group when
I leave a group, Gnus could move point to the next group just before
entering the group (at which point *Group* is still displayed).


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 22:14         ` Stefan Monnier
@ 2018-04-13 22:24           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-13 22:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> switch-to-buffer-preserve-window-point was introduced mainly so that if
> you have a buffer displayed in 2 windows or more, switching to some
> other buffer and back will get you to the original point instead of
> moving you to one of the points of one of the other windows displaying
> that buffer.

Hm...  I see.  That does sound useful.  But here the buffer isn't
displayed that way, so...

> BTW, I'm not sure exactly what is the circumstance where you want Gnus
> to do that, but maybe a better solution is to move point at another
> moment, i.e. either before *Group* is un-displayed, or after *Group* is
> re-displayed.  E.g. instead of moving point to the next group when
> I leave a group, Gnus could move point to the next group just before
> entering the group (at which point *Group* is still displayed).

Yes, that's what Gnus does now, but it didn't do it on all "exit group"
commands, so things got a bit confused.  This happened to work before
because Emacs left the point alone after it had been set, but stopped
working some years ago.

But I think I've fixed the remaining commands now, so I was mostly just
curious about how this was supposed to work.  

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Setting point
  2018-04-13 20:39   ` Lars Ingebrigtsen
  2018-04-13 20:41     ` Lars Ingebrigtsen
  2018-04-13 21:40     ` Stefan Monnier
@ 2018-04-14  6:17     ` Eli Zaretskii
  2 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2018-04-14  6:17 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: emacs-devel@gnu.org
> Date: Fri, 13 Apr 2018 22:39:23 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > That's switch-to-buffer-preserve-window-point in action.
> 
> Ah, thanks.  Even if there's no window displaying the buffer?

With the default value of t, yes.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-14  6:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-13 19:56 Setting point Lars Ingebrigtsen
2018-04-13 20:32 ` Eli Zaretskii
2018-04-13 20:39   ` Lars Ingebrigtsen
2018-04-13 20:41     ` Lars Ingebrigtsen
2018-04-13 21:40     ` Stefan Monnier
2018-04-13 21:52       ` Lars Ingebrigtsen
2018-04-13 22:14         ` Stefan Monnier
2018-04-13 22:24           ` Lars Ingebrigtsen
2018-04-14  6:17     ` Eli Zaretskii

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