summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--attic/misc.el14
-rw-r--r--custom/jao-custom-completion.el47
-rw-r--r--custom/jao-custom-gnus.el1
3 files changed, 61 insertions, 1 deletions
diff --git a/attic/misc.el b/attic/misc.el
index 038072b..7fb45c9 100644
--- a/attic/misc.el
+++ b/attic/misc.el
@@ -128,6 +128,20 @@
:init (setq twtxt-file (expand-file-name "~/doc/jao.io/twtxt")
twtxt-following
'(("yarn" "https://twtxt.net/user/news/twtxt.txt"))))
+;;; corfu bits
+(defun jao-corfu-enable-no-auto ()
+ (setq-local corfu-auto nil)
+ (corfu-mode 1))
+
+(defmacro jao-corfu-no-auto (mode)
+ (let ((mode-name (intern (format "%s-mode" mode)))
+ (hook-name (intern (format "%s-mode-hook" mode))))
+ `(with-eval-after-load ',mode
+ (add-to-list 'corfu-excluded-modes ',mode-name)
+ (add-hook ',hook-name #'jao-corfu-enable-no-auto))))
+
+(jao-corfu-no-auto eshell)
+
;;; gnus bits
(jao-transient-major-mode gnus-group
diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el
index 7a604e4..0e36fcc 100644
--- a/custom/jao-custom-completion.el
+++ b/custom/jao-custom-completion.el
@@ -126,7 +126,52 @@
("RET" . company-complete-selection))
:diminish)
-(unless nil (display-graphic-p) (global-company-mode 1))
+(unless (display-graphic-p) (global-company-mode 1))
+
+;;; corfu
+(use-package corfu
+ :ensure t
+ :init (setq corfu-echo-documentation 0.25
+ corfu-cycle t
+ corfu-count 15
+ corfu-quit-no-match t
+ corfu-auto t
+ corfu-commit-predicate nil
+ corfu-preview-current nil
+ corfu-preselect-first t
+ corfu-min-width 20
+ corfu-max-width 100)
+ :config
+
+ ;; show eldoc string immediately after accepted completion too
+ (with-eval-after-load "eldoc"
+ (eldoc-add-command-completions "corfu-"))
+
+ (defun jao-corfu--active-p ()
+ (and (>= corfu--index 0) (/= corfu--index corfu--preselect)))
+
+ (defun jao-corfu-quit-or-insert ()
+ (interactive)
+ (if (jao-corfu--active-p) (corfu-insert) (corfu-quit)))
+
+ (defun jao-corfu-quit-or-previous ()
+ (interactive)
+ (if (jao-corfu--active-p)
+ (corfu-previous)
+ (corfu-quit)
+ (previous-line)))
+
+ :bind (:map corfu-map
+ ("C-<return>" . corfu-insert)
+ ("\r" . jao-corfu-quit-or-insert)
+ ("C-p" . jao-corfu-quit-or-previous)))
+
+(defun corfu-in-minibuffer ()
+ (when (not (bound-and-true-p vertico--input)) (corfu-mode 1)))
+
+(add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1)
+
+(when (display-graphic-p) (global-corfu-mode 1))
;;; vertico
(use-package vertico
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el
index f415f63..d012773 100644
--- a/custom/jao-custom-gnus.el
+++ b/custom/jao-custom-gnus.el
@@ -390,6 +390,7 @@
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
+
;;;; open mail file in gnus
(defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server)
"Compute the Gnus group name from the given file name.