all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch for beginning-of-visual-line and end-of-visual-line
@ 2017-08-11 17:24 Justin Burkett
  2017-08-11 18:41 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Justin Burkett @ 2017-08-11 17:24 UTC (permalink / raw)
  To: emacs-devel

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.



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

end of thread, other threads:[~2017-08-12 13:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-11 17:24 Patch for beginning-of-visual-line and end-of-visual-line Justin Burkett
2017-08-11 18:41 ` 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

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.