From 060ca4088d928e0808d13a551ea11b2fc00769d4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 8 May 2013 21:05:40 +0300 Subject: [PATCH] Avoid beginning/end of buffer errors when moving across display strings. lisp/simple.el (line-move-visual): Signal beginning/end of buffer only if vertical-motion moved less than it was requested. Avoids silly incorrect error messages when there are display strings with multiple newlines at EOL. --- lisp/ChangeLog | 7 +++++++ lisp/simple.el | 26 +++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index aded31287b6..1abcc933847 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-05-08 Eli Zaretskii + + * simple.el (line-move-visual): Signal beginning/end of buffer + only if vertical-motion moved less than it was requested. Avoids + silly incorrect error messages when there are display strings with + multiple newlines at EOL. + 2013-05-08 Stefan Monnier * progmodes/vera-mode.el (vera-underscore-is-part-of-word): diff --git a/lisp/simple.el b/lisp/simple.el index 103c2a4636c..e4bde7c358c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -4857,13 +4857,25 @@ lines." (frame-char-width)) hscroll)))))) (if target-hscroll (set-window-hscroll (selected-window) target-hscroll)) - (or (and (= (vertical-motion - (cons (or goal-column - (if (consp temporary-goal-column) - (car temporary-goal-column) - temporary-goal-column)) - arg)) - arg) + ;; vertical-motion can move more than it was asked to if it moves + ;; across display strings with newlines. We don't want to ring + ;; the bell and announce beginning/end of buffer in that case. + (or (and (or (and (>= arg 0) + (>= (vertical-motion + (cons (or goal-column + (if (consp temporary-goal-column) + (car temporary-goal-column) + temporary-goal-column)) + arg)) + arg)) + (and (< arg 0) + (<= (vertical-motion + (cons (or goal-column + (if (consp temporary-goal-column) + (car temporary-goal-column) + temporary-goal-column)) + arg)) + arg))) (or (>= arg 0) (/= (point) opoint) ;; If the goal column lies on a display string, -- 2.39.2