zsh-workers
 help / color / mirror / code / Atom feed
* Changing subword-range according to current completion context
@ 2017-11-03 11:52 ` Yuri D'Elia
  2017-11-03 12:23   ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri D'Elia @ 2017-11-03 11:52 UTC (permalink / raw)
  To: zsh-workers

I'd like to fine-tune the way words are interpreted according to the
completion context which was used to expand the word, not to the zle
context.

Is it saved anywhere? Is it possible to correlate the two?

For example, I normally had the following:

select-word-style S
zstyle ':zle:*' word-context '*/*' path '-*' arg
zstyle ':zle:*:path' subword-range '/' 
zstyle ':zle:*:arg' subword-range '='

This allows me to navigate paths easily as well as well as change
assignments in typical long-style arguments.

But I'm bothered that the context is derived according to a glob match I
explicitly defined, and not by the completion function. Seems like I'm
defining the context of each word twice, once for the completer and once
again for zle.


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

* Re: Changing subword-range according to current completion context
  2017-11-03 11:52 ` Changing subword-range according to current completion context Yuri D'Elia
@ 2017-11-03 12:23   ` Peter Stephenson
  2017-11-03 14:57     ` Yuri D'Elia
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2017-11-03 12:23 UTC (permalink / raw)
  To: zsh-workers

On Fri, 3 Nov 2017 12:52:10 +0100
Yuri D'Elia <wavexx@thregr.org> wrote:
> I'd like to fine-tune the way words are interpreted according to the
> completion context which was used to expand the word, not to the zle
> context.
> 
> Is it saved anywhere? Is it possible to correlate the two?

Hmm, I'm not sure that completion even has a generic notion of
words as such.  Each completion just parses the command line, generally
(but not necessarily) starting with a single command line word as
entered so far --- in this case parsed according to shell rules by
the lexical analyser, this is hard-wired because it's extremely
complicated --- and then takes it from there. I can't think of a point
where it matches neatly onto a single interface that tells you the bits
of what you're looking at.

Did you have an example?

pws


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

* Re: Changing subword-range according to current completion context
  2017-11-03 12:23   ` Peter Stephenson
@ 2017-11-03 14:57     ` Yuri D'Elia
  2017-11-04  1:22       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Yuri D'Elia @ 2017-11-03 14:57 UTC (permalink / raw)
  To: zsh-workers

On Fri, Nov 03 2017, Peter Stephenson wrote:
>> I'd like to fine-tune the way words are interpreted according to the
>> completion context which was used to expand the word, not to the zle
>> context.
>> 
>> Is it saved anywhere? Is it possible to correlate the two?
>
> Hmm, I'm not sure that completion even has a generic notion of
> words as such.  Each completion just parses the command line, generally
> (but not necessarily) starting with a single command line word as
> entered so far --- in this case parsed according to shell rules by
> the lexical analyser, this is hard-wired because it's extremely
> complicated --- and then takes it from there. I can't think of a point
> where it matches neatly onto a single interface that tells you the bits
> of what you're looking at.

Isn't the state of each word, once expanded, saved somewhere?
_complete_debug doesn't show anything interested.

By reading the manual, I'm not completely sure about the relationship
between match-words-by-style and match-word-context.

> Did you have an example?

Just to reiterate, imagine expanding a path. But the expansion needs to
be altered for some reason. I often kill the last path component.

If the context of the completer was saved, I could say that *only*
expanded paths get splitted by '/', and not other arguments.

I'm not sure it would be "terrific" in practical terms, as for this kind
of interaction you need to play around and see if it's worth the
tweaking.


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

* Re: Changing subword-range according to current completion context
  2017-11-03 14:57     ` Yuri D'Elia
@ 2017-11-04  1:22       ` Bart Schaefer
  2017-11-04 10:41         ` Yuri D'Elia
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2017-11-04  1:22 UTC (permalink / raw)
  To: Yuri D'Elia, zsh-workers

On Nov 3,  3:57pm, Yuri D'Elia wrote:
}
} Isn't the state of each word, once expanded, saved somewhere?

Not really, unless the completion function is designed to do so.  The
only things that persist from any call of completion to the next are
which completion widget was used and what comprises the previous list
of possible maches, and all that is lost if any other kind of edit or
motion intervenes between calls to completion.

} By reading the manual, I'm not completely sure about the relationship
} between match-words-by-style and match-word-context.

Those are entirely separate widgets and have no relation to completion
(aside from everything being ZLE widgets, of course).  They merely make
an identification of the start and end of the word under or adjacent
to the cursor by using simple syntax rules; they know nothing otherwise
of command context or of how the word was added to the editor buffer.


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

* Re: Changing subword-range according to current completion context
  2017-11-04  1:22       ` Bart Schaefer
@ 2017-11-04 10:41         ` Yuri D'Elia
  0 siblings, 0 replies; 5+ messages in thread
From: Yuri D'Elia @ 2017-11-04 10:41 UTC (permalink / raw)
  To: zsh-workers

On Fri, Nov 03 2017, Bart Schaefer wrote:
> Not really, unless the completion function is designed to do so.  The
> only things that persist from any call of completion to the next are
> which completion widget was used and what comprises the previous list
> of possible maches, and all that is lost if any other kind of edit or
> motion intervenes between calls to completion.

I figured this would be the case.
Keeping it in sync would be quite hard as well.

Well, I'll keep to the the word-context approach for now.
Feels barbaric, but does the job. ;)


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

end of thread, other threads:[~2017-11-04 10:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20171103121014epcas2p1342033fa4eb58a6d7f61400c619d0b52@epcas2p1.samsung.com>
2017-11-03 11:52 ` Changing subword-range according to current completion context Yuri D'Elia
2017-11-03 12:23   ` Peter Stephenson
2017-11-03 14:57     ` Yuri D'Elia
2017-11-04  1:22       ` Bart Schaefer
2017-11-04 10:41         ` Yuri D'Elia

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