* PATCH: save last position in vi-goto-mark
@ 2013-02-08 22:27 Oliver Kiddle
2013-02-10 22:11 ` zle test cases (Re: PATCH: save last position in vi-goto-mark) Oliver Kiddle
2013-03-28 10:36 ` PATCH: save last position in vi-goto-mark Jun T.
0 siblings, 2 replies; 4+ messages in thread
From: Oliver Kiddle @ 2013-02-08 22:27 UTC (permalink / raw)
To: Zsh workers
This actually backs out some of 28611 so perhaps this once worked in the
distant past. `` or '' should return to the previous position from before the
last jump. The rather pointless `' and '` will also do the same but they do in
vim too. I suspect that with the original implementation, LASTFULLCHAR was
returning ` or ' and avoiding this quirk but it now returns the character of
the recently set mark (hence the bug that 28611 fixed). The code for saving the
old position must have either got lost or was forgotten in the first place.
Oliver
diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index 4653855..73c8e59 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -30,7 +30,7 @@
#include "zle.mdh"
#include "zle_move.pro"
-static int vimarkcs[26], vimarkline[26];
+static int vimarkcs[27], vimarkline[27];
#ifdef MULTIBYTE_SUPPORT
/*
@@ -834,11 +834,17 @@ int
vigotomark(UNUSED(char **args))
{
ZLE_INT_T ch;
+ int oldcs = zlecs;
+ int oldline = histline;
ch = getfullchar(0);
- if (ch < ZWC('a') || ch > ZWC('z'))
- return 1;
- ch -= ZWC('a');
+ 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)) {
@@ -846,6 +852,8 @@ vigotomark(UNUSED(char **args))
return 1;
}
zlecs = vimarkcs[ch];
+ vimarkcs[26] = oldcs;
+ vimarkline[26] = histline;
if (zlecs > zlell)
zlecs = zlell;
return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
* zle test cases (Re: PATCH: save last position in vi-goto-mark)
2013-02-08 22:27 PATCH: save last position in vi-goto-mark Oliver Kiddle
@ 2013-02-10 22:11 ` Oliver Kiddle
2013-02-11 9:44 ` Peter Stephenson
2013-03-28 10:36 ` PATCH: save last position in vi-goto-mark Jun T.
1 sibling, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2013-02-10 22:11 UTC (permalink / raw)
To: Zsh workers
I would have added a test case along with the recent patch but we don't
yet have any tests for zle. I had a look and it seemed that not much
needed changing to comptest to support testing zle widgets. With the
following patch, it will report the buffer contents, cursor position and
mark (if the region is active). Is anything more needed? Any other
thoughts on this?
comptest should perhaps be renamed as completion is sooner a part of zle
than zle a part of completion.
Oliver
Index: Test/X02zlevi.ztst
===================================================================
RCS file: Test/X02zlevi.ztst
diff -N Test/X02zlevi.ztst
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Test/X02zlevi.ztst 10 Feb 2013 21:51:46 -0000
@@ -0,0 +1,20 @@
+# Tests of the vi mode of ZLE
+
+%prep
+ if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ . $ZTST_srcdir/comptest
+ comptestinit -v -z $ZTST_testdir/../Src/zsh
+ else
+ ZTST_unimplemented="the zsh/zpty module is not available"
+ fi
+
+%test
+
+ zletest $'one two\ebmt3|`tx``'
+0:setting mark and returning to original position
+>BUFFER: one wo
+>CURSOR: 2
+
+%clean
+
+ zmodload -ui zsh/zpty
Index: Test/comptest
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/comptest,v
retrieving revision 1.18
diff -u -r1.18 comptest
--- Test/comptest 13 Jan 2009 12:09:26 -0000 1.18
+++ Test/comptest 10 Feb 2013 21:51:46 -0000
@@ -8,10 +8,12 @@
zmodload -i zsh/zpty || return $?
comptest_zsh=${ZSH:-zsh}
+ comptest_keymap=e
- while getopts z: opt; do
+ while getopts vz: opt; do
case $opt in
z) comptest_zsh="$OPTARG";;
+ v) comptest_keymap="v";;
esac
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
@@ -30,11 +32,11 @@
"export ZDOTDIR=$ZTST_testdir" \
"module_path=( $module_path )" \
"fpath=( $fpath )" \
+"bindkey -$comptest_keymap" \
'LISTMAX=10000000
TERM=vt100
stty columns 80 rows 24
setopt zle
-bindkey -e
autoload -U compinit
compinit -u
zstyle ":completion:*:default" list-colors "no=<NO>" "fi=<FI>" "di=<DI>" "ln=<LN>" "pi=<PI>" "so=<SO>" "bd=<BD>" "cd=<CD>" "ex=<EX>" "mi=<MI>" "tc=<TC>" "sp=<SP>" "lc=<LC>" "ec=<EC>\n" "rc=<RC>"
@@ -60,18 +62,29 @@
zle clear-screen
zle -R
}
-finish () {
+comp-finish () {
print "<WIDGET><finish>"
zle kill-whole-line
zle clear-screen
zle -R
}
+zle-finish () {
+ print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR"
+ (( region_active )) && print -lr "MARK: $MARK"
+ zle -K main
+ zle kill-whole-line
+ zle clear-screen
+ zle -R
+}
zle -N expand-or-complete-with-report
zle -N list-choices-with-report
-zle -N finish
+zle -N comp-finish
+zle -N zle-finish
bindkey "^I" expand-or-complete-with-report
bindkey "^D" list-choices-with-report
-bindkey "^Z" finish
+bindkey "^Z" comp-finish
+bindkey "^M" zle-finish
+bindkey -a "^M" zle-finish
'
}
@@ -120,3 +133,13 @@
done
done
}
+
+zletest () {
+ input="$*"
+ zpty -n -w zsh "$input"$'\C-M'
+ zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ print "failed to invoke finish widget."
+ return 1
+ }
+ print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zle test cases (Re: PATCH: save last position in vi-goto-mark)
2013-02-10 22:11 ` zle test cases (Re: PATCH: save last position in vi-goto-mark) Oliver Kiddle
@ 2013-02-11 9:44 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2013-02-11 9:44 UTC (permalink / raw)
To: Zsh workers
On Sun, 10 Feb 2013 23:11:46 +0100
Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> I would have added a test case along with the recent patch but we don't
> yet have any tests for zle. I had a look and it seemed that not much
> needed changing to comptest to support testing zle widgets. With the
> following patch, it will report the buffer contents, cursor position and
> mark (if the region is active). Is anything more needed? Any other
> thoughts on this?
Great, let's see how it goes. Obviously we're a bit short of tests but
we can fix that gradually and see if that shows up any glitches along
the way.
Peter Stephenson <p.stephenson@samsung.com> Consultant, Software
Tel: +44 (0)1223 434724 Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: save last position in vi-goto-mark
2013-02-08 22:27 PATCH: save last position in vi-goto-mark Oliver Kiddle
2013-02-10 22:11 ` zle test cases (Re: PATCH: save last position in vi-goto-mark) Oliver Kiddle
@ 2013-03-28 10:36 ` Jun T.
1 sibling, 0 replies; 4+ messages in thread
From: Jun T. @ 2013-03-28 10:36 UTC (permalink / raw)
To: zsh-workers
I guess we need to fix a typo as follows:
Index: Src/Zle/zle_move.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_move.c,v
retrieving revision 1.23
diff -u -r1.23 zle_move.c
--- Src/Zle/zle_move.c 9 Feb 2013 21:27:47 -0000 1.23
+++ Src/Zle/zle_move.c 28 Mar 2013 10:03:46 -0000
@@ -844,7 +844,7 @@
}
zlecs = vimarkcs[ch];
vimarkcs[26] = oldcs;
- vimarkline[26] = histline;
+ vimarkline[26] = oldline;
if (zlecs > zlell)
zlecs = zlell;
return 0;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-28 11:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 22:27 PATCH: save last position in vi-goto-mark Oliver Kiddle
2013-02-10 22:11 ` zle test cases (Re: PATCH: save last position in vi-goto-mark) Oliver Kiddle
2013-02-11 9:44 ` Peter Stephenson
2013-03-28 10:36 ` PATCH: save last position in vi-goto-mark Jun T.
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).