From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29017 invoked by alias); 20 Jun 2017 18:02:37 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22741 Received: (qmail 17389 invoked from network); 20 Jun 2017 18:02:36 -0000 X-Qmail-Scanner-Diagnostics: from mout.gmx.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.227.17.22):SA:0(-1.0/5.0):. Processed in 0.777799 secs); 20 Jun 2017 18:02:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: dominik.vogt@gmx.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at gmx.de designates 212.227.17.22 as permitted sender) Date: Tue, 20 Jun 2017 19:02:14 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: Completions from file with zcompsys Message-ID: <20170620180214.GA5281@gmx.de> Reply-To: dominik.vogt@gmx.de Mail-Followup-To: zsh-users@zsh.org References: <20170620074605.GA3709@gmx.de> <170620102727.ZM5792@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <170620102727.ZM5792@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:z4WWG/WArklhHWSfzE/MXePmUU1oEFcFBP/SsYgMpuCM67UuPax s5XQMAP9l2JWQwMEsFu1SJrVRS9E+FbE07NlZl//JeKFYC9lX+Rn7j3Rg9yi3awL7qaDELv hEoCBCOlkfWO2xHm4Ffu3z4FP57TsXHrcCSOuCqNyzGQaUmUrO4Ae+iUYAo2QckLN747Mn+ xWfLvTdCjArFj2icDE+vQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Aw5W+nydpfk=:/t1BIGlKHau2N3sa7fklcL zcDHyN1iXg/CFrPgUoAWgRPbQT8XzO94WASH5ncv9YwEbn7c7iBbtHo6zY4n9Io+VPeuTosRq gOSrWSmEFm8B/X/Q3P6XcZfZDdAHCAAND6fc+uYQNw4GEQ48mQSg1iJvKCcCcY1INlsSqTkgp ylJwdrxd35EiXAR6ta5ho2uEEbrUuiZxigccera/wsznNzxepRlEXaKBdf5psNaKbgXbwElT4 vIwhFtPUjop/oVGY2zVhwKGo+P17sNlHbPk8Sf1wjNqtCK7xP0UOy4wACRav1dT15U2MzPrmW J+jqnIoO66GW8/oQ/hQ0kSePYZHx0PpAp3r/8nSYJ7VWkzNJ2yknmlXvrMZRduZRqjZFYnJON f1mKrfwVqGV6hGRygZtmOAJt+VrbXOHqYjQR6lJlrRAxtcaEMpXegDxNZkcLLGm+6yb+8QYSx b/SekbHFrNNZPW5cEQtVkbgggNOKFifmpJlhBO1n0hh0N91q1VSbEsPwU5wZTbYeWsbBXx5A7 W47dBfi98Xz0BVDD8+FWIqajiAWz2RYpAujzRm4f4QirRcc24FUv+e0f5pz8oBVAF400ibTpE K3n2pJiZW64kE6WCPb6rXxbKIaPwStZmjHFAstKq7LsWDfk+MiWhkQS0dbE6ssM2i0MrZt0pP AAwR5ZExqH9ZkiyKmrfWTpC1FchCCrklg6v7XSnSk+SRHOIutjvJnLeTSgnchPoGR+HmIQKXe z/Nx2nJoZ+QAcnpxzYML87daUFOnp3CTDwSYEZ/Gk5NlS5iLrl0JTlYI4QY= On Tue, Jun 20, 2017 at 10:27:27AM -0700, Bart Schaefer wrote: > On Jun 20, 8:46am, Dominik Vogt wrote: > } > } Are there some quick instructions instructions or a > } cheat sheet on the new completion system somewhere? > > http://zsh.sourceforge.net/Guide/zshguide06.html#l144 (perhaps?) > > } And I want to type things like > } > } $ foo Chenoalb # -> Chenopodium album > } $ foo Che*a # -> Chenopodium a > } > } (using menu completion, not expanding the * to all matching > } completions). > > The latter one could be tricky because you will have to prevent the "*" > from being expanded as a file glob. If a different "globbing" character would be easier to implement, or a completely different way to allow partial searches in both words of the plant name at the same time, that's fine as well. It does not have to be the asterisk. Maybe just moving the cursor to the beginning of the second word before pressing is good enough. > Do you want the expansions exactly as you wrote them, or should the > spaces be quoted? E.g. do you want to end up with something like one > of > > $ foo 'Chenopodium album' > $ foo Chenopodium\ album <-- this one is the easy one below Yep. All the command will do is print its arguments, one per line, so the spaces need to be quoted. The purpose of the "command" is to transfer lists of plants I've seen outside from a notebook (paper) to a file. Such names are very repetitive so completion would save a lot of work, and it perfectly suits the problem to solve. > You can also pass a string to be eval'd to compdef, so the simplest answer > to your question is (guessing at a file name) > > compdef 'compadd ${(f)"$(<~/latin-plant-names.txt)"}' foo Ah, that seems to be even simpler than the old system. Since I've switched to the new completion system I really had no need to define custom completions, so there was no chance to learn about it. :-) > Then to get the "*"-expansion you will need to add the _match function > to your completer zstyle. Example might be > > zstyle ':completion:*' completer _complete _match > > but adjust the placement of _match to fit whatever your current list of > completers contains. It would normally be anywhere after _complete. Okay, I'll read up on this part to figure out how it works exactly. Thanks for your advice. -- Trying that there is a slight problem. The file has 9529 lines; now, when you type something like Chenopodium x (where no such taxon exists in the file), zsh starts gobbling 100% cpu for about half a minute before completing an approximate match. This has probably to do with these zstyle lines: zstyle ':completion:*' completer _complete _match _approximate zstyle ':completion:*:match:*' original only zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)' Hm, it even takes a lot of time with just zstyle ':completion:*:approximate:*' max-errors 1 numeric (zsh-4.3.17) Ciao Dominik ^_^ ^_^ -- Dominik Vogt