From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: About zcomplete Date: Sun, 20 Feb 2022 11:11:00 +0000 Message-ID: <87wnhp4wu3.fsf@posteo.net> References: <20220220040515.zum3iodtpscj23j3.ref@Ergus> <20220220040515.zum3iodtpscj23j3@Ergus> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10800"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Juri Linkov To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Feb 20 12:14:43 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLkAs-0002cM-Ap for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Feb 2022 12:14:42 +0100 Original-Received: from localhost ([::1]:39564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nLkAr-0000pg-6G for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Feb 2022 06:14:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLk7Q-0007Op-Rw for emacs-devel@gnu.org; Sun, 20 Feb 2022 06:11:10 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:60717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nLk7M-00065w-4r for emacs-devel@gnu.org; Sun, 20 Feb 2022 06:11:08 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 082EC240026 for ; Sun, 20 Feb 2022 12:11:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1645355462; bh=vSgIRCQSAABRXsgNDcVEEq2w21eSTnTp1mYrcGIlXzk=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=k6zUAztuIf93eB3gSSsNGUHMD791c4oz4NJb030GwjYTJk8/3QBdWOUJadyBYuMyw HEFT/4b0cbnsyj4v+g/NhNxNrLgss5U860F7xuCQIFJ0aiRnQhtIRcUwtedBe5Vjks x8/c2FeLf6l21orMnzQKlk1Cs7S/eYa9aRlbxns6vlhdzRTrU2gPtTujdrgEDLq1De 9kAswpBM8KkmilVtoABwi7wAR87I8Zy7uTef/Y2yWRcY+XG21UfGGz7hmwtK6ALnMn V0RmQwyjpTVNTVBTEf7kWQ2CMef7HLE4pxwOnw7MqNlIBvo0QF6GC9ZslFJQ4P+bBp 2LU8sKsvexCpw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4K1jR92HMGz9rxD; Sun, 20 Feb 2022 12:11:01 +0100 (CET) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: <20220220040515.zum3iodtpscj23j3@Ergus> (Ergus's message of "Sun, 20 Feb 2022 05:05:15 +0100") Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286512 Archived-At: Ergus writes: > Hi recently I have been trying to move back to default completion. As > I had many issues with fido and icomplete. > > The default completion system received a nice improvement recently with > the completion-autoselect... and I am wondering a simple mode like > this may be added to vanilla (or at least it gives an idea to a better > lisper to implement something better, this is just a proof of concept.) > > ``` > (require 'simple) > (require 'minibuffer) > > (defvar-keymap zcomplete-map > :doc "Keymap used in *Completions* on zcomplete" > :parent completion-list-mode-map > "z" nil > "n" nil > "p" nil > "q" nil > "g" nil > "h" nil > "DEL" nil > ) When completion-auto-select was first added, there was a discussion about adding automatic narrowing in the *Completions* buffer. Given a mode like zcomplete, that decides to unbind all single-character bindings, this might be possible (as an alternative to what you do in zcomplete--try-on-minibuffer). Whether or not this should be coupled to removing the mode line of the completion buffer is a different question. > (defun zcomplete--try-on-minibuffer () > "Try to execute the binding on minibuffer." > (switch-to-minibuffer) > (if-let ((command (lookup-key (current-active-maps) > (this-single-command-keys)))) > (progn > (minibuffer-hide-completions) > (call-interactively command) > t) > ;; back to completions > (switch-to-completions) > nil)) > > (defun zcomplete--completions-pre-hook () > "Try on minibuffer when the command is not in *Completions* map." > (when (eq this-command 'undefined) > (zcomplete--try-on-minibuffer))) > > (defun zcomplete--hack (data context signal) > "Alternative to command-error-default-function. > This will try to execute on minibuffer, else emits the error" > (unless (and (string= (buffer-name) "*Completions*") > (zcomplete--try-on-minibuffer)) > (command-error-default-function data context signal))) > > (defun zcomplete--completions-setup-hook () > "To call on completions setup." > (add-hook 'pre-command-hook #'zcomplete--completions-pre-hook nil t) > > (setq-local command-error-function #'zcomplete--hack) > (setq-local mode-line-format nil) > (use-local-map zcomplete-map)) > > (define-minor-mode zcomplete-mode > "Completion highlight mode to enable candidates highlight in the minibuffer." > :global t > :group 'minibuffer > > (if zcomplete-mode > (progn > (setq completion-auto-select t) This should probably be reverted when zcomplete-mode is disabled. > ;; (overlay-put zcomplete-overlay 'face 'zcomplete) > (add-hook 'completion-setup-hook #'zcomplete--completions-setup-hook t)) > > (remove-hook 'completion-setup-hook #'zcomplete--completions-setup-hook))) > > (provide 'zcomplete) > ``` > > It lacks some features (like highlight the current candidate or > automatically update completion buffers when visible) to be really a > zsh-like feature, but at least we don't need to press C-g every time we > want to edit the minibuffer. > > With this a tab shows the completions and goes there, and any attempt to > edit or not defined command tries to execute on the minibuffer... > > Parts of this could be implemented with advises, but I know we try to > avoid those on vanilla code. If something like this would be added to the core, it would be better to patch the relevant sections directly. > WDYT? > Best, > Ergus > > -- Philip Kaludercic