From: Ergus via "Emacs development discussions." <emacs-devel@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: vertical fido-mode
Date: Wed, 19 Aug 2020 14:17:55 +0200 [thread overview]
Message-ID: <20200819121755.24hgq4gyba2wkt76@Ergus> (raw)
In-Reply-To: <87y2ouldrr.fsf@mail.linkov.net>
[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]
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
[-- Attachment #2: complete.patch --]
[-- Type: text/plain, Size: 4538 bytes --]
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
\f
;; 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 "<up>") 'previous-line-completion)
+ (define-key map (kbd "C-p") 'previous-line-completion)
+ (define-key map (kbd "<down>") '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.
next prev parent reply other threads:[~2020-08-19 12:17 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1704199899.1577092.1591806438580.ref@mail.yahoo.com>
2020-06-10 16:27 ` vertical fido-mode Ergus
2020-06-10 16:53 ` Stefan Monnier
2020-06-10 19:01 ` Dmitry Gutov
2020-06-10 19:45 ` Basil L. Contovounesios
2020-06-10 21:54 ` Ergus
2020-06-10 22:00 ` Dmitry Gutov
2020-06-10 23:08 ` Juri Linkov
2020-06-10 23:23 ` Dmitry Gutov
2020-06-11 13:22 ` Ergus
2020-06-11 13:28 ` Noam Postavsky
2020-06-11 13:40 ` Ergus
2020-06-11 15:49 ` Protesilaos Stavrou
2020-06-11 15:52 ` Omar Antolín Camarena
2020-06-11 17:37 ` Basil L. Contovounesios
2020-06-17 21:50 ` Juri Linkov
2020-06-17 21:57 ` Dmitry Gutov
2020-06-17 22:17 ` João Távora
2020-06-17 22:31 ` Drew Adams
2020-06-17 22:40 ` João Távora
2020-06-17 22:56 ` Drew Adams
2020-06-17 22:52 ` Juri Linkov
2020-06-17 23:20 ` Drew Adams
2020-06-17 22:22 ` Juri Linkov
2020-06-17 22:52 ` Dmitry Gutov
2020-06-17 22:57 ` Dmitry Gutov
2020-06-17 22:58 ` Drew Adams
2020-06-17 23:15 ` Drew Adams
2020-06-18 21:54 ` Juri Linkov
2020-06-18 22:41 ` João Távora
2020-06-18 22:51 ` Juri Linkov
2020-06-19 8:53 ` João Távora
2020-06-18 8:22 ` Kévin Le Gouguec
2020-06-18 10:19 ` Ergus
2020-06-11 13:10 ` Ergus
2020-08-19 12:17 ` Ergus via Emacs development discussions. [this message]
2020-08-20 0:35 ` Juri Linkov
2020-08-20 10:37 ` Ergus
2020-08-20 23:15 ` Juri Linkov
2020-08-21 0:05 ` Ergus
2020-08-23 18:45 ` Juri Linkov
2020-08-24 19:06 ` vertical fido-mode (new branch) Ergus via Emacs development discussions.
2020-08-25 18:55 ` Juri Linkov
2020-08-25 23:11 ` Ergus
2020-08-25 23:42 ` Stefan Monnier
2020-08-26 4:34 ` Ergus
2020-08-26 13:30 ` Stefan Monnier
2020-08-28 10:09 ` Ergus
2020-06-10 19:45 ` vertical fido-mode Basil L. Contovounesios
2020-06-11 0:55 Omar Antolín Camarena
2020-06-11 13:03 ` Ergus
2020-06-11 13:44 ` Omar Antolín Camarena
2020-06-11 14:07 ` Ergus
2020-06-11 17:29 ` Basil L. Contovounesios
2020-06-18 13:51 ` Stefan Monnier
2020-06-29 14:44 ` Ergus
[not found] <mailman.50.1591891219.14559.emacs-devel@gnu.org>
2020-06-11 17:06 ` Andrew Schwartzmeyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200819121755.24hgq4gyba2wkt76@Ergus \
--to=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=spacibba@aol.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).