zsh-users
 help / color / mirror / code / Atom feed
* completion inside vared
@ 2022-02-17 10:01 Pier Paolo Grassi
  2022-02-18 23:08 ` Pier Paolo Grassi
  0 siblings, 1 reply; 7+ messages in thread
From: Pier Paolo Grassi @ 2022-02-17 10:01 UTC (permalink / raw)
  To: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

Hello, when I execute the widget _complete_help inside vared I get:

tags in context :completion::complete:-value-,a,::
    use-compctl    (_default _value _value _in_vared)
    globbed-files  (_files _default _value _value _in_vared)

I would like to modify this to only display file completion when I call
vared from a certain function, how can I do it?
I tried with:
zstyle ':completion::complete:-value-*:*' completer _files
and
zstyle ':completion::complete:*' completer _files
but
 use-compctl    (_default _value _value _in_vared)
is still there, and I get various completion suggestion that aren't files
(or folders) in the current directory, such as environment variable names,
executable names, etc

thanks

Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1156 bytes --]

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

* Re: completion inside vared
  2022-02-17 10:01 completion inside vared Pier Paolo Grassi
@ 2022-02-18 23:08 ` Pier Paolo Grassi
  2022-02-18 23:39   ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Pier Paolo Grassi @ 2022-02-18 23:08 UTC (permalink / raw)
  To: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 955 bytes --]

does anyone has some clue as to where I can find how to do this?

Il giorno gio 17 feb 2022 alle 11:01 Pier Paolo Grassi <pierpaolog@gmail.com>
ha scritto:

> Hello, when I execute the widget _complete_help inside vared I get:
>
> tags in context :completion::complete:-value-,a,::
>     use-compctl    (_default _value _value _in_vared)
>     globbed-files  (_files _default _value _value _in_vared)
>
> I would like to modify this to only display file completion when I call
> vared from a certain function, how can I do it?
> I tried with:
> zstyle ':completion::complete:-value-*:*' completer _files
> and
> zstyle ':completion::complete:*' completer _files
> but
>  use-compctl    (_default _value _value _in_vared)
> is still there, and I get various completion suggestion that aren't files
> (or folders) in the current directory, such as environment variable names,
> executable names, etc
>
> thanks
>
> Pier Paolo Grassi
>
-- 
Pier Paolo Grassi

[-- Attachment #2: Type: text/html, Size: 1696 bytes --]

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

* Re: completion inside vared
  2022-02-18 23:08 ` Pier Paolo Grassi
@ 2022-02-18 23:39   ` Bart Schaefer
  2022-02-19 17:27     ` Pier Paolo Grassi
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2022-02-18 23:39 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Zsh-Users List

On Fri, Feb 18, 2022 at 3:09 PM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> does anyone has some clue as to where I can find how to do this?

Been busy and didn't have a chance to respond before.

The _in_vared completer forces use of _value which calls _default.  A
side-effect of _default is that compctl completions are attempted.

So what you need is:
zstyle ':completion::complete:-value-*:*' use-compctl no

Or if you want it to be specific to vared, something like:
zstyle -e ':completion::complete:-value-*:*' use-compctl '[[
$funcstack = *_in_vared* ]] && reply=no'

which admittedly is a bit convoluted ... _in_vared probably ought to
be doing some style checks of its own rather than pushing everything
down to _value.


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

* Re: completion inside vared
  2022-02-18 23:39   ` Bart Schaefer
@ 2022-02-19 17:27     ` Pier Paolo Grassi
  2022-02-21 19:27       ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Pier Paolo Grassi @ 2022-02-19 17:27 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

yes that worked (apart from a space to be added between [[and $ funcstack),
thanks.
I'm having another annoyance:
when I exit with ctrl-c from

vared -ehp $prompt text

the history file gets emptied. I tried
trap 'zle send-break' INT
but it doesn't change the result

Is there something I can do to exit from vared with a key combination
(ctrl-d only works if the line is empty) without losing the history?
I could use zle to send the kill-whole-line widget, but how do I send
ctrl-d then? Is it possibile with zle to send key combinations?

thanks

Pier Paolo Grassi


Il giorno sab 19 feb 2022 alle ore 00:39 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Fri, Feb 18, 2022 at 3:09 PM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > does anyone has some clue as to where I can find how to do this?
>
> Been busy and didn't have a chance to respond before.
>
> The _in_vared completer forces use of _value which calls _default.  A
> side-effect of _default is that compctl completions are attempted.
>
> So what you need is:
> zstyle ':completion::complete:-value-*:*' use-compctl no
>
> Or if you want it to be specific to vared, something like:
> zstyle -e ':completion::complete:-value-*:*' use-compctl '[[
> $funcstack = *_in_vared* ]] && reply=no'
>
> which admittedly is a bit convoluted ... _in_vared probably ought to
> be doing some style checks of its own rather than pushing everything
> down to _value.
>

[-- Attachment #2: Type: text/html, Size: 2263 bytes --]

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

* Re: completion inside vared
  2022-02-19 17:27     ` Pier Paolo Grassi
@ 2022-02-21 19:27       ` Bart Schaefer
  2022-02-21 21:55         ` Pier Paolo Grassi
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2022-02-21 19:27 UTC (permalink / raw)
  To: Pier Paolo Grassi; +Cc: Zsh-Users List

On Sat, Feb 19, 2022 at 9:28 AM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> yes that worked (apart from a space to be added between [[and $ funcstack), thanks.

Something to do with gmail line wrapping/unwrapping, sorry.

> Is there something I can do to exit from vared with a key combination (ctrl-d only works if the line is empty) without losing the history?

Which history is getting lost?  The global shell history i.e. $HISTFILE?

Have you tried exiting vared with ctrl-g ?  Does that have the same problem?


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

* Re: completion inside vared
  2022-02-21 19:27       ` Bart Schaefer
@ 2022-02-21 21:55         ` Pier Paolo Grassi
  2022-03-11 17:37           ` Pier Paolo Grassi
  0 siblings, 1 reply; 7+ messages in thread
From: Pier Paolo Grassi @ 2022-02-21 21:55 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]

>Which history is getting lost?  The global shell history i.e. $HISTFILE?
no, before invoking vared I do

fc -p -a $file 200 200

to have an history specific for the command

I just found out that replacing my previous trap with
trap 'return 1' INT

the history file is preserved after a ctrl-c.
If I instead do ctrl-g (send-break) the history file gets "cleaned" again
by cleaned I mean not really empty, but a file that contains just the first
row of the history, for example
if the history file contained:

: 1645479991:0;./Desktop/
: 1645480234:0;./Mail/
: 1645480247:0;./nltk_data/

and I enter vared, than send ctrl-g, the file contains then only

: 1645479991:0;./Desktop/

Is it possible to catch send-break? is it implemented through a trappable
signal?

thanks

Pier Paolo Grassi


Il giorno lun 21 feb 2022 alle ore 20:27 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:

> On Sat, Feb 19, 2022 at 9:28 AM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > yes that worked (apart from a space to be added between [[and $
> funcstack), thanks.
>
> Something to do with gmail line wrapping/unwrapping, sorry.
>
> > Is there something I can do to exit from vared with a key combination
> (ctrl-d only works if the line is empty) without losing the history?
>
> Which history is getting lost?  The global shell history i.e. $HISTFILE?
>
> Have you tried exiting vared with ctrl-g ?  Does that have the same
> problem?
>

[-- Attachment #2: Type: text/html, Size: 2333 bytes --]

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

* Re: completion inside vared
  2022-02-21 21:55         ` Pier Paolo Grassi
@ 2022-03-11 17:37           ` Pier Paolo Grassi
  0 siblings, 0 replies; 7+ messages in thread
From: Pier Paolo Grassi @ 2022-03-11 17:37 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 2013 bytes --]

I will try to bump up this question once more, since I am stuck on this

tldr: I would like to be able to use the send-break zle widget inside vared
to exit it, but when I do, the history file is cropped to one line.
Initially I had the same problem with ctrl-c, but I found out that a
trap 'return 1' INT
is able to prevent the behaviour in that case

thanks for any further help

Pier Paolo Grassi


Il giorno lun 21 feb 2022 alle ore 22:55 Pier Paolo Grassi <
pierpaolog@gmail.com> ha scritto:

> >Which history is getting lost?  The global shell history i.e. $HISTFILE?
> no, before invoking vared I do
>
> fc -p -a $file 200 200
>
> to have an history specific for the command
>
> I just found out that replacing my previous trap with
> trap 'return 1' INT
>
> the history file is preserved after a ctrl-c.
> If I instead do ctrl-g (send-break) the history file gets "cleaned" again
> by cleaned I mean not really empty, but a file that contains just the
> first row of the history, for example
> if the history file contained:
>
> : 1645479991:0;./Desktop/
> : 1645480234:0;./Mail/
> : 1645480247:0;./nltk_data/
>
> and I enter vared, than send ctrl-g, the file contains then only
>
> : 1645479991:0;./Desktop/
>
> Is it possible to catch send-break? is it implemented through a trappable
> signal?
>
> thanks
>
> Pier Paolo Grassi
>
>
> Il giorno lun 21 feb 2022 alle ore 20:27 Bart Schaefer <
> schaefer@brasslantern.com> ha scritto:
>
>> On Sat, Feb 19, 2022 at 9:28 AM Pier Paolo Grassi <pierpaolog@gmail.com>
>> wrote:
>> >
>> > yes that worked (apart from a space to be added between [[and $
>> funcstack), thanks.
>>
>> Something to do with gmail line wrapping/unwrapping, sorry.
>>
>> > Is there something I can do to exit from vared with a key combination
>> (ctrl-d only works if the line is empty) without losing the history?
>>
>> Which history is getting lost?  The global shell history i.e. $HISTFILE?
>>
>> Have you tried exiting vared with ctrl-g ?  Does that have the same
>> problem?
>>
>

[-- Attachment #2: Type: text/html, Size: 3380 bytes --]

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

end of thread, other threads:[~2022-03-11 17:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 10:01 completion inside vared Pier Paolo Grassi
2022-02-18 23:08 ` Pier Paolo Grassi
2022-02-18 23:39   ` Bart Schaefer
2022-02-19 17:27     ` Pier Paolo Grassi
2022-02-21 19:27       ` Bart Schaefer
2022-02-21 21:55         ` Pier Paolo Grassi
2022-03-11 17:37           ` Pier Paolo Grassi

Code repositories for project(s) associated with this 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).