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: [PATCH] Re: Other details about completion. Date: Fri, 1 Apr 2022 22:24:25 +0200 Message-ID: <20220401202425.jfrwqmkm3ffmcm5h@Ergus> References: <20220401153839.idrzrbfl2yfzga3y.ref@Ergus> <20220401153839.idrzrbfl2yfzga3y@Ergus> <86r16g92v5.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="lo4lqqvnbizaozje" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23021"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 01 22:25:28 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 1naNpn-0005rO-GH for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Apr 2022 22:25:27 +0200 Original-Received: from localhost ([::1]:43462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1naNpm-00065U-2W for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Apr 2022 16:25:26 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naNp0-0005Mx-EU for emacs-devel@gnu.org; Fri, 01 Apr 2022 16:24:38 -0400 Original-Received: from sonic304-10.consmr.mail.bf2.yahoo.com ([74.6.128.33]:40301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1naNow-0003Ub-Gi for emacs-devel@gnu.org; Fri, 01 Apr 2022 16:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1648844672; bh=2v+G1d0Q/mXTAx1LbHNNzAN2OM8I1Jkgc50B+p89yaM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=pZqIuROWgkvaLKddiSniuHIUGEp0aJdpyfs7fOnkSvdR/ZjAUWLGddIpXhbjdXVOIVl7X+cbPZ7AbII8ClvHdIDnFFvsts7+YjaCvUJYH42jMRDX1cds4OKvlp3Em2n4aGJc+zz/IgK3qzbRgsPi7f5vxRetP5nfUoJizUwjSNRezojGGUp+vpnyekP3LrZiE/rM3GYFFJnQu9ADxtod8q1b3eUFtY2dy6O6CuPy5aYuQ6z5jlJl2wMXQbgn4EHUTwUCkSpgnszvL2bThwDvKIoGOxCqgCQDhdeqEW6YlIgvVoDrmHLWcnp+lMW8jnc57gmrpZfTY5DZXfDieOn6xg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1648844672; bh=QtCd2wMtJzCxxZDn7cI9OlTsitUXoM2FSQ0TxxH0fTH=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=rBNBxb9gPJ3b8NQqABy+a0RMiXoFY1ZOGdVG88EQkyffjlzGCJgnVgNQi+fRswOKMY4cWJBxNQNvuPpSAleIeMdGlRNImj8tlo5qlDApM8CMmhLfzqsrGDzJ9LNZ9Oq96c3lLIRubAvmIxuK/dNmJl0hYGIZ116jEAge3E2IfCO9JwhJ2Ai+Q6UuBRtWTbYkB6A0fLGwdgRL5DfuKxfwW41pKWgzFAKbpNOgHP4+8IQxH1nMlaY2HzAHXMX+11hTDAGgbGhpXzqr782CVK5Fzi79VNJjrgjEQp1mBonXO2ScSYOaklRx2Qf4sXL165AnlIzuCuZ6Dpp+X9psiKcRkw== X-YMail-OSG: rdKUQH4VM1kB1YsJlbVNlpzHLLQ11slCay5WMyBHQ5Ap2FBfh40ydebiql6u2w3 LHsnzhDsaiIOFv7nm8Foj2dN1hvy_ptPqDaJsw.dAO3wAyZU7HGakYtryoLrZbPKpWO_EhDafel_ QlRiv9lI9hSg9T3xLG3FoPt81JMLn4wx1CcwIqIOat8565EvH.tKfzQz.Xs6roIk2YDhrroaHa32 VRx4E.63q9yTvl0dNrdlhr3uq2ftTSOahJsC12KM9WRaNIxwJT.0OaFNxWUfe330DqvxvTZmF_us 9Zz5jna.0sqJdlE09jyUygV7.Wb28kvs7e5j5XniT.vyysNsIYfBTX0H9qwmUGsJyqfpBb42.gc6 wE9TnIzO0RcZHAIsnGldF.aAba5wbry.IQ_D23BBRLNmfJZbONs..vPrnRrG0Q6YhKd1ZCyRHtJI 1RwG_I.23gf1h3z1WdLfSi1lh3_qSZZkfZHI.xQu4jGYMOBazc..DCZbHTSCXMYsbJ4IahPzghI9 krvD7ejA57ctmY9lklll7T50XEfHN_UiqTZpzSWOcTU94HakmYXj_EsJyIggp9VphQfcI9hOeIpQ N29Ipjp2i2J5r9xwdZHxfV1W2eMR3bYOj9nggtlAcmUY5ie8wnNAcmtQvH5tXwUU9dBjcI9_0RzF L1B3C2D5fZAkTVIprhpk.lXApWh6XurdvF_FkcegvdjdcapJ4Wc6SnJxdaBL3LEP1Ql0I7NsFF9E P31tfcIPd8i3OnzCPf2yF.D1vAedzon8ZEY6B54qTdbQPll63GwZ5EMCJHYnt9.1mHG3SeQsvrRI kUNFj5km9k8k3lAdmZJubaRqFBQBM74gL4Oyx_KGyd X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Fri, 1 Apr 2022 20:24:32 +0000 Original-Received: by kubenode512.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 132a4984c9e5edfb7a3b5e9b45464956; Fri, 01 Apr 2022 20:24:30 +0000 (UTC) Content-Disposition: inline In-Reply-To: <86r16g92v5.fsf@mail.linkov.net> X-Mailer: WebService/1.1.20001 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.128.33; envelope-from=spacibba@aol.com; helo=sonic304-10.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=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:287685 Archived-At: --lo4lqqvnbizaozje Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Hi again... Here I attached a small patch that makes 3 small changes: 1) Remove the trailing newline in completions one-column 2) Use another condition in next-completion to jump to minibuffer. Normally next-completion with tabs at the end of the buffer needs an extra tab because it goes to the end of the last completion before jumping to the minibuffer or wrap.. That extra tab is because the condition to jump or wrap was eobp/bobp assuming that there is not text unproppertized after the last candidate. 3) Remove a comment in switch-to-completions. That comment suggested that the next-completion action must be called inside minibuffer-completion-help but IMO that is not totally correct when completion-auto-select has some of the new values. Please, if anyone could review,correct and push I would be very grateful. Best, Ergus --lo4lqqvnbizaozje Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="next-completion.patch" diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index d8df1799c9..5ad44a7a2d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2044,7 +2044,8 @@ completion--insert-one-column (when title (insert (format completions-group-format title) "\n"))))) (completion--insert str group-fun) - (insert "\n"))))) + (insert "\n"))) + (delete-char -1))) (defun completion--insert (str group-fun) (if (not (consp str)) diff --git a/lisp/simple.el b/lisp/simple.el index c60abcb1f4..7918767a75 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9179,46 +9179,53 @@ next-completion ((/= prev (point)) (point)) (t prev)))) - (let ((beg (point-min)) (end (point-max))) + + (let ((beg (point-min)) + (end (point-max)) + (tabcommand (member (this-command-keys) '("\t" [backtab]))) + prop) (catch 'bound (while (> n 0) ;; If in a completion, move to the end of it. (when (get-text-property (point) 'mouse-face) (goto-char (next-single-property-change (point) 'mouse-face nil end))) ;; If at the last completion option, wrap or skip to the - ;; minibuffer, if requested. - (when (and completion-wrap-movement (eobp)) - (if (and (member (this-command-keys) '("\t" [backtab])) - completion-auto-select) + ;; minibuffer, if requested. We can't use (eobp) because some + ;; extra text may be after the last candidate: ex: when + ;; completion-detailed + (setq prop (next-single-property-change (point) 'mouse-face nil end)) + (when (and completion-wrap-movement (eq end prop)) + (if (and completion-auto-select tabcommand) (throw 'bound nil) (goto-char (point-min)))) ;; Move to start of next one. (unless (get-text-property (point) 'mouse-face) (goto-char (next-single-property-change (point) 'mouse-face nil end))) (setq n (1- n))) + (while (and (< n 0) (not (bobp))) - (let ((prop (get-text-property (1- (point)) 'mouse-face))) - ;; If in a completion, move to the start of it. - (when (and prop (eq prop (get-text-property (point) 'mouse-face))) - (goto-char (previous-single-property-change - (point) 'mouse-face nil beg))) - ;; Move to end of the previous completion. - (unless (or (bobp) (get-text-property (1- (point)) 'mouse-face)) - (goto-char (previous-single-property-change - (point) 'mouse-face nil beg))) - ;; If at the first completion option, wrap or skip to the - ;; minibuffer, if requested. - (when (and completion-wrap-movement (bobp)) - (if (and (member (this-command-keys) '("\t" [backtab])) - completion-auto-select) - (progn - (goto-char (next-single-property-change (point) 'mouse-face nil end)) - (throw 'bound nil)) - (goto-char (point-max)))) - ;; Move to the start of that one. + (setq prop (get-text-property (1- (point)) 'mouse-face)) + ;; If in a completion, move to the start of it. + (when (and prop (eq prop (get-text-property (point) 'mouse-face))) (goto-char (previous-single-property-change - (point) 'mouse-face nil beg)) - (setq n (1+ n))))) + (point) 'mouse-face nil beg))) + ;; Move to end of the previous completion. + (unless (or (bobp) (get-text-property (1- (point)) 'mouse-face)) + (goto-char (previous-single-property-change + (point) 'mouse-face nil beg))) + ;; If at the first completion option, wrap or skip to the + ;; minibuffer, if requested. + (setq prop (previous-single-property-change (point) 'mouse-face nil beg)) + (when (and completion-wrap-movement (eq beg prop)) + (if (and completion-auto-select tabcommand) + (progn + (goto-char (next-single-property-change (point) 'mouse-face nil end)) + (throw 'bound nil)) + (goto-char (point-max)))) + ;; Move to the start of that one. + (goto-char (previous-single-property-change + (point) 'mouse-face nil beg)) + (setq n (1+ n)))) (when (/= 0 n) (switch-to-minibuffer)))) @@ -9436,22 +9443,18 @@ completion-setup-function (defun switch-to-completions () "Select the completion list window." (interactive) - (let ((window (or (get-buffer-window "*Completions*" 0) - ;; Make sure we have a completions window. - (progn (minibuffer-completion-help) - (get-buffer-window "*Completions*" 0))))) - (when window - (select-window window) + (when-let ((window (or (get-buffer-window "*Completions*" 0) + ;; Make sure we have a completions window. + (progn (minibuffer-completion-help) + (get-buffer-window "*Completions*" 0))))) + (select-window window) + (when (bobp) (cond ((and (memq this-command '(completion-at-point minibuffer-complete)) - (equal (this-command-keys) [backtab]) - (bobp)) + (equal (this-command-keys) [backtab])) (goto-char (point-max)) (previous-completion 1)) - ;; In the new buffer, go to the first completion. - ;; FIXME: Perhaps this should be done in `minibuffer-completion-help'. - ((bobp) - (next-completion 1)))))) + (t (next-completion 1)))))) (defun read-expression-switch-to-completions () "Select the completion list window while reading an expression." --lo4lqqvnbizaozje--