* prevent scroll-lock-mode from scrolling?
@ 2016-06-17 1:12 lee
2016-06-17 1:25 ` Emanuel Berg
2016-06-17 6:47 ` Eli Zaretskii
0 siblings, 2 replies; 19+ messages in thread
From: lee @ 2016-06-17 1:12 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
is there a way to prevent the point from moving up or down when
scroll-lock-mode is enabled and the contents of the buffer have been
scrolled so far as for the first or the last line to reach the top or
the bottom of the frame, respectively?
It pretty much defeats the idea of this mode when the point moves
nonetheless after scrolling for a bit, since I would use this mode to
keep the point in its very place when scrolling.
I do understand that the point moving might be a feature allowing the
point to reach every line of the buffer without having to disable
scroll-lock-mode. However, my main purpose for the mode would be to
review some lengthy text, particularly source code, and I'd consider it
a useful feature to have to switch the mode on and off, mirroring
switching between reviewing and editing.
OTOH, I can even imagine modifying the mode such that when it's enabled,
the point always remains within a configurable number of lines at the
centre of the frame --- or at the centre of the lines, in case there can
be more lines displayed than the contents of the buffer have --- while
the contents of the buffer are being scrolled into position when I
scroll them. There's probably such a "scroll-programming-mode" already
available?
Thinking of this, is there a kinda complementary mode, or an option, to
scroll-lock-mode, which would move the point together with the contents
of the buffer when I scroll? This would be useful to scroll in some
part of the buffer content which isn't currently visible without having
to leave the line the point is currently in. (I'd use the ScrollLock
and Pause keys to toggle these two modes, and the "intermediate"
scrolling could automatically be disabled and the point be brought back
to where it was on the screen once I start typing again, like xterm does
this ...)
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 1:12 prevent scroll-lock-mode from scrolling? lee
@ 2016-06-17 1:25 ` Emanuel Berg
2016-06-17 4:14 ` Stefan Monnier
2016-06-17 22:47 ` prevent scroll-lock-mode from scrolling? lee
2016-06-17 6:47 ` Eli Zaretskii
1 sibling, 2 replies; 19+ messages in thread
From: Emanuel Berg @ 2016-06-17 1:25 UTC (permalink / raw)
To: help-gnu-emacs
lee <lee@yagibdah.de> writes:
> is there a way to prevent the point from
> moving up or down when scroll-lock-mode is
> enabled and the contents of the buffer have
> been scrolled so far as for the first or the
> last line to reach the top or the bottom of
> the frame, respectively?
I don't know, but try this:
(require 'cl-macs)
;; civilized scrolling - one line at a time
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)
;; scroll the current window
(defun scroll-up-1 ()
(interactive)
(scroll-down 1) )
(defun scroll-down-1 ()
(interactive)
(scroll-up 1) )
;; automatic scrolling
(defun start-automatic-scroll-down ()
(interactive)
(let ((win))
(cl-loop do
(progn (setq win (window-end))
(scroll-down-1)
(sleep-for 1) ; put speed here in seconds
(redisplay) )
until (= win (window-end)) )))
;; (start-automatic-scroll-down)
;; ^ test here
Civilized scrolling: one line at a time!
http://user.it.uu.se/~embe8573/conf/emacs-init/scroll.el
I have "scroll-up-1" M-i, ditto down M-k,
and... well, it is all in the file.
Worth checking out!
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 48 Blogomatic articles -
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 1:25 ` Emanuel Berg
@ 2016-06-17 4:14 ` Stefan Monnier
2016-06-17 6:00 ` Emanuel Berg
2016-06-17 22:47 ` prevent scroll-lock-mode from scrolling? lee
1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2016-06-17 4:14 UTC (permalink / raw)
To: help-gnu-emacs
> I don't know, but try this:
> (require 'cl-macs)
Don't. This should be (require 'cl-lib).
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 4:14 ` Stefan Monnier
@ 2016-06-17 6:00 ` Emanuel Berg
2016-06-17 22:40 ` Stefan Monnier
0 siblings, 1 reply; 19+ messages in thread
From: Emanuel Berg @ 2016-06-17 6:00 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca>
writes:
>> I don't know, but try this: (require
>
> 'cl-macs)
>
> Don't. This should be (require 'cl-lib).
OK...?
What about cl-extra?
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 48 Blogomatic articles -
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 1:12 prevent scroll-lock-mode from scrolling? lee
2016-06-17 1:25 ` Emanuel Berg
@ 2016-06-17 6:47 ` Eli Zaretskii
2016-06-17 23:10 ` lee
1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2016-06-17 6:47 UTC (permalink / raw)
To: help-gnu-emacs
> From: lee <lee@yagibdah.de>
> Date: Fri, 17 Jun 2016 03:12:15 +0200
>
> is there a way to prevent the point from moving up or down when
> scroll-lock-mode is enabled and the contents of the buffer have been
> scrolled so far as for the first or the last line to reach the top or
> the bottom of the frame, respectively?
>
> It pretty much defeats the idea of this mode when the point moves
> nonetheless after scrolling for a bit, since I would use this mode to
> keep the point in its very place when scrolling.
AFAIU, that's exactly the point of this minor mode. If you don't like
it, I suggest not to turn on the mode.
> Thinking of this, is there a kinda complementary mode, or an option, to
> scroll-lock-mode, which would move the point together with the contents
> of the buffer when I scroll?
That's what happens by default, so I don't think I understand what are
you looking for. Perhaps consider telling more about the feature you
want to have.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 6:00 ` Emanuel Berg
@ 2016-06-17 22:40 ` Stefan Monnier
2016-06-18 1:19 ` what to require (was: Re: prevent scroll-lock-mode from scrolling?) Emanuel Berg
0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2016-06-17 22:40 UTC (permalink / raw)
To: help-gnu-emacs
> What about cl-extra?
Same thing.
Stefan
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 1:25 ` Emanuel Berg
2016-06-17 4:14 ` Stefan Monnier
@ 2016-06-17 22:47 ` lee
1 sibling, 0 replies; 19+ messages in thread
From: lee @ 2016-06-17 22:47 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> lee <lee@yagibdah.de> writes:
>
>> is there a way to prevent the point from
>> moving up or down when scroll-lock-mode is
>> enabled and the contents of the buffer have
>> been scrolled so far as for the first or the
>> last line to reach the top or the bottom of
>> the frame, respectively?
>
> I don't know, but try this:
>
> (require 'cl-macs)
>
> ;; civilized scrolling - one line at a time
> (setq scroll-conservatively 10000)
> (setq auto-window-vscroll nil)
>
> ;; scroll the current window
> (defun scroll-up-1 ()
> (interactive)
> (scroll-down 1) )
> (defun scroll-down-1 ()
> (interactive)
> (scroll-up 1) )
>
> ;; automatic scrolling
> (defun start-automatic-scroll-down ()
> (interactive)
> (let ((win))
> (cl-loop do
> (progn (setq win (window-end))
> (scroll-down-1)
> (sleep-for 1) ; put speed here in seconds
> (redisplay) )
> until (= win (window-end)) )))
> ;; (start-automatic-scroll-down)
> ;; ^ test here
>
> Civilized scrolling: one line at a time!
>
> http://user.it.uu.se/~embe8573/conf/emacs-init/scroll.el
>
> I have "scroll-up-1" M-i, ditto down M-k,
> and... well, it is all in the file.
> Worth checking out!
Thanks, I'll try it out! :)
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 6:47 ` Eli Zaretskii
@ 2016-06-17 23:10 ` lee
2016-06-18 8:38 ` Eli Zaretskii
0 siblings, 1 reply; 19+ messages in thread
From: lee @ 2016-06-17 23:10 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
>> From: lee <lee@yagibdah.de>
>> Date: Fri, 17 Jun 2016 03:12:15 +0200
>>
>> is there a way to prevent the point from moving up or down when
>> scroll-lock-mode is enabled and the contents of the buffer have been
>> scrolled so far as for the first or the last line to reach the top or
>> the bottom of the frame, respectively?
>>
>> It pretty much defeats the idea of this mode when the point moves
>> nonetheless after scrolling for a bit, since I would use this mode to
>> keep the point in its very place when scrolling.
>
> AFAIU, that's exactly the point of this minor mode. If you don't like
> it, I suggest not to turn on the mode.
Well, what happens when you turn it on and your scrolling reaches the
end of the buffer?
The point moves towards the end of the buffer rather than that the
buffer contents are scrolled up.
>> Thinking of this, is there a kinda complementary mode, or an option, to
>> scroll-lock-mode, which would move the point together with the contents
>> of the buffer when I scroll?
>
> That's what happens by default, so I don't think I understand what are
> you looking for. Perhaps consider telling more about the feature you
> want to have.
You must somehow be scrolling very differently from how I scroll.
Or perhaps I shouldn't say "scroll" but "move the point" instead. When
scroll-lock-mode is enabled and you move the point up or down (C-p or
C-n), the buffer contents are scrolled down or up, respectively, while
the point remains in one place. Yet when you come close to the top or
the end of the buffer, the point /does/ suddenly move up or down as if
scroll-lock-mode was disabled. That's what defeats the scroll-lock-mode
entirely.
I'd even say it's a bug, and that scrolling the buffer contents must
stop when the top/bottom is reached. Moving the point up or down is
exactly what I /don't/ want when I enable scroll-lock-mode. Whether the
point should move left or right when scroll-lock-mode is enabled, or if
the buffer contents should be scrolled right or left, should be
configurable.
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* what to require (was: Re: prevent scroll-lock-mode from scrolling?)
2016-06-17 22:40 ` Stefan Monnier
@ 2016-06-18 1:19 ` Emanuel Berg
0 siblings, 0 replies; 19+ messages in thread
From: Emanuel Berg @ 2016-06-18 1:19 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca>
writes:
>> What about cl-extra?
>
> Same thing.
Perhaps this could be made a waring
when compiling?
Because, when I use a function, then compile,
it says that function isn't known to be
defined, I do `C-h f', find the source, go to
the end of the file, and if it says
(provide 'cl-macs)
that is what I `require'.
I don't know what other people do but it seems
like a straightforward way. Perhaps this is the
exception to the rule?
--
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
- so far: 51 Blogomatic articles -
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-17 23:10 ` lee
@ 2016-06-18 8:38 ` Eli Zaretskii
2016-06-19 23:54 ` lee
0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2016-06-18 8:38 UTC (permalink / raw)
To: help-gnu-emacs
> From: lee <lee@yagibdah.de>
> Date: Sat, 18 Jun 2016 01:10:55 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> From: lee <lee@yagibdah.de>
> >> Date: Fri, 17 Jun 2016 03:12:15 +0200
> >>
> >> is there a way to prevent the point from moving up or down when
> >> scroll-lock-mode is enabled and the contents of the buffer have been
> >> scrolled so far as for the first or the last line to reach the top or
> >> the bottom of the frame, respectively?
> >>
> >> It pretty much defeats the idea of this mode when the point moves
> >> nonetheless after scrolling for a bit, since I would use this mode to
> >> keep the point in its very place when scrolling.
> >
> > AFAIU, that's exactly the point of this minor mode. If you don't like
> > it, I suggest not to turn on the mode.
>
> Well, what happens when you turn it on and your scrolling reaches the
> end of the buffer?
>
> The point moves towards the end of the buffer rather than that the
> buffer contents are scrolled up.
Yes, as I'd expect. I'm still not sure I understand why is that a
problem in your case.
> >> Thinking of this, is there a kinda complementary mode, or an option, to
> >> scroll-lock-mode, which would move the point together with the contents
> >> of the buffer when I scroll?
> >
> > That's what happens by default, so I don't think I understand what are
> > you looking for. Perhaps consider telling more about the feature you
> > want to have.
>
> You must somehow be scrolling very differently from how I scroll.
No, the problem is that your terminology is very different from what
we use in Emacs. When you say "point moves", the usual meaning of
this is that point changes its buffer position. But what you actually
mean is "cursor changes its screen position".
> Or perhaps I shouldn't say "scroll" but "move the point" instead. When
> scroll-lock-mode is enabled and you move the point up or down (C-p or
> C-n), the buffer contents are scrolled down or up, respectively, while
> the point remains in one place.
No, point does change its buffer position, but the screen coordinates
of the cursor are kept constant as much as possible.
> Yet when you come close to the top or the end of the buffer, the
> point /does/ suddenly move up or down as if scroll-lock-mode was
> disabled. That's what defeats the scroll-lock-mode entirely.
>
> I'd even say it's a bug, and that scrolling the buffer contents must
> stop when the top/bottom is reached. Moving the point up or down is
> exactly what I /don't/ want when I enable scroll-lock-mode. Whether the
> point should move left or right when scroll-lock-mode is enabled, or if
> the buffer contents should be scrolled right or left, should be
> configurable.
That might make sense in some use cases of view-mode (and even then
might get in the way), but not in a general-purpose editable buffer,
IMO. It means some buffer positions are unreachable by
vertical-motion commands.
I still don't understand why the current behavior is a problem. If
that's because it affects cursor position for future scrolls, you can
change that by cursor motion commands like C-f, C-b, M-f, M-b, etc.,
before you commence scrolling.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-18 8:38 ` Eli Zaretskii
@ 2016-06-19 23:54 ` lee
2016-06-20 8:33 ` tomas
` (2 more replies)
0 siblings, 3 replies; 19+ messages in thread
From: lee @ 2016-06-19 23:54 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
>> From: lee <lee@yagibdah.de>
>> Date: Sat, 18 Jun 2016 01:10:55 +0200
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> >> From: lee <lee@yagibdah.de>
>> >> Date: Fri, 17 Jun 2016 03:12:15 +0200
>> >>
>> >> is there a way to prevent the point from moving up or down when
>> >> scroll-lock-mode is enabled and the contents of the buffer have been
>> >> scrolled so far as for the first or the last line to reach the top or
>> >> the bottom of the frame, respectively?
>> >>
>> >> It pretty much defeats the idea of this mode when the point moves
>> >> nonetheless after scrolling for a bit, since I would use this mode to
>> >> keep the point in its very place when scrolling.
>> >
>> > AFAIU, that's exactly the point of this minor mode. If you don't like
>> > it, I suggest not to turn on the mode.
>>
>> Well, what happens when you turn it on and your scrolling reaches the
>> end of the buffer?
>>
>> The point moves towards the end of the buffer rather than that the
>> buffer contents are scrolled up.
>
> Yes, as I'd expect. I'm still not sure I understand why is that a
> problem in your case.
I turn on scroll-lock-mode to keep the point where it is and don't want
it to move. Why would I expect it to move nonetheless?
>> >> Thinking of this, is there a kinda complementary mode, or an option, to
>> >> scroll-lock-mode, which would move the point together with the contents
>> >> of the buffer when I scroll?
>> >
>> > That's what happens by default, so I don't think I understand what are
>> > you looking for. Perhaps consider telling more about the feature you
>> > want to have.
>>
>> You must somehow be scrolling very differently from how I scroll.
>
> No, the problem is that your terminology is very different from what
> we use in Emacs. When you say "point moves", the usual meaning of
> this is that point changes its buffer position. But what you actually
> mean is "cursor changes its screen position".
I was assuming that 'point' means the position where letters appear when
I type, i. e. where the cursor is.
>> Or perhaps I shouldn't say "scroll" but "move the point" instead. When
>> scroll-lock-mode is enabled and you move the point up or down (C-p or
>> C-n), the buffer contents are scrolled down or up, respectively, while
>> the point remains in one place.
>
> No, point does change its buffer position, but the screen coordinates
> of the cursor are kept constant as much as possible.
That is probably the same :)
>> Yet when you come close to the top or the end of the buffer, the
>> point /does/ suddenly move up or down as if scroll-lock-mode was
>> disabled. That's what defeats the scroll-lock-mode entirely.
>>
>> I'd even say it's a bug, and that scrolling the buffer contents must
>> stop when the top/bottom is reached. Moving the point up or down is
>> exactly what I /don't/ want when I enable scroll-lock-mode. Whether the
>> point should move left or right when scroll-lock-mode is enabled, or if
>> the buffer contents should be scrolled right or left, should be
>> configurable.
>
> That might make sense in some use cases of view-mode (and even then
> might get in the way), but not in a general-purpose editable buffer,
> IMO. It means some buffer positions are unreachable by
> vertical-motion commands.
They won't be unreachable because you can always turn off
scroll-lock-mode and move the cursor around.
> I still don't understand why the current behavior is a problem. If
> that's because it affects cursor position for future scrolls, you can
> change that by cursor motion commands like C-f, C-b, M-f, M-b, etc.,
> before you commence scrolling.
I'm afraid I don't understand how you don't understand this. The
problem is that the cursor moves when it shouldn't. Maybe it helps to
distinguish between different types of cursor positions:
The position of the cursor /within the buffer/ is irrelevant for where
it is /on the screen/. It is relevant to me where the cursor is /on the
screen/ and /which buffer contents/ are around this screen position
(because I want to see them). It is pretty much irrelevant at which
position /within the buffer/ the contents I want to see are. I need
them displayed on the screen in a desirable way, and when programming,
the order and content of the lines I'm looking at are most of the time
much more important than it is where within the buffer they are. (It
doesn't matter whether a function 'foo' is at line 500 or at line 5000
as long as it is declared before being used (which isn't required, but
it is what I do.))
Now the cursor is already at a desired position /on the screen/ when I
enable scroll-lock-mode and start scrolling. I need the cursor to
remain at this screen position while I'm scrolling. I wouldn't enable
scroll-lock-mode to keep the cursor where I don't want it to be.
If I wanted to move the cursor to a desired position /within the
buffer/, I wouldn't enable scroll-lock-mode and move it there (and then
perhaps press C-l to get it to a desirable position /on the screen/ as
well).
Does that make some sense?
Can you explain to me why the cursor remains at its position /on the
screen/ while I'm scrolling with scroll-lock-mode enabled all the time
like it should --- and then suddenly moves when the top or bottom of the
buffer contents come into view? That doesn't make any sense to me; the
cursor still shouldn't move. I intentionally fixed it by enabling
scroll-lock-mode.
It's like you're driving a car, and every time you come close to your
destination, the car suddenly decides to go off road and forces you to
somehow steer it back onto the road, or to stop driving once you're
close enough so it doesn't go off road.
The position of the car within the universe is irrelevant for this. It
only needs to stay on the road. I do not want to move the car to a
particular position between my starting point and the destination (or
anywhere else) before I start driving. I start to drive where the car
is.
For the fun of it, imagine that the car had a drive-lock-mode. The car
would remain at a fixed position and the earth (or universe) would spool
away under it until it reaches its destination when you enable the
drive-lock-mode. You're happy with where the car currently is, so you
enable the drive-lock-mode and start driving. But alas, the
drive-lock-mode is buggy in that the car suddenly moves when it
approaches either it's destination or its starting point. The car
moving just isn't what you wanted, and it is like the opposite of what
the drive-lock-mode should do.
Scroll-lock-mode does that to me.
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-19 23:54 ` lee
@ 2016-06-20 8:33 ` tomas
2016-06-20 14:32 ` lee
2016-06-20 10:05 ` Dmitry Alexandrov
2016-06-20 14:34 ` Eli Zaretskii
2 siblings, 1 reply; 19+ messages in thread
From: tomas @ 2016-06-20 8:33 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Jun 20, 2016 at 01:54:02AM +0200, lee wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
[...]
> > No, the problem is that your terminology is very different from what
> > we use in Emacs. When you say "point moves", the usual meaning of
> > this is that point changes its buffer position. But what you actually
> > mean is "cursor changes its screen position".
>
> I was assuming that 'point' means the position where letters appear when
> I type, i. e. where the cursor is.
Yes, but the question is "relative to what"?
Q: where are you?
A: I'm here, in the middle of the living room
Now, if the question came from an intergalactic starship zipping
around at 0.95c, one would have to take Earth's exquisite dance
around itself, around the Sun, Sun's dance around... you get the
idea.
[...]
> The position of the cursor /within the buffer/ is irrelevant for where
> it is /on the screen/. It is relevant to me where the cursor is /on the
> screen/ and /which buffer contents/ are around this screen position
> (because I want to see them). It is pretty much irrelevant at which
> position /within the buffer/ the contents I want to see are. I need
> them displayed on the screen in a desirable way, and when programming,
> the order and content of the lines I'm looking at are most of the time
> much more important than it is where within the buffer they are. (It
> doesn't matter whether a function 'foo' is at line 500 or at line 5000
> as long as it is declared before being used (which isn't required, but
> it is what I do.))
The only sense I can make of that is: you don't want point to move
relative to the window *and* you don't want window to move relative
to buffer.
I know you can't mean that. At least it doesn't make sense to me,
because it would inhibit any movement. So I must be misundertanding
you.
regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAldnqmgACgkQBcgs9XrR2kYepACfVwqOXafH0GW2Lzd2GIiWWdUK
hSIAniP6N4aysyOfW43P87xW6SBJqtns
=ljbq
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-19 23:54 ` lee
2016-06-20 8:33 ` tomas
@ 2016-06-20 10:05 ` Dmitry Alexandrov
2016-06-20 15:24 ` lee
2016-06-20 14:34 ` Eli Zaretskii
2 siblings, 1 reply; 19+ messages in thread
From: Dmitry Alexandrov @ 2016-06-20 10:05 UTC (permalink / raw)
lee <lee@yagibdah.de> writes:
> Can you explain to me why the cursor remains at its position /on the
> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
> like it should --- and then suddenly moves when the top or bottom of the
> buffer contents come into view? That doesn't make any sense to me; the
> cursor still shouldn't move.
Given that there is no free space before the first line of a buffer,
this does make perfect sense with regard to scrolling backward (to the
top of a buffer). The other way we would just get stuck with the point
in the middle of a screen not being able to reach first lines. The
scrolling forward behaves the same way for sake of coherence, I guess.
Anyway, if you look into the code, you’ll see that this behaviour is
definetely intentional:
(defun scroll-lock-next-line (&optional arg)
"Scroll up ARG lines keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
(scroll-lock-update-goal-column)
(if (pos-visible-in-window-p (point-max))
(forward-line arg)
(scroll-up arg))
(scroll-lock-move-to-column scroll-lock-temporary-goal-column))
(defun scroll-lock-previous-line (&optional arg)
"Scroll up ARG lines keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
(scroll-lock-update-goal-column)
(condition-case nil
(scroll-down arg)
(beginning-of-buffer (forward-line (- arg))))
(scroll-lock-move-to-column scroll-lock-temporary-goal-column))
However, if you do not like it, just remove the condition:
(defun my-scroll-lock-next-line (&optional arg)
"Scroll up ARG lines keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
(scroll-lock-update-goal-column)
(scroll-up arg)
(scroll-lock-move-to-column scroll-lock-temporary-goal-column))
(defun my-scroll-lock-previous-line (&optional arg)
"Scroll up ARG lines keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
(scroll-lock-update-goal-column)
(scroll-down arg)
(scroll-lock-move-to-column scroll-lock-temporary-goal-column))
(advice-add 'scroll-lock-next-line :override #'my-scroll-lock-next-line)
(advice-add 'scroll-lock-previous-line :override #'my-scroll-lock-previous-line)
Also, if you are regularily toggling the ‘scroll-lock-mode’ on and off,
you might consider to use approach that, one might say, is more
‘Emacsish’ — another keychord instead of mode:
(setq scroll-preserve-screen-position 'always)
(global-set-key (kbd "M-n") #'scroll-up-line)
(global-set-key (kbd "M-<down>") #'scroll-up-line)
(global-set-key (kbd "M-p") #'scroll-down-line)
(global-set-key (kbd "M-<up>") #'scroll-down-line)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-20 8:33 ` tomas
@ 2016-06-20 14:32 ` lee
0 siblings, 0 replies; 19+ messages in thread
From: lee @ 2016-06-20 14:32 UTC (permalink / raw)
To: help-gnu-emacs
<tomas@tuxteam.de> writes:
> On Mon, Jun 20, 2016 at 01:54:02AM +0200, lee wrote:
>> Eli Zaretskii <eliz@gnu.org> writes:
> [...]
>
>> The position of the cursor /within the buffer/ is irrelevant for where
>> it is /on the screen/. It is relevant to me where the cursor is /on the
>> screen/ and /which buffer contents/ are around this screen position
>> (because I want to see them). It is pretty much irrelevant at which
>> position /within the buffer/ the contents I want to see are. I need
>> them displayed on the screen in a desirable way, and when programming,
>> the order and content of the lines I'm looking at are most of the time
>> much more important than it is where within the buffer they are. (It
>> doesn't matter whether a function 'foo' is at line 500 or at line 5000
>> as long as it is declared before being used (which isn't required, but
>> it is what I do.))
>
> The only sense I can make of that is: you don't want point to move
> relative to the window *and* you don't want window to move relative
> to buffer.
>
> I know you can't mean that. At least it doesn't make sense to me,
> because it would inhibit any movement. So I must be misundertanding
> you.
So you get the idea: I want the buffer contents to move relative to the
window and relative to the cursor without the cursor and without the
window moving. Suppose the window is the universe; the universe doesn't
move.
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-19 23:54 ` lee
2016-06-20 8:33 ` tomas
2016-06-20 10:05 ` Dmitry Alexandrov
@ 2016-06-20 14:34 ` Eli Zaretskii
2016-06-20 21:21 ` lee
2 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2016-06-20 14:34 UTC (permalink / raw)
To: help-gnu-emacs
> From: lee <lee@yagibdah.de>
> Date: Mon, 20 Jun 2016 01:54:02 +0200
>
> I turn on scroll-lock-mode to keep the point where it is and don't want
> it to move. Why would I expect it to move nonetheless?
Because some buffer positions would be unreachable otherwise.
> I was assuming that 'point' means the position where letters appear when
> I type, i. e. where the cursor is.
No, point is _buffer_ position where insertion happens. It isn't a
screen position.
> > That might make sense in some use cases of view-mode (and even then
> > might get in the way), but not in a general-purpose editable buffer,
> > IMO. It means some buffer positions are unreachable by
> > vertical-motion commands.
>
> They won't be unreachable because you can always turn off
> scroll-lock-mode and move the cursor around.
Yes, but turning the mode on and off is an annoyance.
> Can you explain to me why the cursor remains at its position /on the
> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
> like it should --- and then suddenly moves when the top or bottom of the
> buffer contents come into view?
See above: Emacs attempts to let you reach the buffer text below the
cursor position.
> Scroll-lock-mode does that to me.
I understand; this just means scroll-lock-mode is not doing what you
want, it's doing something else. Maybe someone will extend it to do
what you want, or maybe there's already a similar mode that does.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-20 10:05 ` Dmitry Alexandrov
@ 2016-06-20 15:24 ` lee
2016-06-20 16:12 ` Dmitry Alexandrov
0 siblings, 1 reply; 19+ messages in thread
From: lee @ 2016-06-20 15:24 UTC (permalink / raw)
To: help-gnu-emacs
Dmitry Alexandrov <321942@gmail.com> writes:
> lee <lee@yagibdah.de> writes:
>> Can you explain to me why the cursor remains at its position /on the
>> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
>> like it should --- and then suddenly moves when the top or bottom of the
>> buffer contents come into view? That doesn't make any sense to me; the
>> cursor still shouldn't move.
>
> Given that there is no free space before the first line of a buffer,
> this does make perfect sense with regard to scrolling backward (to the
> top of a buffer). The other way we would just get stuck with the point
> in the middle of a screen not being able to reach first lines. The
> scrolling forward behaves the same way for sake of coherence, I guess.
There is no free space beyond the last line of a buffer, either.
It doesn't make sense, though, because scroll-lock means that the cursor
does not move when scrolling. Why else would I use scroll-lock-mode?
> Anyway, if you look into the code, you’ll see that this behaviour is
> definetely intentional:
>
> (defun scroll-lock-next-line (&optional arg)
> "Scroll up ARG lines keeping point fixed."
> (interactive "p")
> (or arg (setq arg 1))
> (scroll-lock-update-goal-column)
> (if (pos-visible-in-window-p (point-max))
> (forward-line arg)
> (scroll-up arg))
> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
>
> (defun scroll-lock-previous-line (&optional arg)
> "Scroll up ARG lines keeping point fixed."
> (interactive "p")
> (or arg (setq arg 1))
> (scroll-lock-update-goal-column)
> (condition-case nil
> (scroll-down arg)
> (beginning-of-buffer (forward-line (- arg))))
> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
"Scroll up ARG lines keeping point fixed.": It doesn't keep point fixed
(as I expect) but moves it when the end or start of buffer are near
(which defeats the mode).
> However, if you do not like it, just remove the condition:
>
> (defun my-scroll-lock-next-line (&optional arg)
> "Scroll up ARG lines keeping point fixed."
> (interactive "p")
> (or arg (setq arg 1))
> (scroll-lock-update-goal-column)
> (scroll-up arg)
> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
>
> (defun my-scroll-lock-previous-line (&optional arg)
> "Scroll up ARG lines keeping point fixed."
> (interactive "p")
> (or arg (setq arg 1))
> (scroll-lock-update-goal-column)
> (scroll-down arg)
> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
>
> (advice-add 'scroll-lock-next-line :override #'my-scroll-lock-next-line)
> (advice-add 'scroll-lock-previous-line :override #'my-scroll-lock-previous-line)
Thank you very much! That does the trick --- and I just found out that
I have scroll-preserve-screen-position set to t and forgot about it ages
ago. The result of that is pretty much what scroll-lock-mode is
supposed to do.
I guess I'm a bit confused because emacs at work and emacs at home are
configured differently. I should be fine when I set
scroll-preserve-screen-position to t at work, too.
> Also, if you are regularily toggling the ‘scroll-lock-mode’ on and off,
> you might consider to use approach that, one might say, is more
> ‘Emacsish’ — another keychord instead of mode:
>
> (setq scroll-preserve-screen-position 'always)
> (global-set-key (kbd "M-n") #'scroll-up-line)
> (global-set-key (kbd "M-<down>") #'scroll-up-line)
> (global-set-key (kbd "M-p") #'scroll-down-line)
> (global-set-key (kbd "M-<up>") #'scroll-down-line)
The idea was to make use of the ScrollLock key. So I did that and found
that when scroll-lock-mode is enabled, the point does move when it
shouldn't.
Since what scroll-lock-mode does is achieved by setting
scroll-preserve-screen-position to t, what is the point or purpose of
scroll-lock-mode? That the cursor moves when it shouldn't?
BTW, it seems that changing scroll-preserve-screen-position requires
restarting emacs to take effect. Maybe that's what scroll-lock-mode is
for, being able to change the behaviour without restarting?
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-20 15:24 ` lee
@ 2016-06-20 16:12 ` Dmitry Alexandrov
2016-06-20 19:50 ` lee
0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Alexandrov @ 2016-06-20 16:12 UTC (permalink / raw)
To: lee; +Cc: help-gnu-emacs
lee <lee@yagibdah.de> writes:
> Dmitry Alexandrov <321942@gmail.com> writes:
>
>> lee <lee@yagibdah.de> writes:
>>> Can you explain to me why the cursor remains at its position /on the
>>> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
>>> like it should --- and then suddenly moves when the top or bottom of the
>>> buffer contents come into view? That doesn't make any sense to me; the
>>> cursor still shouldn't move.
>>
>> Given that there is no free space before the first line of a buffer,
>> this does make perfect sense with regard to scrolling backward (to the
>> top of a buffer). The other way we would just get stuck with the point
>> in the middle of a screen not being able to reach first lines. The
>> scrolling forward behaves the same way for sake of coherence, I guess.
>
> There is no free space beyond the last line of a buffer, either.
Well, by default in GNU Emacs there *is* free space beyond the last
line, which is taken in account while scrolling. I have no idea how
could you disabled it. Actually I would like to see some day an
opposite option in GNU Emacs — to enable empty lines above the top of a
buffer.
> It doesn't make sense, though, because scroll-lock means that the cursor
> does not move when scrolling. Why else would I use scroll-lock-mode?
As far as I understand, minor modes for Emacs are generally designed to
be used on permanent basis, not to be toggled every several keystrokes.
Since the algorithm you described prevents user from accessing to first
N lines of buffer, this algorithm would be perceived as broken.
>> However, if you do not like it, just remove the condition:
>>
>> (defun my-scroll-lock-next-line (&optional arg)
>> "Scroll up ARG lines keeping point fixed."
>> (interactive "p")
>> (or arg (setq arg 1))
>> (scroll-lock-update-goal-column)
>> (scroll-up arg)
>> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
>>
>> (defun my-scroll-lock-previous-line (&optional arg)
>> "Scroll up ARG lines keeping point fixed."
>> (interactive "p")
>> (or arg (setq arg 1))
>> (scroll-lock-update-goal-column)
>> (scroll-down arg)
>> (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
>>
>> (advice-add 'scroll-lock-next-line :override #'my-scroll-lock-next-line)
>> (advice-add 'scroll-lock-previous-line :override #'my-scroll-lock-previous-line)
>
> Thank you very much! That does the trick
You are welcome.
> and I just found out that
> I have scroll-preserve-screen-position set to t and forgot about it ages
> ago. The result of that is pretty much what scroll-lock-mode is
> supposed to do.
>
> I guess I'm a bit confused because emacs at work and emacs at home are
> configured differently. I should be fine when I set
> scroll-preserve-screen-position to t at work, too.
Or maybe even to ‘always’ (or whatever you want to call it).
>> Also, if you are regularily toggling the ‘scroll-lock-mode’ on and off,
>> you might consider to use approach that, one might say, is more
>> ‘Emacsish’ — another keychord instead of mode:
>>
>> (setq scroll-preserve-screen-position 'always)
>> (global-set-key (kbd "M-n") #'scroll-up-line)
>> (global-set-key (kbd "M-<down>") #'scroll-up-line)
>> (global-set-key (kbd "M-p") #'scroll-down-line)
>> (global-set-key (kbd "M-<up>") #'scroll-down-line)
>
> The idea was to make use of the ScrollLock key. So I did that and found
> that when scroll-lock-mode is enabled, the point does move when it
> shouldn't.
>
> Since what scroll-lock-mode does is achieved by setting
> scroll-preserve-screen-position to t, what is the point or purpose of
> scroll-lock-mode? That the cursor moves when it shouldn't?
First of all, I would not say that there is something wrong even with
existence of a minor mode that only toggles single variable. However
you might notice that besides toggling ‘scroll-preserve-screen-position’
‘scroll-lock-mode’ at least re-defines several moving keys: ‘C-n’, ‘C-p’, etc.
> BTW, it seems that changing scroll-preserve-screen-position requires
> restarting emacs to take effect.
No.
> Maybe that's what scroll-lock-mode is
> for, being able to change the behaviour without restarting?
As you already noticed, ‘scroll-lock-mode’ depends on state of
‘scroll-preserve-screen-position’. How then could it evade such a
limitation if it existed?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-20 16:12 ` Dmitry Alexandrov
@ 2016-06-20 19:50 ` lee
0 siblings, 0 replies; 19+ messages in thread
From: lee @ 2016-06-20 19:50 UTC (permalink / raw)
To: help-gnu-emacs
Dmitry Alexandrov <321942@gmail.com> writes:
> lee <lee@yagibdah.de> writes:
>
>> Dmitry Alexandrov <321942@gmail.com> writes:
>>
>>> lee <lee@yagibdah.de> writes:
>>>> Can you explain to me why the cursor remains at its position /on the
>>>> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
>>>> like it should --- and then suddenly moves when the top or bottom of the
>>>> buffer contents come into view? That doesn't make any sense to me; the
>>>> cursor still shouldn't move.
>>>
>>> Given that there is no free space before the first line of a buffer,
>>> this does make perfect sense with regard to scrolling backward (to the
>>> top of a buffer). The other way we would just get stuck with the point
>>> in the middle of a screen not being able to reach first lines. The
>>> scrolling forward behaves the same way for sake of coherence, I guess.
>>
>> There is no free space beyond the last line of a buffer, either.
>
> Well, by default in GNU Emacs there *is* free space beyond the last
> line, which is taken in account while scrolling. I have no idea how
> could you disabled it.
Err, yes, I shouldn't have said it this way. I mean there's no free
space, only whatever emacs uses to fill parts of the display there are
no buffer contents such parts could otherwise be filled with.
Inconsistently, emacs fills only what it considers as "below" of buffer
contents with non-buffer-contents.
> Actually I would like to see some day an opposite option in GNU Emacs
> — to enable empty lines above the top of a buffer.
I'd like that, too. It would make things consistent.
>> It doesn't make sense, though, because scroll-lock means that the cursor
>> does not move when scrolling. Why else would I use scroll-lock-mode?
>
> As far as I understand, minor modes for Emacs are generally designed to
> be used on permanent basis, not to be toggled every several keystrokes.
> Since the algorithm you described prevents user from accessing to first
> N lines of buffer, this algorithm would be perceived as broken.
Scroll-lock-mode shouldn't have been implemented as a minor mode then,
or be given a different name. Not that I'd press the ScrollLock key
every few keystrokes, though.
> [...]
>
>>> Also, if you are regularily toggling the ‘scroll-lock-mode’ on and off,
>>> you might consider to use approach that, one might say, is more
>>> ‘Emacsish’ — another keychord instead of mode:
>>>
>>> (setq scroll-preserve-screen-position 'always)
>>> (global-set-key (kbd "M-n") #'scroll-up-line)
>>> (global-set-key (kbd "M-<down>") #'scroll-up-line)
>>> (global-set-key (kbd "M-p") #'scroll-down-line)
>>> (global-set-key (kbd "M-<up>") #'scroll-down-line)
>>
>> The idea was to make use of the ScrollLock key. So I did that and found
>> that when scroll-lock-mode is enabled, the point does move when it
>> shouldn't.
>>
>> Since what scroll-lock-mode does is achieved by setting
>> scroll-preserve-screen-position to t, what is the point or purpose of
>> scroll-lock-mode? That the cursor moves when it shouldn't?
>
> First of all, I would not say that there is something wrong even with
> existence of a minor mode that only toggles single variable. However
> you might notice that besides toggling ‘scroll-preserve-screen-position’
> ‘scroll-lock-mode’ at least re-defines several moving keys: ‘C-n’, ‘C-p’, etc.
I'm wondering why a whole mode should be needed when what the mode does
can be done by just changing a single variable instead. And why would
it do more than doing just that?
>> BTW, it seems that changing scroll-preserve-screen-position requires
>> restarting emacs to take effect.
>
> No.
You mean it does take effect without restarting when you try it?
>> Maybe that's what scroll-lock-mode is
>> for, being able to change the behaviour without restarting?
>
> As you already noticed, ‘scroll-lock-mode’ depends on state of
> ‘scroll-preserve-screen-position’. How then could it evade such a
> limitation if it existed?
Why would it do more than changing the variable if changing it would
take effect without any further ado?
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: prevent scroll-lock-mode from scrolling?
2016-06-20 14:34 ` Eli Zaretskii
@ 2016-06-20 21:21 ` lee
0 siblings, 0 replies; 19+ messages in thread
From: lee @ 2016-06-20 21:21 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
>> From: lee <lee@yagibdah.de>
>> Date: Mon, 20 Jun 2016 01:54:02 +0200
>>
>> I turn on scroll-lock-mode to keep the point where it is and don't want
>> it to move. Why would I expect it to move nonetheless?
>
> Because some buffer positions would be unreachable otherwise.
I can reach them no problem when I press the ScrollLock key again to
turn off ScrollLock. That's what the key is for. Besides, why can't
emacs scroll the buffer contents to where the cursor is no matter
whether the top or bottom of the buffer has come close?
Almost all buffer positions remain unreachable without pressing keys.
>> I was assuming that 'point' means the position where letters appear when
>> I type, i. e. where the cursor is.
>
> No, point is _buffer_ position where insertion happens. It isn't a
> screen position.
ok
Scrolling usually refers to screen positions, though.
>> > That might make sense in some use cases of view-mode (and even then
>> > might get in the way), but not in a general-purpose editable buffer,
>> > IMO. It means some buffer positions are unreachable by
>> > vertical-motion commands.
>>
>> They won't be unreachable because you can always turn off
>> scroll-lock-mode and move the cursor around.
>
> Yes, but turning the mode on and off is an annoyance.
It is much more annoying to turn on a mode that is supposed to prevent
the cursor from moving while scrolling just to find that the mode
doesn't do that.
>> Can you explain to me why the cursor remains at its position /on the
>> screen/ while I'm scrolling with scroll-lock-mode enabled all the time
>> like it should --- and then suddenly moves when the top or bottom of the
>> buffer contents come into view?
>
> See above: Emacs attempts to let you reach the buffer text below the
> cursor position.
That defeats scroll-lock-mode.
>> Scroll-lock-mode does that to me.
>
> I understand; this just means scroll-lock-mode is not doing what you
> want, it's doing something else. Maybe someone will extend it to do
> what you want, or maybe there's already a similar mode that does.
That it doesn't do what I want is one thing, that it doesn't do what it
supposedly should do is another. Let's see what it is supposed to do:
"Scroll-Lock minor mode[...]
When enabled, keys that normally move point by line or paragraph will
scroll the buffer by the respective amount of lines instead and point
will be kept vertically fixed relative to window boundaries during
scrolling."
Why would one want to keep the buffer position where insertions happen
at a fixed position which is relative to screen positions (only) while
scrolling? Insertions can easily happen off screen anyway, and it is
irrelevant for this whether the cursor can reach every buffer position
while scrolling or not.
I think the flaw comes from changing the key bindings. Changing them is
what makes screen positions unreachable by the cursor.
I guess I need to use the ScrollLock key as a modifier for cursor keys
so that they yield different symbols when ScrollLock is enabled, and
bind appropriate scrolling functions to these symbols in emacs. That
should do what I want.
--
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, X toolkit)
of 2016-03-18 on heimdali
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2016-06-20 21:21 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 1:12 prevent scroll-lock-mode from scrolling? lee
2016-06-17 1:25 ` Emanuel Berg
2016-06-17 4:14 ` Stefan Monnier
2016-06-17 6:00 ` Emanuel Berg
2016-06-17 22:40 ` Stefan Monnier
2016-06-18 1:19 ` what to require (was: Re: prevent scroll-lock-mode from scrolling?) Emanuel Berg
2016-06-17 22:47 ` prevent scroll-lock-mode from scrolling? lee
2016-06-17 6:47 ` Eli Zaretskii
2016-06-17 23:10 ` lee
2016-06-18 8:38 ` Eli Zaretskii
2016-06-19 23:54 ` lee
2016-06-20 8:33 ` tomas
2016-06-20 14:32 ` lee
2016-06-20 10:05 ` Dmitry Alexandrov
2016-06-20 15:24 ` lee
2016-06-20 16:12 ` Dmitry Alexandrov
2016-06-20 19:50 ` lee
2016-06-20 14:34 ` Eli Zaretskii
2016-06-20 21:21 ` lee
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).