-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathvertico-unobtrusive.el
68 lines (54 loc) · 2.69 KB
/
vertico-unobtrusive.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; vertico-unobtrusive.el --- Unobtrusive display for Vertico -*- lexical-binding: t -*-
;; Copyright (C) 2021-2025 Free Software Foundation, Inc.
;; Author: Daniel Mendler <[email protected]>
;; Maintainer: Daniel Mendler <[email protected]>
;; Created: 2021
;; Version: 1.10
;; Package-Requires: ((emacs "28.1") (compat "30") (vertico "1.10"))
;; URL: 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 <https://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 with M-U if
;; `vertico-multiform-mode' is enabled.
;;; Code:
(require 'vertico-flat)
(defvar vertico-unobtrusive--restore nil)
;;;###autoload
(define-minor-mode vertico-unobtrusive-mode
"Unobtrusive display for Vertico."
:global t :group 'vertico
(cond
((and vertico-unobtrusive-mode (not vertico-unobtrusive--restore))
(push '(vertico-current . default) (default-value 'face-remapping-alist))
(setq vertico-unobtrusive--restore (cons vertico-count vertico-count-format)
vertico-count 1
vertico-count-format nil
vertico-flat-format `(:separator nil :ellipsis nil ,@vertico-flat-format)))
((and (not vertico-unobtrusive-mode) vertico-unobtrusive--restore)
(cl-callf2 delete '(vertico-current . default)
(default-value 'face-remapping-alist))
(setq vertico-count (car vertico-unobtrusive--restore)
vertico-count-format (cdr vertico-unobtrusive--restore)
vertico-flat-format (nthcdr 4 vertico-flat-format)
vertico-unobtrusive--restore nil)))
(vertico-flat-mode (if vertico-unobtrusive-mode 1 -1)))
(cl-defmethod vertico--setup :before (&context (vertico-unobtrusive-mode (eql t)))
(redisplay))
(provide 'vertico-unobtrusive)
;;; vertico-unobtrusive.el ends here