zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: _diff
@ 2000-02-10 12:58 Oliver Kiddle
  2000-02-10 15:51 ` Bart Schaefer
  2000-02-11 15:28 ` Tanaka Akira
  0 siblings, 2 replies; 10+ messages in thread
From: Oliver Kiddle @ 2000-02-10 12:58 UTC (permalink / raw)
  To: Zsh workers

This may have already been fixed but the diff completion seemed to call
diff with /dev/null as stdin but not stdout and stderr. This causes me
to get an error messages about -v not being an option in the middle of
my command line. I take it that redirecting stdin was a typo?

I seem to remember a recent discussion which I didn't follow fully about
how to call programs from completion functions and a proposed
configurable function for doing it so I haven't patched the use of
'command diff'. I leave the original diff and link GNU diff to 'gdiff'.
With the current _diff, I can't then get GNU style completion for gdiff.
Having both the GNU and supplied utilites are fairly common place on
commercial UNIX installations. For this reason, I object to using
non-local variables like _diff_is_gnu and calling 'diff' instead of
pulling out the first word on the command-line.

Oliver Kiddle

--- _diff_options.bak	Sat Jan 29 19:42:48 2000
+++ _diff_options	Thu Feb 10 12:34:33 2000
@@ -3,8 +3,8 @@
 local of ofwuc ouc oss ofwy ofwg ofwl
 
 (( $+_diff_is_gnu )) || {
-	_diff_is_gnu=0;
-        [[ $(command diff -v </dev/null) == *GNU* ]] && _diff_is_gnu=1
+	_diff_is_gnu=0
+        [[ $(command diff -v >/dev/null 2>&1) == *GNU* ]] &&
_diff_is_gnu=1
 }
 
 if (( _diff_is_gnu ))


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: PATCH: _diff
@ 2000-02-10 14:10 Sven Wischnowsky
  2000-02-10 14:44 ` Oliver Kiddle
  2000-02-11 10:14 ` Alexandre Duret-Lutz
  0 siblings, 2 replies; 10+ messages in thread
From: Sven Wischnowsky @ 2000-02-10 14:10 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> This may have already been fixed but the diff completion seemed to call
> diff with /dev/null as stdin but not stdout and stderr. This causes me
> to get an error messages about -v not being an option in the middle of
> my command line. I take it that redirecting stdin was a typo?
> 
> I seem to remember a recent discussion which I didn't follow fully about
> how to call programs from completion functions and a proposed
> configurable function for doing it so I haven't patched the use of
> 'command diff'. I leave the original diff and link GNU diff to 'gdiff'.
> With the current _diff, I can't then get GNU style completion for gdiff.
> Having both the GNU and supplied utilites are fairly common place on
> commercial UNIX installations. For this reason, I object to using
> non-local variables like _diff_is_gnu and calling 'diff' instead of
> pulling out the first word on the command-line.

Well, if we use something like _diff_is_gnu[$words[1]], using a
non-local variable should be fine, right?

But you are right -- I had forgotten to integrate using $words[1] into 
my suggestion somehow. Hm.

Still no patch for any of this, though. The problem is that this would
probably be interesting in several places so that updating the docs
would be quite a bit of work. And since we also had the `discussion'
about trying to add some auto-documentation mechanism (using magic
comments in the functions) I wanted to delay it until we had thought
about that some more.

Bye
 Sven


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


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: PATCH: _diff
@ 2000-02-11 10:48 Sven Wischnowsky
  2000-02-11 13:06 ` Alexandre Duret-Lutz
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2000-02-11 10:48 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> X-Seq: 9675
> 
> >>> "Sven" == Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> 
>  Sven> Oliver Kiddle wrote:
> 
>  >> I object to using
>  >> non-local variables like _diff_is_gnu and calling 'diff' instead of
>  >> pulling out the first word on the command-line.
> 
>  Sven> Well, if we use something like _diff_is_gnu[$words[1]], using a
>  Sven> non-local variable should be fine, right?
> 
> I don't think so, because _diff_options may be called from places where
> $words[1] is not the command name, e.g. called from _prcs (maybe _cvs_diff
> could call it too).

Err, right, I forgot...

> Hum, looking closer to _prcs, I see there is a problem, if I do
> 
> % prcs diff -P zsh -- -u <TAB>
> 
> the values of $words when entering the _diff_options functions are
> 
> diff -P zsh -- -u 
> 
> (this begin with diff since $words was shifted in _prcs)
> and the -P option is removed from the diff options list, which is wrong.
> I'd like this array te be restricted to
> 
> -- -u
> 
> unfortunately, I don't see how to do that with _arguments.
> The _arguments line calling _diff_options reads
> 
> '--[introduce diff options]:*:diff options: _diff_options'
> 
> I can't use the `*::message:action' syntax here.  So I guess
> I have to write an intermediate function that shift the $words 
> array $CURRENT times before calling _diff_options.  Or I am missing
> some syntaxic sugar in _arguments?

Of course, `--:*::...' should work (reporting anything after the
`--'), there was just a little thinko in ca_parse_line().

Bye
 Sven

diff -ru ../z.old/Src/Zle/computil.c Src/Zle/computil.c
--- ../z.old/Src/Zle/computil.c	Fri Feb 11 09:23:09 2000
+++ Src/Zle/computil.c	Fri Feb 11 11:46:04 2000
@@ -1235,12 +1235,12 @@
 	    else {
 		LinkList l = state.oargs[state.curopt->num];
 
+		if (cur < compcurrent)
+		    memcpy(&ca_laststate, &state, sizeof(state));
 		PERMALLOC {
 		    for (; line; line = compwords[cur++])
 			addlinknode(l, ztrdup(line));
 		} LASTALLOC;
-		if (cur < compcurrent)
-		    memcpy(&ca_laststate, &state, sizeof(state));
 		ca_laststate.ddef = NULL;
 		ca_laststate.doff = 0;
 		break;

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


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: PATCH: _diff
@ 2000-02-11 13:20 Sven Wischnowsky
  2000-02-11 19:27 ` Peter Stephenson
  0 siblings, 1 reply; 10+ messages in thread
From: Sven Wischnowsky @ 2000-02-11 13:20 UTC (permalink / raw)
  To: zsh-workers


Alexandre Duret-Lutz wrote:

> ...
> 
> Ah, thanks. So the patch below correct this call to 
> _diff_options. (and also add _texi and _matcher to .distfiles)

Will I ever learn that?

Bye
 Sven

diff -ru ../z.old/Completion/Core/.distfiles Completion/Core/.distfiles
--- ../z.old/Completion/Core/.distfiles	Fri Feb 11 14:18:29 2000
+++ Completion/Core/.distfiles	Fri Feb 11 14:19:37 2000
@@ -3,7 +3,7 @@
     _alternative _approximate _compalso _complete _correct _description
     _expand _files _funcall _list _main_complete _match 
     _matcher _menu _multi_parts _message _normal _oldlist 
-    _options _parameters _path_files _requested
+    _options _parameters _path_files _prefix _requested
     _sep_parts _set_options _setup _sort_tags _tags
     _unset_options _wanted
     compdump compinit compinstall

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


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

end of thread, other threads:[~2000-02-11 19:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-10 12:58 PATCH: _diff Oliver Kiddle
2000-02-10 15:51 ` Bart Schaefer
2000-02-11 15:28 ` Tanaka Akira
2000-02-10 14:10 Sven Wischnowsky
2000-02-10 14:44 ` Oliver Kiddle
2000-02-11 10:14 ` Alexandre Duret-Lutz
2000-02-11 10:48 Sven Wischnowsky
2000-02-11 13:06 ` Alexandre Duret-Lutz
2000-02-11 13:20 Sven Wischnowsky
2000-02-11 19:27 ` Peter Stephenson

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