From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19290 invoked from network); 21 Mar 2021 15:25:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Mar 2021 15:25:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616340339; b=wMD20oAnQRSvU33/4mFuaiqBqJlSbUhl6l89cWPmSNuLuAvvEziGnSmHRdBRtvYrN9KSZtEBnI 0Wip8BphYppsSePupHaQWt5Vv3WW2JlkmjIPqIZNd1lzdzw2BMbQuO7h3JGVmTJXhRHX24d4m1 h7ZqKENSQFi9IIzJP46IuhziM4c7pjBjebiAoapjbq07CSC/Pt0bfmJsWRa4lhsB95vd16Qg+Q 92BzaMD6p86PX9x3Fg58uIZJVPhm0OZx/ROvya8wYj/PLNj5WUfBG2Z2fklEIhl1xOLCB3+aSt 2mM9DqbfK04zDt9gBtuAvlmdnIKQrBuOQ/P1rf5WF5nXnw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f54.google.com) smtp.remote-ip=209.85.167.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1616340339; bh=SZv/vTiSEwW56uyKHpt2//c7kMBTbatlPFhvSrZnb0g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=jyBHVTFv0PLvGlg0wkdqgBeiOSYuz6FQAUKR7lVYsyT4DBsnGjy7w5vFrMgHvVGfOpJovom0BR eGZw/c+aHjO0K1gj6ORikHxLkoLbVs3Def/ieI7vpslqwcyy5+qK+1pmFp4PDqj0o43cVUUma3 uLpdaKTcKN5+4Z5JZmxLM53wWb1jfpgyX//RBPgssalZj/tnVGsAud+Ukvi0otcfNpOZ4Qz/tO MkZspbRpf9A0Rb/ql6NmTOwWaXsB/DIXGWUrV8if0P4clzlAFBZX8iWoUyCZoeUYrMhkCFptQ7 QQi318/dHtRUGInVDZeeWsTj6tMlOqq9BLdHQhtXtGaznQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=A0oyeiNOwun4YzAyhBnX8YXU2rZ/yTGr76dHk9gpnZg=; b=JExEI453PD5Kacx/pL/uVEjpl5 mm12gcMzpwPbdMj9E2Q7H3N4Bejcr40NSBIW+J4+WRZT8/2pM6ZwmoLEfDA/+pEsY4s3Su+ERxrGA 9MgPEWhclNG7ntcjOV74OQY9AbffShcsD2Y/U4FPZHkgPluDKFcQDk02NDYwb+xsPbdDc27WE/cw8 QMWSFLYJJIASCoI1FLzX6s0GCSGNryPzuzOVuVYua6m0tGW9p4jKZbYXKiW6lExcd31N4++H3fNfo RFTYabiliBiMDEeca6vN7fW9NW4lPljz50ufwApcnM9s/SbFTWdebtXIo9i9iIlZ1ILzW6D65JTv0 Wss40f3Q==; Received: from authenticated user by zero.zsh.org with local id 1lNzxS-0007V8-Ro; Sun, 21 Mar 2021 15:25:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f54.google.com) smtp.remote-ip=209.85.167.54; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f54.google.com ([209.85.167.54]:38785) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lNzxI-0007MU-H0; Sun, 21 Mar 2021 15:25:29 +0000 Received: by mail-lf1-f54.google.com with SMTP id f3so9039636lfu.5 for ; Sun, 21 Mar 2021 08:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=A0oyeiNOwun4YzAyhBnX8YXU2rZ/yTGr76dHk9gpnZg=; b=XOzjt5JTDIp+tC+lfAESaHeICDF1f5b9C7kvmDolDjC8eyAFL+lpIsx7xw6GJ7D1M9 Wxtw33iqv5Ypz7zTji6G2KRYl8KasmaNO82io+OKhtXS4wI7LjIFHZV5afTiKzWGd9hU uPW8ZIDEQfsQUJVeEcyYjQqo1hd2Ana4qMK87yVB/GIcYELGxSHoxs2ZSEZOwVF/6/6N VZc2gk+FyK4XX5afWxuI7g4ICy8TtIqGw5t4OG5mL7//0citK8OIOKyxGP83SKqr04oA M8hGJo31IyJG4fdlneBu0ur7RMjKrbKI5UG+41IUISUb4QZvwUfNu0bRU5QQLCGI7rF2 CQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=A0oyeiNOwun4YzAyhBnX8YXU2rZ/yTGr76dHk9gpnZg=; b=inyh5+qlkTq7CTVHcJSPOhWogeR1iBHdxnCXcuXAbZvmqwY1fGBTK5e4/4hqCzLCMV iJfMFyRe/WHf6ozn4965H0EGapN7I8RMaJ3vTQ1iXzAX6PqFVE68ZslsXar+OTE3NgfR mHJQO+Au07dwYOCTQRyxwbBAW6WWMTmCvAz+Rz7VIt3ys8+CqqcF32rADRakXbvs6+cC o5Q3hF/G2rOXH3Ymkc77PgTUki63rInD8/Dli2jOxYwRD0Ik7WFFrYV8LMxOqltEgMWv jYI6lxpXJTY8Uas1Tf+CxBfcUjsOOSJ1hB4oPbGe0ZCXqgfbVizPea0V32j2H/Gm3VEm Ashg== X-Gm-Message-State: AOAM5332CaPqHiS5LoJTknFt+CxXs2KoF4JBViKXrkU66R6Ypzg4NsW5 fpStcHNzVZdp17bPcjW4l1ST7GEYnwueG3R4Fnjg5o5bAwLyEQ== X-Google-Smtp-Source: ABdhPJxiEf57B/yfMLc+NIMM4nvQouxfUMF7pO+eDgVZ1H5OkplAe7s2sdCXUmAScTkoUOj6EK4pYdMrzoD22qQxoQw= X-Received: by 2002:ac2:5fa2:: with SMTP id s2mr6400848lfe.486.1616340327795; Sun, 21 Mar 2021 08:25:27 -0700 (PDT) MIME-Version: 1.0 From: Marlon Richert Date: Sun, 21 Mar 2021 17:24:49 +0200 Message-ID: Subject: Patch: Add file types to _expand completions To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 48214 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: This adds file types to `_expand` completions, so they can be colored through complist. diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index def522a76..8e3a84f30 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -11,7 +11,7 @@ setopt localoptions nonomatch [[ _matcher_num -gt 1 ]] && return 1 -local exp word sort expr expl subd suf=" " force opt asp tmp opre pre epre +local exp word sort expr expl subd pref suf=" " force opt asp tmp opre pre epre local continue=0 (( $# )) && @@ -214,9 +214,10 @@ else normal=( "$normal[@]" "$i" ) fi done - (( $#dir )) && compadd "$expl[@]" -UQ -qS/ -a dir - (( $#space )) && compadd "$expl[@]" -UQ -qS " " -a space - (( $#normal )) && compadd "$expl[@]" -UQ -qS "" -a normal + pref="${${word:#[~/]*}:+$PWD}/" + (( $#dir )) && compadd "$expl[@]" -fW "$pref" -UQ -qS/ -a dir + (( $#space )) && compadd "$expl[@]" -fW "$pref" -UQ -qS " " -a space + (( $#normal )) && compadd "$expl[@]" -fW "$pref" -UQ -qS "" -a normal fi if _requested all-expansions; then local disp dstr diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index f6474c4a1..463686633 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -44,6 +44,25 @@ >line: {: dir1/}{} >line: {: dir2/}{} + comptest $': *\t\t\t\t\t\t\t' +0:_expand shows file types +>line: {: dir1/}{} +>DESCRIPTION:{expansions} +>DI:{dir1} +>DI:{dir2} +>FI:{file1} +>FI:{file2} +>DESCRIPTION:{all expansions} +>NO:{dir1 dir2 file1 file2} +>DESCRIPTION:{original} +>NO:{*} +>line: {: dir1/}{} +>line: {: dir2/}{} +>line: {: file1 }{} +>line: {: file2 }{} +>line: {: dir1 dir2 file1 file2 }{} +>line: {: *}{} + comptesteval '_users () { compadd user1 user2 }' comptest $': ~\t\t\t\t\t' 0:tilde diff --git a/Test/comptest b/Test/comptest index a36e301e0..cdb3ecc61 100644 --- a/Test/comptest +++ b/Test/comptest @@ -40,6 +40,7 @@ KEYTIMEOUT=1 setopt zle autoload -U compinit compinit -u +zstyle ":completion:*" completer _expand _complete _ignored zstyle ":completion:*:default" list-colors "no=" "fi=" "di=" "ln=" "pi=" "so=" "bd=" "cd=" "ex=" "mi=" "tc=" "sp=" "lc=" "ec=\n" "rc=" zstyle ":completion:*" group-name "" zstyle ":completion:*:messages" format "%d @@ -50,9 +51,9 @@ zstyle ":completion:*:options" verbose yes zstyle ":completion:*:values" verbose yes setopt noalwayslastprompt listrowsfirst completeinword zmodload zsh/complist -expand-or-complete-with-report () { - print -lr "" - zle expand-or-complete +complete-word-with-report () { + print -lr "" + zle complete-word print -lr - "$LBUFFER" "$RBUFFER" zle clear-screen zle -R @@ -80,11 +81,11 @@ zle-finish () { (( $+mark )) && print -lr "MARK: $mark" zle accept-line } -zle -N expand-or-complete-with-report +zle -N complete-word-with-report zle -N list-choices-with-report zle -N comp-finish zle -N zle-finish -bindkey "^I" expand-or-complete-with-report +bindkey "^I" complete-word-with-report bindkey "^D" list-choices-with-report bindkey "^Z" comp-finish bindkey "^X" zle-finish