summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
authorAmin Bandali <bandali@kelar.org>2025-02-12 17:37:25 -0500
committerAmin Bandali <bandali@kelar.org>2025-02-26 19:17:17 -0500
commit2fb274f4921d4a2e8fa2fd228a714fcbff96d95c (patch)
tree7291da9db765bd3f5ac0aa6c4afa3be5045200b7 /.emacs.d
parent1c17eb4d7076eb3d942ed85a79caaa691db9b89f (diff)
downloadconfigs-2fb274f4921d4a2e8fa2fd228a714fcbff96d95c.tar.gz
configs-2fb274f4921d4a2e8fa2fd228a714fcbff96d95c.tar.xz
configs-2fb274f4921d4a2e8fa2fd228a714fcbff96d95c.zip
Add and configure vertico and friends
Thanks to Prot's post for inspiration to try these excellent packages: Emacs: a basic and capable configuration https://protesilaos.com/codelog/2024-11-28-basic-emacs-configuration/
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el7
-rw-r--r--.emacs.d/lisp/bandali-dired.el1
-rw-r--r--.emacs.d/lisp/bandali-essentials.el81
-rw-r--r--.emacs.d/lisp/bandali-misc.el17
4 files changed, 96 insertions, 10 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 96669d2..3b6c40a 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -116,7 +116,12 @@ plain variables. This means that `setopt' will execute any
("nongnu" . "https://elpa.nongnu.org/nongnu/"))
;; List of the packages I use from GNU ELPA and NonGNU ELPA.
package-selected-packages
- '(debbugs delight eat elpher))
+ '(delight
+ debbugs
+ elpher
+ eat
+ vertico marginalia orderless corfu consult embark embark-consult
+ wgrep))
(unless package-archive-contents
(package-refresh-contents))
diff --git a/.emacs.d/lisp/bandali-dired.el b/.emacs.d/lisp/bandali-dired.el
index f0ebbc5..16ce55c 100644
--- a/.emacs.d/lisp/bandali-dired.el
+++ b/.emacs.d/lisp/bandali-dired.el
@@ -74,6 +74,7 @@
("\\.xlsx\\'" "libreoffice")
("\\.flac\\'" "mpv"))))
(add-hook 'dired-mode-hook #'dired-hide-details-mode)
+(add-hook 'dired-mode-hook #'hl-line-mode)
(provide 'bandali-dired)
;;; bandali-dired.el ends here
diff --git a/.emacs.d/lisp/bandali-essentials.el b/.emacs.d/lisp/bandali-essentials.el
index 09ef291..e7024af 100644
--- a/.emacs.d/lisp/bandali-essentials.el
+++ b/.emacs.d/lisp/bandali-essentials.el
@@ -36,6 +36,7 @@
completion-ignore-case t
read-buffer-completion-ignore-case t
enable-recursive-minibuffers t
+ delete-by-moving-to-trash t
resize-mini-windows t
message-log-max 20000
mode-line-compact t
@@ -89,6 +90,11 @@
(with-eval-after-load 'minibuffer
(setopt read-file-name-completion-ignore-case t))
+;; Do not allow the cursor in the minibuffer prompt.
+(setopt
+ minibuffer-prompt-properties
+ '(read-only t cursor-intangible t face minibuffer-prompt))
+(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(with-eval-after-load 'files
(setopt
@@ -232,20 +238,24 @@
(convert-standard-filename "info/") source-directory)
"/usr/share/info/")))
+;; `indent'
+(setopt tab-always-indent 'complete)
+
;; `ielm'
-(b/keymap-global-set "C-c i" #'ielm)
+(b/keymap-global-set "C-c i e" #'ielm)
(run-with-idle-timer 0.2 nil #'require 'recentf)
(with-eval-after-load 'recentf
(setopt recentf-max-saved-items 2000)
(recentf-mode 1)
- (defun b/recentf-open ()
- "Use `completing-read' to \\[find-file] a recent file."
- (interactive)
- (find-file
- (completing-read "Find recent file: " recentf-list)))
- (b/keymap-global-set "C-c f r" #'b/recentf-open))
+ ;; (defun b/recentf-open ()
+ ;; "Use `completing-read' to \\[find-file] a recent file."
+ ;; (interactive)
+ ;; (find-file
+ ;; (completing-read "Find recent file: " recentf-list)))
+ ;; (b/keymap-global-set "C-c f r" #'b/recentf-open)
+ )
(with-eval-after-load 'help
(temp-buffer-resize-mode 1)
@@ -305,6 +315,7 @@
save-interprogram-paste-before-kill t)
(column-number-mode 1)
(line-number-mode 1))
+(b/keymap-global-set "C-c k" #'kill-current-buffer)
(add-hook 'text-mode-hook #'auto-fill-mode)
(add-hook 'tex-mode-hook #'auto-fill-mode)
@@ -342,9 +353,10 @@
;; (package-installed-p 'completion-preview)
(with-eval-after-load 'completion-preview
(let ((m completion-preview-active-mode-map))
+ (b/keymap-set m "TAB" #'completion-preview-complete)
+ (b/keymap-set m "M-i" #'completion-preview-insert)
(b/keymap-set m "M-p" #'completion-preview-prev-candidate)
- (b/keymap-set m "M-n" #'completion-preview-next-candidate)
- (b/keymap-set m "M-i" #'completion-preview-insert)))
+ (b/keymap-set m "M-n" #'completion-preview-next-candidate)))
(add-hook 'prog-mode-hook #'completion-preview-mode)
(add-hook 'text-mode-hook #'completion-preview-mode)
(add-hook 'comint-mode-hook #'completion-preview-mode))
@@ -352,5 +364,56 @@
;; `version'
(b/keymap-global-set "C-c e v" #'emacs-version)
+;; Add prompt indicator to `completing-read-multiple'.
+;; https://bugs.gnu.org/76028
+(defun crm-indicator (args)
+ (cons (format "[CRM%s] %s"
+ (replace-regexp-in-string
+ "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
+ crm-separator)
+ (car args))
+ (cdr args)))
+(advice-add #'completing-read-multiple :filter-args #'crm-indicator)
+
+(with-eval-after-load 'vertico
+ (setopt
+ vertico-cycle t)
+ ;; (b/keymap-set vertico-map "TAB" #'minibuffer-force-complete)
+ (require 'orderless)
+ (setopt
+ completion-styles
+ '(orderless basic)
+ completion-category-overrides
+ '((file (styles basic partial-completion)))))
+(add-hook 'after-init-hook #'vertico-mode)
+
+(add-hook 'after-init-hook #'marginalia-mode)
+
+(with-eval-after-load 'corfu
+ (setopt
+ corfu-min-width 20
+ corfu-preview-current nil)
+ (require 'corfu-popupinfo)
+ (setopt corfu-popupinfo-delay '(1.25 . 0.5))
+ (corfu-popupinfo-mode 1))
+(add-hook 'after-init-hook #'global-corfu-mode)
+
+;; `consult'
+(with-eval-after-load 'consult
+ (setopt
+ consult-find-args
+ (concat "find . -not ( "
+ "-path */.git* -prune "
+ "-or -path */.cache* -prune )"))
+ (add-to-list
+ 'consult-mode-histories
+ '(vc-git-log-edit-mode . log-edit-comment-ring)))
+(b/keymap-global-set "C-c b" #'consult-buffer)
+(b/keymap-global-set "C-c o" #'consult-outline)
+(b/keymap-global-set "C-c f r" #'consult-find)
+(b/keymap-global-set "C-c h i" #'consult-history)
+(b/keymap-global-set "C-c i m" #'consult-imenu)
+(b/keymap-global-set "C-c s s" #'consult-line)
+
(provide 'bandali-essentials)
;;; bandali-essentials.el ends here
diff --git a/.emacs.d/lisp/bandali-misc.el b/.emacs.d/lisp/bandali-misc.el
index 5390615..eccee15 100644
--- a/.emacs.d/lisp/bandali-misc.el
+++ b/.emacs.d/lisp/bandali-misc.el
@@ -108,5 +108,22 @@
(require 'debian-copyright)
(require 'readme-debian))
+;; `eat'
+(b/keymap-global-set "C-c e a t" #'eat)
+
+;; `embark'
+(b/keymap-global-set "C-c ." #'embark-act)
+(let ((m minibuffer-local-map))
+ (b/keymap-set m "C-c C-c" #'embark-collect)
+ (b/keymap-set m "C-c C-e" #'embark-export))
+
+;; `wgrep'
+(with-eval-after-load 'grep
+ (require 'wgrep)
+ (let ((m grep-mode-map))
+ (b/keymap-set m "e" #'wgrep-change-to-wgrep-mode)
+ (b/keymap-set m "C-x C-q" #'wgrep-change-to-wgrep-mode)
+ (b/keymap-set m "C-c C-c" #'wgrep-finish-edit)))
+
(provide 'bandali-misc)
;;; bandali-misc.el ends here