From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: vertical fido-mode Date: Wed, 19 Aug 2020 14:17:55 +0200 Message-ID: <20200819121755.24hgq4gyba2wkt76@Ergus> References: <1704199899.1577092.1591806438580.ref@mail.yahoo.com> <1704199899.1577092.1591806438580@mail.yahoo.com> <13ec44ed-4b54-8d43-590f-709bd813fd01@yandex.ru> <795146083.1708851.1591826041689@mail.yahoo.com> <87y2ouldrr.fsf@mail.linkov.net> Reply-To: Ergus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wrlextfq7ef2zpsb" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32406"; 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 Wed Aug 19 14:18:43 2020 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 1k8N3D-0008KQ-CL for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Aug 2020 14:18:43 +0200 Original-Received: from localhost ([::1]:56342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8N3C-0004K8-DT for ged-emacs-devel@m.gmane-mx.org; Wed, 19 Aug 2020 08:18:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8N2h-0003um-I2 for emacs-devel@gnu.org; Wed, 19 Aug 2020 08:18:11 -0400 Original-Received: from sonic313-13.consmr.mail.bf2.yahoo.com ([74.6.133.123]:40538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k8N2d-0008Bi-Sm for emacs-devel@gnu.org; Wed, 19 Aug 2020 08:18:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1597839483; bh=PCovCr09sJxl+rGYkKHNG+vJLMZyADRzLnBo5QiLqe4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=FFydy75ezJrvk2pFMDcsLNRVRUD1+vfYt7owolD/H2ek+vQWb8V9XIEq4+t44ffLleu+6a+7UVTxaRBSp5Ma0EBA1gbGBLaZ5zcK9W5JH0Rll1GajCwiEOK4xFYAIk5rj7S96+eHm6j3388432zXY0QGtoA5Av9Jz3ixy1Sex+3yD7Ev9SRzuah/mEuw0bA7PB2HvT55Z2HuQL9yJHr9V9jnoIf7syYLgXLsoUj8gUk0XOFU+QaQ5s6dEhNEewcDk20DLeEsY6R9iguNtOxKTi1Swgx6QfIatjQQEW83NXR+ZtlvHkhzqjBf/DRIKrN3OzW9JjqWCMH1UVF+WQnDug== X-YMail-OSG: 0s7nOrQVM1nKAJZV10MqyuSuwyBiiwFLxLq0g6jwwet4jYfWNNNherfHrJhuGnW LVXlZRlkNPWxSxMg6LXdppRgCX5xeewj6Ajhv89kPCZt0fKy2aRo5sVmCcNp5WIceNLlqTkO5r4k xon9AzCyhsqJinvFbMCO.a5XI9G5wBbs2.RLKUIl3IZDnqy3eoV28zNqzbnfQNXuXryHjO20dmep _DUOlVwlmDBHH04VcSIJPQLDN5InS4NpmcVctU9Jf61EMtS.57jJAXAMHpv6QWvs9gxds3X0yeBf RtLl5zJ0GrPZl2U_i.ClY5lzRo0XVQbdxxNEOdCvx70pOKJBMUHsrRlFoJTjpDOj0LQsZt4Z5TAu x5W7Or_boT4ZJ0_eC8Ap8FjcBDmUD0Lbi2IVMMlpW9Tml5MDYcz5701KEAQqftFbvoS9Jh1CpBtY seHT2P3_AbwhiL.Ji.iaaUBhihagzo7.97SVX7eStlKgpK4H252esqWGs5ayjUXxQrODfNNyzcDM 2ELnCZS89k7VRTc5A6GCtB7MDqRHXq225hrLUX17pt0SMVV5gOZJKJ64USJZ7ViT66aVYXTrsSO8 tk19_H6IHEP_2jBQ3Od_7hs6AJUTBMxx8vEk73LAV3qaN38pcV.tfwLjpYJAsEx15o318JLmrugz 40MNu0wC93IwE15WpCJtuurooxPzV_k2O0l8iDYqTbM46MnXfVQTVAV0nR0i76IfMzM6zVV1fQuM bziy71swNLiMg9J.FR7KOjUEkmLJ0uFF7LpmmLSkaT6Q7dkxr_8JyM6bBv5Y4dt8KLkyVD9ZQHqA SunHAeSCRtVTBqswQhem4c5dYFkUXtpsLBjGUevOUv Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.bf2.yahoo.com with HTTP; Wed, 19 Aug 2020 12:18:03 +0000 Original-Received: by smtp410.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 709d785109ad8b6fdb8997f4d041c561; Wed, 19 Aug 2020 12:17:58 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87y2ouldrr.fsf@mail.linkov.net> X-Mailer: WebService/1.1.16455 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Apache-HttpAsyncClient/4.1.4 (Java/11.0.7) Received-SPF: pass client-ip=74.6.133.123; envelope-from=spacibba@aol.com; helo=sonic313-13.consmr.mail.bf2.yahoo.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 08:18:03 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:253997 Archived-At: --wrlextfq7ef2zpsb Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On Thu, Jun 11, 2020 at 02:08:56AM +0300, Juri Linkov wrote: >Or show vertical completions in the *Completions* buffer and use the >current icomplete keys to navigate the *Completions* list from the minibuffer. > Hi! Coming back to this thread, I just made this very simple patch (attached) to provide a sort of "zsh" like experience in the *Completion* buffer. I would love to see a version of this enabled by default in emacs (to feel we are a bit in 2020 and give a more friendly first impression to new users); but I know that changing defaults will start a war. So I won't even try to argue about that; so I added variables to customize everything. If you are interested, you can try it and I will be very happy with any suggestions and critics if you thing this can be added to master in the future. It basically adds: 1) enforces navigation throw completion candidates (no go to header or random useless places in *completion* buffer). 2) Current candidate highlight with the 'highlight face. 3) Second tab in minibuffer with completion shown and all candidates visible (no need scroll) jump to *Completions* buffer (similar to zsh). 4) Skip Completion buffer with C-g. The intentions of this is just to tweak a little the *Completions* interaction keeping everything extremely simple. At the end after a couple of hours most of the users go for Ido, help or Ivy. But this doesn't mean we shouldn't improve the first impression right? OTOH: I would like to know if Omar finally got the copyright otherwise I will try to implement the vertical-fido/Icompletes mode. Best, Ergus --wrlextfq7ef2zpsb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="complete.patch" diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 641a2e5315..7c5025b11c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -753,6 +753,12 @@ minibuffer-message-clear-timeout (integer :tag "Wait for the number of seconds" 2)) :version "27.1") +(defcustom minibuffer-tab-go-completion t + "If a second `TAB' jump to completion buffer." + :type 'boolean + :version "28.1" + :group 'completion) + (defvar minibuffer-message-timer nil) (defvar minibuffer-message-overlay nil) @@ -940,6 +946,8 @@ completion-styles :type completion--styles-type :version "23.1") + + (defvar completion-category-defaults '((buffer (styles . (basic substring))) (unicode-name (styles . (basic substring))) @@ -1288,8 +1296,12 @@ completion--in-region-1 (let ((window minibuffer-scroll-window)) (with-current-buffer (window-buffer window) (if (pos-visible-in-window-p (point-max) window) - ;; If end is in view, scroll up to the beginning. - (set-window-start window (point-min) nil) + (if (and minibuffer-tab-go-completion + (pos-visible-in-window-p (point-min) window)) + ;; If all completions are visible move cursor there + (switch-to-completions) + ;; If end is in view, scroll up to the beginning. + (set-window-start window (point-min) nil)) ;; Else scroll down one screen. (with-selected-window window (scroll-up))) diff --git a/lisp/simple.el b/lisp/simple.el index b45fb87887..c203efe16d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8359,6 +8359,12 @@ set-variable ;; Define the major mode for lists of completions. +(defcustom completion-highlight-candidate t + "Non-nil means show help message in *Completions* buffer." + :type 'boolean + :version "28.1" + :group 'completion) + (defvar completion-list-mode-map (let ((map (make-sparse-keymap))) (define-key map [mouse-2] 'choose-completion) @@ -8372,6 +8378,12 @@ completion-list-mode-map (define-key map [backtab] 'previous-completion) (define-key map "q" 'quit-window) (define-key map "z" 'kill-current-buffer) + + (define-key map (kbd "C-g") 'quit-window) + (define-key map (kbd "") 'previous-line-completion) + (define-key map (kbd "C-p") 'previous-line-completion) + (define-key map (kbd "") 'next-line-completion) + (define-key map (kbd "C-n") 'next-line-completion) map) "Local map for completion list buffers.") @@ -8410,6 +8422,19 @@ completion-base-size If nil, Emacs determines which part of the tail end of the buffer's text is involved in completion by comparing the text directly.") + +(defvar completion-overlay nil + "Use a face to highlight completion candidate.") + +(defun move-completion-overlay () + "Update completion overlay to highlight current candidate." + (let* ((obeg (point)) + (oend (next-single-property-change obeg 'mouse-face nil (point-max)))) + (unless (overlayp completion-overlay) + (setq completion-overlay (make-overlay 0 0)) + (overlay-put completion-overlay 'face 'highlight)) + (move-overlay completion-overlay obeg oend))) + (make-obsolete-variable 'completion-base-size 'completion-base-position "23.2") (defun delete-completion-window () @@ -8428,7 +8453,7 @@ previous-completion (interactive "p") (next-completion (- n))) -(defun next-completion (n) +(defun next-completion (n &optional no-move-overlay) "Move to the next item in the completion list. With prefix argument N, move N items (negative N means move backward)." (interactive "p") @@ -8454,7 +8479,25 @@ next-completion ;; Move to the start of that one. (goto-char (previous-single-property-change (point) 'mouse-face nil beg)) - (setq n (1+ n)))))) + (setq n (1+ n))))) + + (when (and completion-highlight-candidate + (not no-move-overlay)) + (move-completion-overlay))) + +(defun next-line-completion (&optional arg try-vscroll) + "Go to completion candidate in line bellow current." + (interactive "^p\np") + (line-move arg t nil try-vscroll) + (next-completion 1 t) + (next-completion -1)) + +(defun previous-line-completion (&optional arg try-vscroll) + "Go to completion candidate in line above current." + (interactive "^p\np") + (line-move (- arg) t nil try-vscroll) + (next-completion -1 t) + (next-completion 1)) (defun choose-completion (&optional event) "Choose the completion at point. --wrlextfq7ef2zpsb--