From: Justin Burkett <justin@burkett.cc>
To: emacs-devel@gnu.org
Subject: Patch for beginning-of-visual-line and end-of-visual-line
Date: Fri, 11 Aug 2017 13:24:54 -0400 [thread overview]
Message-ID: <CAF5dqNJbePryAuEe5_cZDHQnN=YRpb2ziUDY0oGtGzepnVQOEg@mail.gmail.com> (raw)
Hi,
I found (what seems like) a bug in these two functions. The docstrings
advertise that they should stop if they reach the beginning or end of
buffer and they don't. As a test cast, try
(beginning-of-visual-line 2)
in a buffer with one line. According to the docstring, point should be
at the end of the buffer, but it ends up at the beginning for me in
Emacs 25.2.1.
Here's a patch that works for me.
Justin
diff --git a/lisp/simple.el b/lisp/simple.el
index 3d23fc3..04d8030 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6682,9 +6682,10 @@ To ignore intangibility, bind
`inhibit-point-motion-hooks' to t."
(if (/= n 1)
(let ((line-move-visual t))
(line-move (1- n) t)))
- ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't
- ;; constrain to field boundaries, so we don't either.
- (vertical-motion (cons (window-width) 0)))
+ (unless (or (bobp) (eobp))
+ ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't
+ ;; constrain to field boundaries, so we don't either.
+ (vertical-motion (cons (window-width) 0))))
(defun beginning-of-visual-line (&optional n)
"Move point to beginning of current visual line.
@@ -6697,9 +6698,10 @@ To ignore intangibility, bind
`inhibit-point-motion-hooks' to t."
(if (/= n 1)
(let ((line-move-visual t))
(line-move (1- n) t)))
- (vertical-motion 0)
- ;; Constrain to field boundaries, like `move-beginning-of-line'.
- (goto-char (constrain-to-field (point) opoint (/= n 1)))))
+ (unless (or (bobp) (eobp))
+ (vertical-motion 0)
+ ;; Constrain to field boundaries, like `move-beginning-of-line'.
+ (goto-char (constrain-to-field (point) opoint (/= n 1))))))
(defun kill-visual-line (&optional arg)
"Kill the rest of the visual line.
next reply other threads:[~2017-08-11 17:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 17:24 Justin Burkett [this message]
2017-08-11 18:41 ` Patch for beginning-of-visual-line and end-of-visual-line Eli Zaretskii
2017-08-11 21:10 ` Justin Burkett
2017-08-12 6:35 ` Eli Zaretskii
2017-08-12 11:54 ` Justin Burkett
2017-08-12 12:13 ` Eli Zaretskii
2017-08-12 13:14 ` Justin Burkett
2017-08-12 13:18 ` Eli Zaretskii
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='CAF5dqNJbePryAuEe5_cZDHQnN=YRpb2ziUDY0oGtGzepnVQOEg@mail.gmail.com' \
--to=justin@burkett.cc \
--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 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.