zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: _history-complete-older problems with $(
Date: Tue, 12 Jan 2016 14:09:47 +0100	[thread overview]
Message-ID: <CAKc7PVBCEM=46YmgmhPR==Rq+pSfY+hgr8bcOMLV=zLFm6THBg@mail.gmail.com> (raw)
In-Reply-To: <160111161501.ZM5305@torch.brasslantern.com>

On 12 January 2016 at 01:15, Bart Schaefer <schaefer@brasslantern.com> wrote:
> The following produces the correct set of completion matches (pardon the
> unimaginative name) but is a bit of a hack (it breaks _complete_debug
> and _complete_help):

I think the hacks are acceptable if the code will be used only by
Alt-/ (_history-complete-older). How to accomplish this, btw? Probably
the context should be changed:

>   zstyle ':completion:*' completer _widen_for_history _complete

but I don't know how to do this exactly. Can you help?

>   _widen_for_history () {
>     local -a left=( "${(z)LBUFFER}" )
>     local right="${words[CURRENT]#${left[-1]}}"
>     words=( "${(z)BUFFER}" )
>     CURRENT=${#left}
>     *
>     PREFIX="${left[-1]}"

I've added following line where * is:

echo -e "\nCURRENT: $CURRENT, NEWCUR: $CURRENT, CURSR: $CURSOR, lft:
|$left|, rght: |$left|, words: >""$words[@]""<"

Example outputs are:
# ls<TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 2, lft: |ls|, rght: |ls|, words: >ls<
# ls <TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 3, lft: |ls|, rght: |ls|, words: >ls<
# $(<TAB>
CURRENT: 1, NEWCUR: 1, CURSR: 2, lft: |$(|, rght: |$(|, words: >$(<
# $( TAB
CURRENT: 1, NEWCUR: 1, CURSR: 3, lft: |$( |, rght: |$( |, words: >$( <

Are this expected values? Because despite proposing $(( 0 + 1 ))
correctly after $(<TAB>  (btw., not after $(<Alt-/>), the completer
behaves weird. For "ls <TAB>" it doesn't propose any files.

> This needs some work around the issue of empty words, i.e., when
> completing in empty parens such as $(<TAB>) then $words[CURRENT] is
> empty and the trailing paren must be copied from $RBUFFER to SUFFIX.
> I haven't dived into that detail.

I would gladly perform the work but the code is quite difficult. Could
you state in one sentence what it is doing? Variables $CURRENT, $word
aren't documented in zshzle.1. What does the {} always {} block of
code do? Next, I would guess that "builtin compadd -O found "$@""
performs one run of matching, is this correct? Why second comadd, and
what does "${(@)${(@)found#$PREFIX}%$SUFFIX}" do?

> Another approach would be to create a custom key binding for a widget
> which
>
> - inserts an open quote before the current word
> - invokes completion with completer style set to _history
> - removes quoting again
>
> but that has its own complications if the word on the line is already
> quoted, etc.

Maybe I could get the complications resolved for Zew. The separate key
binding seems close to what I want for Alt-/

Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2016-01-12 13:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10 19:35 Sebastian Gniazdowski
2016-01-11 16:21 ` Sebastian Gniazdowski
2016-01-12  0:15   ` Bart Schaefer
2016-01-12 13:09     ` Sebastian Gniazdowski [this message]
2016-01-12 19:39       ` Bart Schaefer
2016-01-13  1:01         ` Daniel Shahaf
2016-01-13  2:01           ` Bart Schaefer
2016-01-13 16:40             ` Sebastian Gniazdowski
2016-01-14  4:48               ` Bart Schaefer
2016-01-14 11:30                 ` Sebastian Gniazdowski
2016-01-14 11:37                   ` Sebastian Gniazdowski
2016-01-14 11:59                     ` Sebastian Gniazdowski
2016-01-15  3:18                   ` Bart Schaefer
2016-01-15  5:07                     ` Sebastian Gniazdowski
2016-01-15  6:26                     ` Daniel Shahaf
2016-01-14 18:55                 ` Sebastian Gniazdowski
2016-01-14  9:52               ` Sebastian Gniazdowski
2016-01-14 10:14                 ` Sebastian Gniazdowski
2016-01-14 10:55                   ` Sebastian Gniazdowski
2016-01-15  3:05                     ` Bart Schaefer
2016-01-15  6:26                 ` Daniel Shahaf
2016-01-13  1:01       ` Daniel Shahaf
2016-01-13  1:59         ` Bart Schaefer
2016-01-12  7:57 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKc7PVBCEM=46YmgmhPR==Rq+pSfY+hgr8bcOMLV=zLFm6THBg@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).