From: Ralf Angeli <angeli@caeruleus.net>
To: emacs-devel@gnu.org
Subject: Re: scroll-lock-mode and goal-column
Date: Mon, 30 Jun 2008 22:31:08 +0200 [thread overview]
Message-ID: <g4bfqc$fh0$1@ger.gmane.org> (raw)
In-Reply-To: jwvskuwcbu8.fsf-monnier+emacs@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]
* Stefan Monnier (2008-06-29) writes:
>> Can I make the C code acquainted with the functions of scroll-lock.el?
>
> Not directly, no. Maybe we should add a variable for that.
> Othrwise, you can either set this-command to `scroll-up' (since it's
> later on mvoes to last-command), or you can let-bind last-command
> appropriately around the calls to scroll-up/down.
>
>> If this is what would remedy the situation. I'm a bit confused because
>> in scroll-lock.el, the goal column is updated if `last-command' is _not_
>> among the scrolling functions.
>
> updated = changed = not preserved.
Ugh, I should stop answering messages when in a hurry.
>> And if I open the raw dir file the behavior is even worse, meaning
>> point will not jump back into the previous column at all once it got
>> stuck to column 0.
>
> I actually much prefer this behavior because it's consistent with the
> simple `last-command' problem, so it should be easy to fix.
I'm not sure what to let-bind `last-command' to, but setting
`this-command' seems to work. (See attached patch. No ChangeLog entry,
because I don't think this should be applied.)
The only problem now is that once the `forward-line' movement kicks in
at the start or end of a buffer, point will be moved to column 0 again.
However, I'd prefer the column to be preserved. Since this behavior of
`forward-line' is by design, I'm not sure if we can get rid of the
manual preservation of the goal column. `vertical-motion' obviously has
a similar behavior and I did not find an alternative function for moving
by lines that keeps the goal column, nor did I find an option which
could be set in order for `forward-line' to change behavior.
--
Ralf
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: scroll-lock.patch --]
[-- Type: text/x-diff, Size: 2972 bytes --]
Index: scroll-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/scroll-lock.el,v
retrieving revision 1.10
diff -u -r1.10 scroll-lock.el
--- scroll-lock.el 6 May 2008 07:57:49 -0000 1.10
+++ scroll-lock.el 30 Jun 2008 20:04:03 -0000
@@ -63,63 +63,44 @@
(setq scroll-preserve-screen-position
scroll-lock-preserve-screen-pos-save)))
-(defun scroll-lock-update-goal-column ()
- "Update `scroll-lock-temporary-goal-column' if necessary."
- (unless (memq last-command '(scroll-lock-next-line
- scroll-lock-previous-line
- scroll-lock-forward-paragraph
- scroll-lock-backward-paragraph))
- (setq scroll-lock-temporary-goal-column (current-column))))
-
-(defun scroll-lock-move-to-column (column)
- "Like `move-to-column' but cater for wrapped lines."
- (if (or (bolp)
- ;; Start of a screen line.
- (not (zerop (mod (- (point) (line-beginning-position))
- (window-width)))))
- (move-to-column column)
- (forward-char (min column (- (line-end-position) (point))))))
-
(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))
+ (scroll-up arg)
+ (setq this-command 'scroll-up)))
(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))
+ (progn
+ (scroll-down arg)
+ (setq this-command 'scroll-down))
+ (beginning-of-buffer (forward-line (- arg)))))
(defun scroll-lock-forward-paragraph (&optional arg)
"Scroll down ARG paragraphs keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
- (scroll-lock-update-goal-column)
(scroll-up (count-screen-lines (point) (save-excursion
(forward-paragraph arg)
(point))))
- (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
+ (setq this-command 'scroll-up))
(defun scroll-lock-backward-paragraph (&optional arg)
"Scroll up ARG paragraphs keeping point fixed."
(interactive "p")
(or arg (setq arg 1))
- (scroll-lock-update-goal-column)
(let ((goal (save-excursion (backward-paragraph arg) (point))))
(condition-case nil
- (scroll-down (count-screen-lines goal (point)))
- (beginning-of-buffer (goto-char goal))))
- (scroll-lock-move-to-column scroll-lock-temporary-goal-column))
+ (progn
+ (scroll-down (count-screen-lines goal (point)))
+ (setq this-command 'scroll-down))
+ (beginning-of-buffer (goto-char goal)))))
(provide 'scroll-lock)
next prev parent reply other threads:[~2008-06-30 20:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-13 15:49 scroll-lock-mode and goal-column Stefan Monnier
2008-06-13 16:05 ` David Kastrup
2008-06-13 17:50 ` Stefan Monnier
2008-06-29 14:33 ` Ralf Angeli
2008-06-29 17:51 ` Stefan Monnier
2008-06-29 18:10 ` Ralf Angeli
2008-06-29 19:03 ` Stefan Monnier
2008-06-30 20:31 ` Ralf Angeli [this message]
2008-07-03 22:10 ` Stefan Monnier
2008-07-20 19:49 ` Ralf Angeli
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='g4bfqc$fh0$1@ger.gmane.org' \
--to=angeli@caeruleus.net \
--cc=emacs-devel@gnu.org \
/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 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).