zsh-workers
 help / color / mirror / code / Atom feed
* Re: copy-prev-word question RE: Bug report interface comments
@ 2000-04-06  8:24 Sven Wischnowsky
  0 siblings, 0 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-04-06  8:24 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > Erm... could we, until we have some automatic forwarding from the bug
> > manager to zsh-workers, agree that full bug descriptions be sent to
> > zsh-workers, too?
> 
> bor@itsrm2% mv BI<TAB>
> bor@itsrm2% mv BIC\ NMI.rm2/
> bor@itsrm2% mv BIC\ NMI.rm2 <ESC-^_>
> bor@itsrm2% mv BIC\ NMI.rm2 NMI.rm2
> 
> I'd expect it to respect shell quouting ... note, that insert-last-word
> does that:
> 
> bor@itsrm2% mv 'xx xx' 'yy yy'
> mv: Cannot access xx xx: No such file or directory
> bor@itsrm2% mv <ESC-.>
> bor@itsrm2% mv 'yy yy'
> 
> the same with
> 
> bor@itsrm2% mv yy\ yy
> 
> the "yy\ yy" is inserted.

No patch, but I thought, I could try to explain...

insert-last-word uses the history, which contains the words for each
line, separated, parsed and everything. copy-prev-word has no such
luck, because the current line doesn't exist in parsed form yet. This
is, btw, the same reason why $historywords does not contain the words
from the current line and why `compctl -h' couldn't complete these
words.

The completion code has gat_comp_string() to get at the words from the 
current line, but setting everything up to be able to call that
function is complicated enough to kepp me from trying to fix this...

Maybe one could try it with a loop as in set_comp_sep() some day...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: copy-prev-word question RE: Bug report interface comments
  2000-04-11  9:48     ` Sven Wischnowsky
@ 2000-04-11 15:25       ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-04-11 15:25 UTC (permalink / raw)
  To: zsh-workers

On Apr 11, 10:20am, Oliver Kiddle wrote:
} Subject: Re: copy-prev-word question RE: Bug report interface comments
}
} Bart Schaefer wrote:
} 
} > So "behind the cursor" is to the left of it (unless you're writing in
} > Hebrew or Aramaic or something) and I think the doc was correct before,
} > or rather it was correct "behind."
} 
} I'm sure what you say is right but 'before' seems clearer to me.

It's actually fine either way, to a native English speaker, so ....

} I wouldn't particularly consider the left to be behind the
} right because it is no further away and isn't obscured by it.

Ah, now -there's- an aspect of obscurity that I neglected to explore.
"Behind" like one car is behind another in a train [*], not like your
sister is hiding behind the couch.

[*] Train cars aren't automobiles, but automobiles are cars.
    Oh, nevermind.

On Apr 11, 11:48am, Sven Wischnowsky wrote:
}
} Back to the original question: should I commit the patch? With a
} to-the-left-of-the-cursor manual as suggested by Oliver? Should I make 
} it a separate widget? (Name? I can only think of copy-last-word which
} is probably to easily confused with copy-prev-word and insert-last-word.)

Oliver's suggestion:  Yes.

A new widget:  Yes.  Call it repeat-prev-word or copy-prev-shell-word or
some such.  (The distinction is whether the word boundary is typographical 
or shell-lexical, right?)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: copy-prev-word question RE: Bug report interface comments
@ 2000-04-11  9:48     ` Sven Wischnowsky
  2000-04-11 15:25       ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-04-11  9:48 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Apr 10,  9:58am, Sven Wischnowsky wrote:
> } Subject: Re: copy-prev-word question RE: Bug report interface comments
> }
> } And the maual was wrong, wasn't it?
> } 
> } -Duplicate the word behind the cursor.
> } +Duplicate the word before the cursor.
> 
> Behind in space, before in time.  What is left behind has gone before,
> but what lies ahead is still before us, and the part after this is even
> more confusing after I've written it.
> 
> This is what we English speakers get for muddling our temporal-spacial
> relationships:  We're always getting ahead of ourselves, and no one else
> can tell whether we're coming or going.
> 
> So "behind the cursor" is to the left of it (unless you're writing in
> Hebrew or Aramaic or something) and I think the doc was correct before,
> or rather it was correct "behind." 

;-) Everything is crystal clear now...

Back to the original question: should I commit the patch? With a
to-the-left-of-the-cursor manual as suggested by Oliver? Should I make 
it a separate widget? (Name? I can only think of copy-last-word which
is probably to easily confused with copy-prev-word and insert-last-word.)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: copy-prev-word question RE: Bug report interface comments
  2000-04-11  2:52 ` Bart Schaefer
  2000-04-11  6:11   ` Andrej Borsenkow
@ 2000-04-11  9:20   ` Oliver Kiddle
  2000-04-11  9:48     ` Sven Wischnowsky
  1 sibling, 1 reply; 8+ messages in thread
From: Oliver Kiddle @ 2000-04-11  9:20 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:
> 
> On Apr 10,  9:58am, Sven Wischnowsky wrote:
> } -Duplicate the word behind the cursor.
> } +Duplicate the word before the cursor.

> So "behind the cursor" is to the left of it (unless you're writing in
> Hebrew or Aramaic or something) and I think the doc was correct before,
> or rather it was correct "behind."

I'm sure what you say is right but 'before' seems clearer to me. Would
it maybe be clearer if the doc said 'Duplicate the word to the left of
the cursor'. I wouldn't particularly consider the left to be behind the
right because it is no further away and isn't obscured by it. I agree
with Andrej in finding 'before the cursor' more understandable.

Oliver


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: copy-prev-word question RE: Bug report interface comments
  2000-04-11  2:52 ` Bart Schaefer
@ 2000-04-11  6:11   ` Andrej Borsenkow
  2000-04-11  9:20   ` Oliver Kiddle
  1 sibling, 0 replies; 8+ messages in thread
From: Andrej Borsenkow @ 2000-04-11  6:11 UTC (permalink / raw)
  To: Bart Schaefer, Sven Wischnowsky, zsh-workers

> }
> } -Duplicate the word behind the cursor.
> } +Duplicate the word before the cursor.
>
> Behind in space, before in time.  What is left behind has gone before,
> but what lies ahead is still before us, and the part after
> this is even
> more confusing after I've written it.
>

Wow! I must confess, the times when I really could _feel_ this
difference, are far far away ... and for us, poor foreigners, who do not
use English in *native* environment, "before the cursor" is much more
understandable :-)

-andrej


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: copy-prev-word question RE: Bug report interface comments
  2000-04-10  7:58 Sven Wischnowsky
@ 2000-04-11  2:52 ` Bart Schaefer
  2000-04-11  6:11   ` Andrej Borsenkow
  2000-04-11  9:20   ` Oliver Kiddle
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-04-11  2:52 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

On Apr 10,  9:58am, Sven Wischnowsky wrote:
} Subject: Re: copy-prev-word question RE: Bug report interface comments
}
} And the maual was wrong, wasn't it?
} 
} -Duplicate the word behind the cursor.
} +Duplicate the word before the cursor.

Behind in space, before in time.  What is left behind has gone before,
but what lies ahead is still before us, and the part after this is even
more confusing after I've written it.

This is what we English speakers get for muddling our temporal-spacial
relationships:  We're always getting ahead of ourselves, and no one else
can tell whether we're coming or going.

So "behind the cursor" is to the left of it (unless you're writing in
Hebrew or Aramaic or something) and I think the doc was correct before,
or rather it was correct "behind." 

And now you're probably all after me.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: copy-prev-word question RE: Bug report interface comments
@ 2000-04-10  7:58 Sven Wischnowsky
  2000-04-11  2:52 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-04-10  7:58 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > Erm... could we, until we have some automatic forwarding from the bug
> > manager to zsh-workers, agree that full bug descriptions be sent to
> > zsh-workers, too?
> 
> bor@itsrm2% mv BI<TAB>
> bor@itsrm2% mv BIC\ NMI.rm2/
> bor@itsrm2% mv BIC\ NMI.rm2 <ESC-^_>
> bor@itsrm2% mv BIC\ NMI.rm2 NMI.rm2
> 
> I'd expect it to respect shell quouting ... note, that insert-last-word
> does that:
> 
> ...

The patch could be something like the one below. I haven't committed
it because it would change the behaviour it always had and I don't
know if it counts as a bug fix.

The core is the new function bufferwords() in hist.c which returns a
list containing the words from the current line. The patch makes that
also be used for the $historywords parameter.

And the maual was wrong, wasn't it?

Bye
 Sven

diff -u -r ../oz/Doc/Zsh/zle.yo ./Doc/Zsh/zle.yo
--- ../oz/Doc/Zsh/zle.yo	Fri Apr  7 20:06:26 2000
+++ ./Doc/Zsh/zle.yo	Fri Apr  7 21:31:46 2000
@@ -637,7 +637,7 @@
 )
 tindex(copy-prev-word)
 item(tt(copy-prev-word) (ESC-^_) (unbound) (unbound))(
-Duplicate the word behind the cursor.
+Duplicate the word before the cursor.
 )
 tindex(vi-delete)
 item(tt(vi-delete) (unbound) (d) (unbound))(
diff -u -r ../oz/Src/Modules/parameter.c ./Src/Modules/parameter.c
--- ../oz/Src/Modules/parameter.c	Fri Apr  7 20:06:31 2000
+++ ./Src/Modules/parameter.c	Fri Apr  7 21:27:16 2000
@@ -1081,10 +1081,14 @@
 histwgetfn(Param pm)
 {
     char **ret, **p, *h, *e, sav;
-    LinkList l = newlinklist();
+    LinkList l = newlinklist(), ll;
     LinkNode n;
     int i = addhistnum(curhist, -1, HIST_FOREIGN), iw;
     Histent he = quietgethistent(i, GETHIST_UPWARD);
+
+    ll = bufferwords(NULL);
+    for (n = firstnode(ll); n; incnode(n))
+	pushnode(l, getdata(n));
 
     while (he) {
 	for (iw = he->nwords - 1; iw >= 0; iw--) {
diff -u -r ../oz/Src/Zle/zle_misc.c ./Src/Zle/zle_misc.c
--- ../oz/Src/Zle/zle_misc.c	Fri Apr  7 20:06:30 2000
+++ ./Src/Zle/zle_misc.c	Fri Apr  7 21:11:44 2000
@@ -523,20 +523,25 @@
 int
 copyprevword(char **args)
 {
-    int len, t0;
+    LinkList l;
+    LinkNode n;
+    int i;
+    char *p = NULL;
 
-    for (t0 = cs - 1; t0 >= 0; t0--)
-	if (iword(line[t0]))
-	    break;
-    for (; t0 >= 0; t0--)
-	if (!iword(line[t0]))
+    l = bufferwords(&i);
+
+    for (n = firstnode(l); n; incnode(n))
+	if (!i--) {
+	    p = getdata(n);
 	    break;
-    if (t0)
-	t0++;
-    len = cs - t0;
-    spaceinline(len);
-    memcpy((char *)&line[cs], (char *)&line[t0], len);
-    cs += len;
+	}
+    if (p) {
+	int len = strlen(p);
+
+	spaceinline(len);
+	memcpy(line + cs, p, len);
+	cs += len;
+    }
     return 0;
 }
 
diff -u -r ../oz/Src/hist.c ./Src/hist.c
--- ../oz/Src/hist.c	Fri Apr  7 20:06:27 2000
+++ ./Src/hist.c	Fri Apr  7 21:14:42 2000
@@ -2032,3 +2032,66 @@
 	free(lockfile);
     }
 }
+
+/* Get the words in the current buffer. Using the lexer. */
+
+/**/
+mod_export LinkList
+bufferwords(int *index)
+{
+    LinkList list = newlinklist();
+    int num = 0, cur = -1, got = 0, ne = noerrs, ocs = cs;
+    char *p;
+
+    zleparse = 1;
+    addedx = 0;
+    noerrs = 1;
+    lexsave();
+    if (!isfirstln && chline) {
+	p = (char *) zhalloc(hptr - chline + ll + 2);
+	memcpy(p, chline, hptr - chline);
+	memcpy(p + (hptr - chline), line, ll);
+	p[(hptr - chline) + ll] = ' ';
+	p[(hptr - chline) + ll + 1] = '\0';
+	inpush(p, 0, NULL);
+	cs += hptr - chline;
+    } else {
+	p = (char *) zhalloc(ll + 2);
+	memcpy(p, line, ll);
+	p[ll] = ' ';
+	p[ll + 1] = '\0';
+	inpush(p, 0, NULL);
+    }
+    if (cs)
+	cs--;
+    strinbeg(0);
+    noaliases = 1;
+    do {
+	ctxtlex();
+	if (tok == ENDINPUT || tok == LEXERR)
+	    break;
+	if (tokstr && *tokstr) {
+	    untokenize((p = dupstring(tokstr)));
+	    addlinknode(list, p);
+	    num++;
+	}
+	if (!got && !zleparse) {
+	    got = 1;
+	    cur = num - 1;
+	}
+    } while (tok != ENDINPUT && tok != LEXERR);
+    if (cur < 0 && num)
+	cur = num - 1;
+    noaliases = 0;
+    strinend();
+    inpop();
+    errflag = zleparse = 0;
+    noerrs = ne;
+    lexrestore();
+    cs = ocs;
+
+    if (index)
+	*index = cur;
+
+    return list;
+}

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* copy-prev-word question RE: Bug report interface comments
  2000-04-04  9:19 Sven Wischnowsky
@ 2000-04-04  9:29 ` Andrej Borsenkow
  0 siblings, 0 replies; 8+ messages in thread
From: Andrej Borsenkow @ 2000-04-04  9:29 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> Erm... could we, until we have some automatic forwarding from the bug
> manager to zsh-workers, agree that full bug descriptions be sent to
> zsh-workers, too?
>

bor@itsrm2% mv BI<TAB>
bor@itsrm2% mv BIC\ NMI.rm2/
bor@itsrm2% mv BIC\ NMI.rm2 <ESC-^_>
bor@itsrm2% mv BIC\ NMI.rm2 NMI.rm2

I'd expect it to respect shell quouting ... note, that insert-last-word
does that:

bor@itsrm2% mv 'xx xx' 'yy yy'
mv: Cannot access xx xx: No such file or directory
bor@itsrm2% mv <ESC-.>
bor@itsrm2% mv 'yy yy'

the same with

bor@itsrm2% mv yy\ yy

the "yy\ yy" is inserted.

-andrej


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-04-11 15:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-06  8:24 copy-prev-word question RE: Bug report interface comments Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-04-10  7:58 Sven Wischnowsky
2000-04-11  2:52 ` Bart Schaefer
2000-04-11  6:11   ` Andrej Borsenkow
2000-04-11  9:20   ` Oliver Kiddle
2000-04-11  9:48     ` Sven Wischnowsky
2000-04-11 15:25       ` Bart Schaefer
2000-04-04  9:19 Sven Wischnowsky
2000-04-04  9:29 ` copy-prev-word question " Andrej Borsenkow

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).