Browse Source

Emacs: Update to use vertico-prescient, update Elpaca bootstrap

master
Riyyi 2 years ago
parent
commit
f9459cfe66
  1. 23
      .config/emacs/site-lisp/dot-elpaca.el
  2. 17
      .config/emacs/site-lisp/dot-selection.el

23
.config/emacs/site-lisp/dot-elpaca.el

@ -9,33 +9,34 @@
;; ----------------------------------------- ;; -----------------------------------------
;; Elpaca bootstrap ;; Elpaca bootstrap
(defvar elpaca-installer-version 0.2)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory)) (defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory)) (defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git" (defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :ref nil
:files (:defaults (:exclude "extensions"))
:build (:not elpaca--activate-package))) :build (:not elpaca--activate-package)))
(when-let ((repo (expand-file-name "repos/elpaca/" elpaca-directory)) (when-let ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory)) (build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order)) (order (cdr elpaca-order))
((add-to-list 'load-path (if (file-exists-p build) build repo))) ((add-to-list 'load-path (if (file-exists-p build) build repo)))
((not (file-exists-p repo)))) ((not (file-exists-p repo))))
(condition-case-unless-debug err (condition-case-unless-debug err
(if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) (if-let ((buffer (pop-to-buffer-same-window "*elpaca-installer*"))
((zerop (call-process "git" nil buffer t "clone" ((zerop (call-process "git" nil buffer t "clone"
(plist-get order :repo) repo))) (plist-get order :repo) repo)))
(default-directory repo) (default-directory repo)
((zerop (call-process "git" nil buffer t "checkout" ((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))) (or (plist-get order :ref) "--"))))
(progn (emacs (concat invocation-directory invocation-name))
(byte-recompile-directory repo 0 'force) ((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
(require 'elpaca) "--eval" "(byte-recompile-directory \".\" 0 'force)"))))
(and (fboundp 'elpaca-generate-autoloads) (progn (require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)) (elpaca-generate-autoloads "elpaca" repo)
(kill-buffer buffer)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string)))) (error "%s" (with-current-buffer buffer (buffer-string))))
((error) ((error) (warn "%s" err) (delete-directory repo 'recursive))))
(warn "%s" err)
(delete-directory repo 'recursive))))
(require 'elpaca-autoloads) (require 'elpaca-autoloads)
(add-hook 'after-init-hook #'elpaca-process-queues) (add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order)) (elpaca `(,@elpaca-order))

17
.config/emacs/site-lisp/dot-selection.el

@ -10,7 +10,6 @@
(:require prescient) (:require prescient)
(:when-loaded (:when-loaded
(setq completion-styles '(prescient basic)) (setq completion-styles '(prescient basic))
(setq prescient-completion-enable-sort nil)
(setq prescient-filter-method '(literal regexp fuzzy)) (setq prescient-filter-method '(literal regexp fuzzy))
(setq prescient-save-file (expand-file-name "prescient-save.el" dot-cache-dir)) (setq prescient-save-file (expand-file-name "prescient-save.el" dot-cache-dir))
(prescient-persist-mode))) (prescient-persist-mode)))
@ -18,17 +17,6 @@
(elpaca-setup (vertico :files (:defaults "extensions/*")) (elpaca-setup (vertico :files (:defaults "extensions/*"))
(:load-after prescient) (:load-after prescient)
(:when-loaded (:when-loaded
(setq vertico-sort-function #'prescient-completion-sort)
(setq vertico-sort-override-function #'prescient-completion-sort)
(defun dot/vertico-prescient-remember ()
"Remember the chosen candidate with Prescient."
(when (>= vertico--index 0)
(prescient-remember
(substring-no-properties
(nth vertico--index vertico--candidates)))))
(advice-add #'vertico-insert :after #'dot/vertico-prescient-remember)
(setq vertico-previous-directory nil) (setq vertico-previous-directory nil)
(defun dot/vertico-backspace () (defun dot/vertico-backspace ()
"In Vertico file completion, backward kill sexp, delete char otherwise." "In Vertico file completion, backward kill sexp, delete char otherwise."
@ -57,6 +45,11 @@
(:load-after vertico) (:load-after vertico)
(:when-loaded (vertico-mouse-mode)))) (:when-loaded (vertico-mouse-mode))))
(elpaca-setup vertico-prescient
(:load-after vertico prescient)
(:when-loaded
(vertico-prescient-mode)))
(elpaca-setup marginalia (elpaca-setup marginalia
(:load-after vertico) (:load-after vertico)
(:when-loaded (:when-loaded

Loading…
Cancel
Save