zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Make _xset complete more helpfully
@ 2011-05-12 16:59 Mikael Magnusson
  2011-05-12 17:14 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Mikael Magnusson @ 2011-05-12 16:59 UTC (permalink / raw)
  To: zsh-workers

I've had this in my drafts folder for at least 3 years
"""
xset <tab> has absolutely zero effect, but if i type the first
argument it correctly completes some things i tried, others, not so
much. I'm happy if just the first argument thing is fixed though. It
seems to use _regex_arguments which I've never used before, so I'll
settle for mentioning it here and hoping for the best.
"""

Looking into it now, this seems to be the fix, but I'm not sure I
understand why. Is it simply wrong to give words not starting with a -
or + to _describe when you pass -o? Before the patch, even xset
mo<tab> doesn't complete mouse, but xset -b<tab> does complete xset
-bc. Not having either of -o or -O also works, but I feel like it
should be -O, probably. Because of the way xset treats options, things
that start with a - aren't really different from ones that don't.

I'm not exactly sure what I meant with some arguments not working,
maybe that things like xset dpms <tab> inserts force instead of also
saying you can type a number there. If you do start typing a number
and press tab it does say what the number is for though. I'm not going
to fiddle with that :).

--- a/Completion/X/Command/_xset
+++ b/Completion/X/Command/_xset
@@ -27,8 +27,8 @@ _xset_compopts () {
       tmp=("$tmp[@]" "$opt")
     fi
   done
-  _describe -o options tmp -- ||
-  _describe -o options allopts --
+  _describe -O options tmp -- ||
+  _describe -O options allopts --
 }

 _xset_compfpadd () {


-- 
Mikael Magnusson


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

* Re: PATCH: Make _xset complete more helpfully
  2011-05-12 16:59 PATCH: Make _xset complete more helpfully Mikael Magnusson
@ 2011-05-12 17:14 ` Bart Schaefer
  2011-05-12 17:22   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2011-05-12 17:14 UTC (permalink / raw)
  To: zsh-workers

On May 12,  6:59pm, Mikael Magnusson wrote:
} Subject: PATCH: Make _xset complete more helpfully
}
} Looking into it now, this seems to be the fix, but I'm not sure I
} understand why. Is it simply wrong to give words not starting with a -
} or + to _describe when you pass -o?

As usual, the way to find out is to try it both ways and compare the
output of _complete_debug.

In this case _describe -o bails out at line 29:

     27 [[ "$_type$_noprefix" = options && ! -prefix [-+]* ]] && \
     28     zstyle -T ":completion:${curcontext}:options" prefix-needed &&
     29         return 1

I'm not sure it's correct for it to entirely punt when prefix-needed
is not defined.  Probably the right thing would be to assume a default
value instead ... but I don't really know.

-- 


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

* Re: PATCH: Make _xset complete more helpfully
  2011-05-12 17:14 ` Bart Schaefer
@ 2011-05-12 17:22   ` Bart Schaefer
  2011-05-12 17:40     ` Mikael Magnusson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2011-05-12 17:22 UTC (permalink / raw)
  To: zsh-workers

On May 12, 10:14am, Bart Schaefer wrote:
}
}      27 [[ "$_type$_noprefix" = options && ! -prefix [-+]* ]] && \
}      28     zstyle -T ":completion:${curcontext}:options" prefix-needed &&
}      29         return 1
} 
} I'm not sure it's correct for it to entirely punt when prefix-needed
} is not defined.  Probably the right thing would be to assume a default
} value instead ... but I don't really know.

Ah.  Seems punting when not defined is equivalent to assuming a default
value of "true":

     For command options, this means that the initial `-', `+', or `--'
     must be typed explicitly before option names will be completed.

So changing _xset to use -O instead *is* the correct fix.


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

* Re: PATCH: Make _xset complete more helpfully
  2011-05-12 17:22   ` Bart Schaefer
@ 2011-05-12 17:40     ` Mikael Magnusson
  2011-05-12 18:29       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Mikael Magnusson @ 2011-05-12 17:40 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On 12 May 2011 19:22, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 12, 10:14am, Bart Schaefer wrote:
> }
> }      27 [[ "$_type$_noprefix" = options && ! -prefix [-+]* ]] && \
> }      28     zstyle -T ":completion:${curcontext}:options" prefix-needed &&
> }      29         return 1
> }
> } I'm not sure it's correct for it to entirely punt when prefix-needed
> } is not defined.  Probably the right thing would be to assume a default
> } value instead ... but I don't really know.
>
> Ah.  Seems punting when not defined is equivalent to assuming a default
> value of "true":
>
>     For command options, this means that the initial `-', `+', or `--'
>     must be typed explicitly before option names will be completed.
>
> So changing _xset to use -O instead *is* the correct fix.

Okay, I'll commit that then. So this means passing -o and non-option
arguments is incorrect, as it is quite hard to type the leading - of a
word that starts with a letter? Reading the man page entry for
_describe I get the impression it is supposed to show non-option
arguments only as long as you don't type a -, not show nothing until
you do... (I don't want this behaviour either for _xset though, as I
said earlier).

-- 
Mikael Magnusson


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

* Re: PATCH: Make _xset complete more helpfully
  2011-05-12 17:40     ` Mikael Magnusson
@ 2011-05-12 18:29       ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2011-05-12 18:29 UTC (permalink / raw)
  To: zsh-workers

On May 12,  7:40pm, Mikael Magnusson wrote:
}
} Okay, I'll commit that then. So this means passing -o and non-option
} arguments is incorrect, as it is quite hard to type the leading - of a
} word that starts with a letter?

Seems so, yes.

} Reading the man page entry for
} _describe I get the impression it is supposed to show non-option
} arguments only as long as you don't type a -

Well, it says

     If the option `-o' appears before the first argument, the matches
     added will be treated as names of command options ...

So even if you add something that doesn't have a leading -, it's
treated as if it was supposed to have a leading -.  I guess you're
supposed to separate the option arguments from the non-option ones
and use _alternative so they have different tags.

-- 


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

end of thread, other threads:[~2011-05-12 18:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-12 16:59 PATCH: Make _xset complete more helpfully Mikael Magnusson
2011-05-12 17:14 ` Bart Schaefer
2011-05-12 17:22   ` Bart Schaefer
2011-05-12 17:40     ` Mikael Magnusson
2011-05-12 18:29       ` Bart Schaefer

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