From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: Select completions from the minibuffer Date: Tue, 22 Mar 2022 20:24:14 +0100 Message-ID: <20220322192414.imcbntimg7d35cdn@Ergus> References: <86h7817mj4.fsf@mail.linkov.net> <87ilsgx5fx.fsf@gnus.org> <86bkxz3y1h.fsf@mail.linkov.net> <875yo7p0hh.fsf@gnus.org> <86v8w675un.fsf@mail.linkov.net> <837d8mf6pf.fsf@gnu.org> <20220322141815.2iq7jec2d5lvfox3@Ergus> <831qyuf3e0.fsf@gnu.org> <20220322152150.xnghbiufg6fvspio@Ergus> <864k3p6cxe.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="73p6tnc2zrmfgxwr" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14652"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , larsi@gnus.org, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 22 20:26:07 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 1nWk8t-0003Ww-Ff for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Mar 2022 20:26:07 +0100 Original-Received: from localhost ([::1]:50680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWk8p-0005qC-FC for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Mar 2022 15:26:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWk7t-00057d-OB for emacs-devel@gnu.org; Tue, 22 Mar 2022 15:25:05 -0400 Original-Received: from sonic317-26.consmr.mail.bf2.yahoo.com ([74.6.129.81]:43283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWk7r-0002qA-2b for emacs-devel@gnu.org; Tue, 22 Mar 2022 15:25:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1647977098; bh=WgagRiaxVv7AcwdouQBTSZbgTgWlpLrcVoeapyd/eN0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=Ojl9uTvtn67WUV4VgrXRqfKl6nFM4cHiW8qlCOwco1T3tzNWpYHLpc/E6Kahi8AlCr875kNPmQH7Cq60nGbhxxhOl+itaObnuG7KyjKnQrXHitTNWG8+QzwTUWNtFiofoj4ElHSzkLRmVAEE2vm5ENZDgVUBh/Z7QhQn0azLG+NAt+5Bs7jXqvVh5RNaZPWjz9g2FsyxmEs2lHfZCSprXPpFVulFrzpuLpktv04mchOk4g9t+qTLHniVsmu9pyubRFc/hlnhXq52uRGQGgDuNrEViaa4f951wQ1K+cCzVnMG2V34Vx117O0ktEAxpU8dyO5rcAmMWYCZ9Yel/EN88g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1647977098; bh=IkyISJ7QWsu7fqDKLsz4yP36iq757ORQZXOF7w0gPOd=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=l3S8MnfjxVxSP80xARq30PYZeZw7F8jam4/H7aPa6XbHtJns4Lb2wgB5Tx6BBsiKrGf4TlZ1s87AK9zmhMHmxW5RwqgZL0XNPvMl//K9r2dcGI54Do8z7vAnFiVmHLWHU7d538Ejg0fUv/A3QsfA4g2YyBMHem30+B2Hfg7ZnoSutp+hoyw2P01oOx2EYJZ00xy2wmXwg+k2liFTieZTLOPTTM90HOqLhRafT3O3+4nGf2R/IbIh00sMnXeeFrotf4uyfkKAaFkogJ16ne6FOAceBkUMdViRcFFRmMO7nE4fSEhIEZijP46C+6b3//SzNnNbbt4WVroWHyYXiar4+g== X-YMail-OSG: Q0t.SgcVM1lTMOlkdWOedycAFCntoCZi8mLQ_BzYp3DSxjN1aV8DGKU4c.GywPU 9gglDZHXKhtqlyIYHbwQQYz4g4yDBZgSZny5C2KJpHpDBV_UQKEJu25FCF0E21sBJW9HRIZypGV8 T.gRQqgn.iD7K.EC52kuE9wv0I0Es8GKsWgw1qzVPkM1kBhD6GumJ5SyqseleL8QVaOj917BWB0U 5kUFSI_JPxyIPfaHTIrIG95xIGY5IRFd.EJ463Hb2P1EhEY2jWHbBGA7vouxDoaMdgknZOC3.8R3 _Fnb8XGLsewG803rwByQ3COrjXj_ud9SqANMzkkuDVUpgvnGMGaJxDPyJ1Q5zlhf5srADCo2iRyj pwgp440WBA2Tiis6bs2HkJ4Of_uiGmoqCljr.FHod16Ob5pa2TLjtI1oJkTVp8wp8NxtovENwdfm E1.cuz1fReEJcusGMT.RTmH27U_3RH.vvExmTPi4TPsYRx2gDVCt1mYVPrZXS0fekdpL9Pkr1CvX DPSMa8.P6vBnVoe8jis9HNVDhOJqtwUvOcswKeS7VrOiI9QvpdPoIcdQLv4GtLu35I6lVjGCtTIi F7bgnjSaTVAwI0WLmAUGuVj1YGt7AnreoxXK1kg139ZXiA0RYWukJ3T1XONEpkPRpJJF8WCdGcgj pVqcHOgvEB7rAd9P5ahmGq7hFKsdahh0jRAYua1kHeb2hnSHF9DkvULeKf83Kj0B0sFmwdN48vkf kQW7GuLi4YY4I06QbJw8PNTeETk9BFM6CC_BnOth3sTQdu3qumqRICT6Ku6q3ncwy3SwV4jC1uWV FJtjFmjyodj_iDB1C95kX1U50IrnV_IVCj3eDB8fcz X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.bf2.yahoo.com with HTTP; Tue, 22 Mar 2022 19:24:58 +0000 Original-Received: by kubenode501.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID e86ab2e387cc0ef356edd33f5eff37eb; Tue, 22 Mar 2022 19:24:54 +0000 (UTC) Content-Disposition: inline In-Reply-To: <864k3p6cxe.fsf@mail.linkov.net> X-Mailer: WebService/1.1.19894 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.129.81; envelope-from=spacibba@aol.com; helo=sonic317-26.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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:287372 Archived-At: --73p6tnc2zrmfgxwr Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On Tue, Mar 22, 2022 at 08:38:45PM +0200, Juri Linkov wrote: >> First tab: attempts to complete common and shows completions >> Second tab: go to completions and select first candidate. >> Following tabs: move to next candidate > >This is exactly what happens when completion-auto-select is t. > Look at the attached patch that produces this behavior... I am not sure is we want to add it, but it is useful in my case to mix completion-auto-help 'always/'visible completion-auto-select 'second-tab If you think this is useful I may add it to a branch and add some documentation. Best, Ergus --73p6tnc2zrmfgxwr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="second-tab.patch" diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 00d4560865..f38db6d278 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1407,18 +1407,26 @@ completion--in-region-1 ;; and this command is repeated, scroll that window. ((and (window-live-p minibuffer-scroll-window) (eq t (frame-visible-p (window-frame minibuffer-scroll-window)))) - (let ((window minibuffer-scroll-window) - (reverse (equal (this-command-keys) [backtab]))) + (let ((window minibuffer-scroll-window)) (with-current-buffer (window-buffer window) - (if (pos-visible-in-window-p (if reverse (point-min) (point-max)) window) - ;; If end or beginning is in view, scroll up to the - ;; beginning or end respectively. - (if reverse - (set-window-point window (point-max)) - (set-window-start window (point-min) nil)) - ;; Else scroll down one screen. - (with-selected-window window - (if reverse (scroll-down) (scroll-up)))) + (cond + ;; here this is possible only when second-tab, so jump now. + (completion-auto-select + (switch-to-completions)) + ;; reverse tab + ((equal (this-command-keys) [backtab]) + (if (pos-visible-in-window-p (point-min) window) + ;; If beginning is in view, scroll up to the end + (set-window-point window (point-max)) + ;; Else scroll down one screen. + (with-selected-window window (scroll-down)))) + ;; normal tab + (t + (if (pos-visible-in-window-p (point-max) window) + ;; If end is in view, scroll up to the end + (set-window-start window (point-min) nil) + ;; Else scroll down one screen. + (with-selected-window window (scroll-up))))) nil))) ;; If we're cycling, keep on cycling. ((and completion-cycling completion-all-sorted-completions) diff --git a/lisp/simple.el b/lisp/simple.el index 9a8ed0bb75..f229608690 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9144,6 +9144,14 @@ completion-wrap-movement :version "29.1" :group 'completion) +(defcustom completion-auto-select nil + "Non-nil means to automatically select the *Completions* buffer." + :type '(choice (const :tag "Select window" t) + (const :tag "Disabled" nil) + (const :tag "Select window on second-tab" second-tab)) + :version "29.1" + :group 'completion) + (defun previous-completion (n) "Move to the previous item in the completion list. With prefix argument N, move back N items (negative N means move @@ -9365,12 +9373,6 @@ completion-show-help :version "22.1" :group 'completion) -(defcustom completion-auto-select nil - "Non-nil means to automatically select the *Completions* buffer." - :type 'boolean - :version "29.1" - :group 'completion) - ;; This function goes in completion-setup-hook, so that it is called ;; after the text of the completion list buffer is written. (defun completion-setup-function () @@ -9411,8 +9413,8 @@ completion-setup-function (insert (substitute-command-keys "In this buffer, type \\[choose-completion] to \ select the completion near point.\n\n"))))) - (when completion-auto-select - (switch-to-completions))) + (if (eq completion-auto-select t) + (switch-to-completions))) (add-hook 'completion-setup-hook #'completion-setup-function) --73p6tnc2zrmfgxwr--