From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: Vim special marks - Re: PATCH: highlight pasted text
Date: Tue, 11 Aug 2015 13:16:01 +0200 [thread overview]
Message-ID: <27930.1439291761@thecus.kiddle.eu> (raw)
In-Reply-To: <9889.1437764790@thecus.kiddle.eu>
On 24 Jul, I wrote:
> There's one very unfortunate
> effect of this design choice, however: if the start of some inserted
> text looks the same as what was there before, the undo mechanism will
> identify the later characters as having been inserted rather than the
> earlier ones.
I've not come up with a solution to this. One part of the patch was
actually a bug fix: the use of histline rather than curhist when
checking whether the zle_goto_hist call is needed. This prevented you
from returning to the original line.
The following is a cut down version of the patch. It includes the addition
of the . mark which uses the cursor position from the last change rather
than the offset so is unaffected by the problem,
Oliver
diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index d751c43..208839e 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -876,24 +876,36 @@ int
vigotomark(UNUSED(char **args))
{
ZLE_INT_T ch;
+ int *markcs, *markhist = 0;
int oldcs = zlecs;
int oldline = histline;
+ int tmpcs, tmphist;
ch = getfullchar(0);
- if (ch == ZWC('\'') || ch == ZWC('`'))
- ch = 26;
- else {
- if (ch < ZWC('a') || ch > ZWC('z'))
- return 1;
- ch -= ZWC('a');
- }
- if (!vimarkline[ch])
- return 1;
- if (curhist != vimarkline[ch] && !zle_goto_hist(vimarkline[ch], 0, 0)) {
- vimarkline[ch] = 0;
+ if (ch == ZWC('\'') || ch == ZWC('`')) {
+ markhist = vimarkline + 26;
+ markcs = vimarkcs + 26;
+ } else if (ch == ZWC('.') && curchange->prev) {
+ /* position cursor where it was after the last change. not exactly
+ * what vim does but close enough */
+ tmpcs = curchange->prev->new_cs;
+ tmphist = curchange->prev->hist;
+ markcs = &tmpcs;
+ markhist = &tmphist;
+ } else if (ch >= ZWC('a') && ch <= ZWC('z')) {
+ markhist = vimarkline + (ch - ZWC('a'));
+ markcs = vimarkcs + (ch - ZWC('a'));
+ } else
return 1;
+ if (markhist) {
+ if (!*markhist)
+ return 1;
+ if (histline != *markhist && !zle_goto_hist(*markhist, 0, 0)) {
+ *markhist = 0;
+ return 1;
+ }
}
- zlecs = vimarkcs[ch];
+ zlecs = *markcs;
vimarkcs[26] = oldcs;
vimarkline[26] = oldline;
if (zlecs > zlell)
next prev parent reply other threads:[~2015-08-11 11:22 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-15 16:51 bracketed paste Yuri D'Elia
2015-07-15 17:33 ` Yuri D'Elia
2015-07-15 18:15 ` Mikael Magnusson
2015-07-15 18:43 ` Yuri D'Elia
2015-07-16 5:19 ` Oliver Kiddle
2015-07-16 14:32 ` Yuri D'Elia
2015-07-18 2:33 ` Oliver Kiddle
2015-07-18 11:55 ` Yuri D'Elia
2015-07-18 17:17 ` Bart Schaefer
2015-07-18 23:28 ` Oliver Kiddle
2015-07-19 8:13 ` Unmetafy of getsparam() Bart Schaefer
2015-07-21 20:07 ` Peter Stephenson
2015-07-21 23:08 ` Bart Schaefer
2015-07-23 8:50 ` Peter Stephenson
2015-07-16 20:15 ` bracketed paste Bart Schaefer
2015-07-18 12:05 ` Yuri D'Elia
2015-07-18 18:08 ` Bart Schaefer
2015-07-19 2:50 ` PATCH: highlight pasted text Oliver Kiddle
2015-07-19 8:17 ` Bart Schaefer
2015-07-19 12:13 ` Yuri D'Elia
2015-07-19 17:12 ` Daniel Shahaf
2015-07-19 18:10 ` Bart Schaefer
2015-07-21 15:23 ` Oliver Kiddle
2015-07-21 17:35 ` Bart Schaefer
2015-07-23 3:57 ` Oliver Kiddle
2015-07-19 17:57 ` Oliver Kiddle
2015-07-19 18:09 ` Yuri D'Elia
2015-08-08 21:51 ` Daniel Shahaf
2015-08-14 1:38 ` Oliver Kiddle
2015-08-14 5:28 ` Bart Schaefer
2015-07-23 5:00 ` Mikael Magnusson
2015-07-23 6:23 ` Oliver Kiddle
2015-07-24 5:06 ` Bart Schaefer
2015-07-24 5:21 ` Bart Schaefer
2015-07-24 22:22 ` Oliver Kiddle
2015-07-24 23:13 ` Bart Schaefer
2015-07-25 7:49 ` Oliver Kiddle
2015-07-25 16:46 ` zle options (was Re: PATCH: highlight pasted text) Bart Schaefer
2015-07-28 9:09 ` Oliver Kiddle
2015-07-24 19:06 ` Vim special marks - Re: PATCH: highlight pasted text Oliver Kiddle
2015-07-24 19:45 ` Bart Schaefer
2015-08-11 11:16 ` Oliver Kiddle [this message]
2015-08-13 23:14 ` Daniel Shahaf
2015-08-13 23:50 ` Bart Schaefer
2015-08-14 2:09 ` Oliver Kiddle
2015-08-14 5:24 ` Bart Schaefer
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=27930.1439291761@thecus.kiddle.eu \
--to=okiddle@yahoo.co.uk \
--cc=zsh-workers@zsh.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.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).