emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vertico 5890d09beb 2/4: Add vertico-unobtrusive-mode


From: ELPA Syncer
Subject: [elpa] externals/vertico 5890d09beb 2/4: Add vertico-unobtrusive-mode
Date: Sun, 2 Jan 2022 19:57:54 -0500 (EST)

branch: externals/vertico
commit 5890d09beb7b76457af16ab65ce9d8a8a26d5901
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add vertico-unobtrusive-mode
    
    Fix #149
    Fix #168
---
 README.org                        | 10 +++---
 extensions/vertico-unobtrusive.el | 70 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index c2a3c33bd7..4ca6133977 100644
--- a/README.org
+++ b/README.org
@@ -225,11 +225,10 @@
 
   We maintain small extension packages to Vertico in this repository in the
   subdirectory 
[[https://github.com/minad/vertico/tree/main/extensions][extensions/]]. The 
extensions are installed together with Vertico
-  if you pull the package from ELPA. The extensions are of course inactive by
-  default and can be enabled manually if desired. Furthermore it is possible to
-  install all of the files separately, both ~vertico.el~ and the ~vertico-*.el~
-  extensions. Currently the following extensions come with the Vertico ELPA
-  package:
+  if you pull the package from ELPA. The extensions are inactive by default and
+  can be enabled manually if desired. Furthermore it is possible to install all
+  of the files separately, both ~vertico.el~ and the ~vertico-*.el~ extensions.
+  Currently the following extensions come with the Vertico ELPA package:
 
   - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-buffer.el][vertico-buffer]]:
 =vertico-buffer-mode= to display Vertico in a separate buffer.
   - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-directory.el][vertico-directory]]:
 Commands for Ido-like directory navigation.
@@ -241,6 +240,7 @@
   - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-quick.el][vertico-quick]]:
 Commands to select using Avy-style quick keys.
   - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-repeat.el][vertico-repeat]]:
 The command =vertico-repeat= repeats the last completion session.
   - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-reverse.el][vertico-reverse]]:
 =vertico-reverse-mode= to reverse the display.
+  - 
[[https://github.com/minad/vertico/blob/main/extensions/vertico-unobtrusive.el][vertico-unobtrusive]]:
 =vertico-unobtrusive-mode= displays only the topmost candidate.
 
   With these extensions it is possible to adapt Vertico such that it matches
   your preference or behaves similar to other familiar UIs. For example, the
diff --git a/extensions/vertico-unobtrusive.el 
b/extensions/vertico-unobtrusive.el
new file mode 100644
index 0000000000..6673356e1c
--- /dev/null
+++ b/extensions/vertico-unobtrusive.el
@@ -0,0 +1,70 @@
+;;; vertico-unobtrusive.el --- Unobtrusive display for Vertico -*- 
lexical-binding: t -*-
+
+;; Copyright (C) 2021  Free Software Foundation, Inc.
+
+;; Author: Daniel Mendler <mail@daniel-mendler.de>
+;; Maintainer: Daniel Mendler <mail@daniel-mendler.de>
+;; Created: 2021
+;; Version: 0.1
+;; Package-Requires: ((emacs "27.1") (vertico "0.18"))
+;; Homepage: https://github.com/minad/vertico
+
+;; This file is part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This package is a Vertico extension providing a unobtrusive display.
+;; The unobtrusive display only shows the topmost candidate and nothing
+;; else, it is a simple derivative of `vertico-flat-mode'.
+;;
+;; The mode can be enabled globally or via `vertico-multiform-mode' per
+;; command or completion category. Alternatively the unobtrusive display
+;; can be toggled temporarily if `vertico-multiform-mode' is enabled:
+;;
+;; (define-key vertico-map "\M-U" #'vertico-multiform-unobtrusive)
+
+;;; Code:
+
+(require 'vertico-flat)
+
+(defvar vertico-unobtrusive--orig-count nil)
+(defvar vertico-unobtrusive--orig-count-format nil)
+
+;;;###autoload
+(define-minor-mode vertico-unobtrusive-mode
+  "Unobtrusive display for Vertico."
+  :global t :group 'vertico
+  (cond
+   (vertico-unobtrusive-mode
+    (unless vertico-unobtrusive--orig-count
+      (setq vertico-unobtrusive--orig-count vertico-count
+            vertico-unobtrusive--orig-count-format vertico-count-format
+            vertico-count 1
+            vertico-count-format nil
+            vertico-flat-format `(:separator nil :ellipsis nil 
,@vertico-flat-format)))
+    (advice-add #'vertico--setup :before #'redisplay)
+    (vertico-flat-mode 1))
+   (t
+    (when vertico-unobtrusive--orig-count
+      (setq vertico-count vertico-unobtrusive--orig-count
+            vertico-count-format vertico-unobtrusive--orig-count-format
+            vertico-flat-format (nthcdr 4 vertico-flat-format)
+            vertico-unobtrusive--orig-count nil))
+    (advice-remove #'vertico--setup #'redisplay)
+    (vertico-flat-mode 0))))
+
+(provide 'vertico-unobtrusive)
+;;; vertico-unobtrusive.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]