From: Karl Chen <Karl.Chen@quarl.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: alp.tekin.aker@gmail.com, Emacs Developement List <emacs-devel@gnu.org>
Subject: Bug in vertical-motion vs overlay with display property
Date: Fri, 12 Apr 2013 19:34:24 -0400 [thread overview]
Message-ID: <quack.20130412T1934.87txnb5nnj@honk.quarl.org> (raw)
Hi Eli/Emacs-devel,
I believe I've discovered a small bug in `vertical-motion' in
indent.c. It affects movement past blank lines when there is an
overlay with a display/cursor property.
When using `fci-mode' from fill-column-indicator.el,
`previous-line' sometimes goes past two blank lines instead of
one.
Affected Emacs versions:
- Good: 24.2
- BAD: 24.3
- BAD: 24.3.50 as of 2013-04-08
1. One can reproduce the problem using fill-column-indicator.el:
$ wget https://raw.github.com/alpaker/Fill-Column-Indicator/master/fill-column-indicator.el
$ emacs -Q
M-x load-file fill-column-indicator.el
M-x fci-mode
<enter> <enter> <enter> <enter> <enter>
<up>
<up> ;; BAD: this moves up 2 lines instead of 1 line
2. I minimized the above down to the following self-contained test
case:
$ cat > aa.el <<EOF
(defun fci-redraw-region (start end _ignored)
(save-match-data
(save-excursion
(goto-char start)
(while
(search-forward "\n" end t)
(setq eol-str "X")
(setq o (make-overlay (match-beginning 0) (match-beginning 0)))
(overlay-put o 'after-string
(propertize eol-str 'display (propertize eol-str 'cursor t)))
))))
(add-hook 'after-change-functions 'fci-redraw-region)
(insert "\n\n\n\n")
(vertical-motion -1)
(vertical-motion -1)
(kill-emacs (+ 100 (line-number-at-pos)))
EOF
$ emacs-24.2 -nw -Q --load aa.el ; echo $?
103 # good
$ emacs-24.3 -nw -Q --load aa.el ; echo $?
102 # BAD
Note that `emacs --batch' doesn't reproduce the problem.
3. Using the above I bisected the changes between 24.2 and 24.3
down to the following commit:
commit b65a46be5055c338a9f8e7640ad97b8e592d5977
Refs: HEAD, refs/bisect/bad
Author: Eli Zaretskii <eliz@gnu.org>
AuthorDate: 2012-11-21 21:28:14 +0200
Commit: Eli Zaretskii <eliz@gnu.org>
CommitDate: 2012-11-21 21:28:14 +0200
Fix bug #12930 with vertical-motion through a display string.
src/indent.c (Fvertical_motion): If the starting position is covered
by a display string, return to one position before that, to avoid
overshooting it inside move_it_to.
---
src/ChangeLog | 6 ++++++
src/indent.c | 8 +++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 020948e..c51f58a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2012-11-21 Eli Zaretskii <eliz@gnu.org>
+
+ * indent.c (Fvertical_motion): If the starting position is covered
+ by a display string, return to one position before that, to avoid
+ overshooting it inside move_it_to. (Bug#12930)
+
2012-11-20 Daniel Colascione <dancol@dancol.org>
* w32fns.c (Fx_file_dialog):
diff --git a/src/indent.c b/src/indent.c
index bbc944d..3332228 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2057,7 +2057,13 @@ whether or not it is currently displayed in some window. */)
comment said this is "so we don't move too far" (2005-01-19
checkin by kfs). But this does nothing useful that I can
tell, and it causes Bug#2694 . -- cyd */
- move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+ /* When the position we started from is covered by a display
+ string, move_it_to will overshoot it, while vertical-motion
+ wants to put the cursor _before_ the display string. So in
+ that case, we move to buffer position before the display
+ string, and avoid overshooting. */
+ move_it_to (&it, disp_string_at_start_p ? PT - 1 : PT,
+ -1, -1, -1, MOVE_TO_POS);
/* IT may move too far if truncate-lines is on and PT lies
beyond the right margin. IT may also move too far if the
Thoughts?
Thanks,
Karl
next reply other threads:[~2013-04-12 23:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-12 23:34 Karl Chen [this message]
2013-04-13 9:03 ` Bug in vertical-motion vs overlay with display property Eli Zaretskii
2013-04-13 15:13 ` Karl Chen
2013-04-13 21:10 ` 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
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=quack.20130412T1934.87txnb5nnj@honk.quarl.org \
--to=karl.chen@quarl.org \
--cc=alp.tekin.aker@gmail.com \
--cc=eliz@gnu.org \
--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).