zsh-users
 help / color / mirror / code / Atom feed
* completion for printf-style format strings
@ 2004-09-03 14:50 Felix Rosencrantz
  2004-09-03 15:08 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Rosencrantz @ 2004-09-03 14:50 UTC (permalink / raw)
  To: zsh-users

Does anyone have code to perform completion of printf-style format strings?

I think it was suggested that it might be possible to do with 
_regex_arguments. but not sure if there is an example somewhere or a
utility function.

I'm not sure if such completion would help reduce typing, but being
able to get a context based listing of possible values could help skip
a trip to the documentation..

-FR.


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

* Re: completion for printf-style format strings
  2004-09-03 14:50 completion for printf-style format strings Felix Rosencrantz
@ 2004-09-03 15:08 ` Oliver Kiddle
  2004-09-07  6:50   ` Felix Rosencrantz
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2004-09-03 15:08 UTC (permalink / raw)
  To: zsh-users

Felix Rosencrantz wrote:
> Does anyone have code to perform completion of printf-style format strings?
> 
> I think it was suggested that it might be possible to do with 
> _regex_arguments. but not sure if there is an example somewhere or a
> utility function.

It wouldn't be possible with _regex_arguments. _regex_arguments is only
useful when completing a single command-line argument in full. It never
uses compset -P/-S to cut the current word down into chunks.

You would probably want to use patterns a lot though. Basically you need
to remove any literal characters and complete format specifications from
the front of the word. Then you can deal with any partially complete
format specifications. What might be good is to make it sufficiently
general so as to be usable for things like strftime too.

Oliver


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

* Re: completion for printf-style format strings
  2004-09-03 15:08 ` Oliver Kiddle
@ 2004-09-07  6:50   ` Felix Rosencrantz
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Rosencrantz @ 2004-09-07  6:50 UTC (permalink / raw)
  To: Oliver Kiddle, zsh-users

If _regex_arguments doesn't provide a means or even a good example.   
 Do you think that it would make sense to modify _regex_arguments to
add code that would cause it to use the  compset -P/-S flags?

The _regex_arguments function relies on zregexparse, which is not
really documented, though it does have a dedicated test suite.  Would
it make sense to try to decipher that and make it try to search for
just substrings of the current word? Is that possible.  Or do you
think this is more a task for compadd/compset?  Is there an existing
utility function that could be used/modified?

I was thinking maybe _values might be good to look at, instead of
using a hard-coded separator, maybe a regex could be used.  Though it
uses compvalues which is not documented or tested(!).

It would be very useful to be able to complete alot of different
format strings.  I think you mentioned strftime since it can have
multi-letter formats. I think there are a lot of useful places it
could be used, like zsh prompts or the builtin print command.  Also
things like the date command or the find -printf flag.

Again, I'm not sure that this would directly help with a reduction in
typing, but I think it would help reduce the need to visit the
documentation, which would be useful.

-FR.


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

end of thread, other threads:[~2004-09-07  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-03 14:50 completion for printf-style format strings Felix Rosencrantz
2004-09-03 15:08 ` Oliver Kiddle
2004-09-07  6:50   ` Felix Rosencrantz

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