From: Wolfgang Jenkner <wjenkner@inode.at>
To: 20701@debbugs.gnu.org
Subject: bug#20701: 25.0.50; [PATCH] (vertical-motion 0) broken at display strings after newline
Date: Sun, 31 May 2015 16:19:46 +0200 [thread overview]
Message-ID: <85y4k47qf6.fsf@iznogoud.viz> (raw)
If you run the following snippet in emacs -Q point will end up at the
first line of the "Test" buffer, but it should stay at the second line.
(with-current-buffer (generate-new-buffer "Test")
(pop-to-buffer (current-buffer))
(insert "x\n")
(save-excursion
(insert (propertize "x" 'display "x")))
(sit-for 1)
(vertical-motion 0))
On the other hand, non-zero arguments for vertical-motion seem to work
correctly, as long as the buffer contains only ASCII characters before
the propertized "x".
Otherwise
(with-current-buffer (generate-new-buffer "Test")
(pop-to-buffer (current-buffer))
(insert "\né\n")
(save-excursion
(insert (propertize "x" 'display "x")))
(sit-for 1)
(vertical-motion -1))
Here, point should go to the second line but it goes to the first line.
The following patch tries to fix both issues.
-- >8 --
Subject: [PATCH] * src/indent.c (Fvertical_motion): Fix a case of motion by 0
lines.
Starting from a display string after a newline, point went to the
previous line.
Also, correct an inadvertent use of a buffer position with FETCH_BYTE.
---
src/indent.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/indent.c b/src/indent.c
index ce78308..b4e6d74 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -2134,17 +2134,20 @@ whether or not it is currently displayed in some window. */)
overshoot_handled = 1;
}
else if (IT_CHARPOS (it) == PT - 1
- && FETCH_BYTE (PT - 1) == '\n'
- && nlines < 0)
+ && FETCH_BYTE (PT_BYTE - 1) == '\n'
+ && nlines <= 0)
{
/* The position we started from was covered by a display
property, so we moved to position before the string, and
- backed up one line, because the character at PT - 1 is a
- newline. So we need one less line to go up. */
+ backed up one line, because the character at PT - 1 is
+ a newline. So we need one less line to go up (or exactly
+ one line to go down if nlines == 0). */
nlines++;
/* But we still need to record that one line, in order to
return the correct value to the caller. */
vpos_init = -1;
+
+ overshoot_handled = 1;
}
if (lcols_given)
to_x = window_column_x (w, window, extract_float (lcols), lcols);
@@ -2159,7 +2162,7 @@ whether or not it is currently displayed in some window. */)
}
else if (overshoot_handled)
{
- it.vpos = 0;
+ it.vpos = vpos_init;
move_it_by_lines (&it, min (PTRDIFF_MAX, nlines));
}
else
--
2.4.1
next reply other threads:[~2015-05-31 14:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-31 14:19 Wolfgang Jenkner [this message]
2015-05-31 15:08 ` bug#20701: 25.0.50; [PATCH] (vertical-motion 0) broken at display strings after newline Eli Zaretskii
2015-06-03 13:56 ` Wolfgang Jenkner
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=85y4k47qf6.fsf@iznogoud.viz \
--to=wjenkner@inode.at \
--cc=20701@debbugs.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.