Speedup Manipulations with Autocompletion
Because we execute a lot of commands while using Emacs, it’s hard live without completion.
Lightweight Completion System
I introduce Vertico, a lightweight autocompletion package:
(leaf vertico
:doc "Completion interface"
:ensure t
:init (vertico-mode)
:custom
(vertico-cycle . t)
(vertico-count . 18))
Vertico provides vertical candidate UI good in visibility:
Smoother Directory Navigation
I also need autocompletion during navigating through directories:
(leaf vertico-directory
:doc "Extensions for file directory navigation"
:after vertico
:ensure nil
:preface
(defun vertico-directory-enter-or-dired ()
"Enter directory or open it in dired if it's the current selection."
(interactive)
(let* ((current (vertico--candidate))
(cand (minibuffer-completion-contents)))
(if (or (string-suffix-p "/" current)
(and (not (string-suffix-p "/" cand))
(file-directory-p current)))
(progn
(vertico-exit)
(dired current))
(vertico-directory-enter))))
:init
(with-eval-after-load 'vertico
(define-key vertico-map (kbd "RET") #'vertico-directory-enter-or-dired)
(define-key vertico-map (kbd "/") #'vertico-directory-enter)
(define-key vertico-map (kbd "DEL") #'vertico-directory-delete-char)
(define-key vertico-map (kbd "M-DEL") #'vertico-directory-delete-word)))
By hitting /
, we can navigate into the directory keeping vertico-directory-mode
.
On the other hand, hitting RET
invokes dired
at the candidate directory.
More Flexible Matching
orderless
provides more flexible matching:
(leaf orderless
:doc "Completion style for regexp matching"
:ensure t
:custom
(completion-styles . '(orderless))
(completion-category-defaults . nil))
Now your completion system can match patterns in any order.
Summary
_ The state of init.el at the end of this post can be found here 🚀
References
comments powered by Disqus