Discussion:
Setting point
(too old to reply)
Lars Ingebrigtsen
2018-04-13 19:56:13 UTC
Permalink
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
Eli Zaretskii
2018-04-13 20:32:25 UTC
Permalink
Date: Fri, 13 Apr 2018 21:56:13 +0200
(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.
Lars Ingebrigtsen
2018-04-13 20:39:23 UTC
Permalink
Post by Eli Zaretskii
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
Lars Ingebrigtsen
2018-04-13 20:41:22 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Eli Zaretskii
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
Stefan Monnier
2018-04-13 21:40:42 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Eli Zaretskii
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
Lars Ingebrigtsen
2018-04-13 21:52:43 UTC
Permalink
Post by Stefan Monnier
Post by Lars Ingebrigtsen
Post by Eli Zaretskii
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
Stefan Monnier
2018-04-13 22:14:29 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Stefan Monnier
Post by Lars Ingebrigtsen
Post by Eli Zaretskii
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
I believe you do, tho only for a particular circumstance.
Post by Lars Ingebrigtsen
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
Lars Ingebrigtsen
2018-04-13 22:24:03 UTC
Permalink
Post by Stefan Monnier
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...
Post by Stefan Monnier
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
Eli Zaretskii
2018-04-14 06:17:35 UTC
Permalink
Date: Fri, 13 Apr 2018 22:39:23 +0200
Post by Eli Zaretskii
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.

Loading...