From cc3587285dd6062094d5963e191f24a4e64764ca Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 3 Jun 2022 21:46:55 +0100 Subject: in good company --- attic/misc.org | 85 ++++++++++++++++++++++++++++++++++++++++++++++ completion.org | 104 ++++++++++++++++++++++++++++----------------------------- notmuch.org | 2 +- 3 files changed, 137 insertions(+), 54 deletions(-) diff --git a/attic/misc.org b/attic/misc.org index fdfc193..3a31d6a 100644 --- a/attic/misc.org +++ b/attic/misc.org @@ -1,3 +1,65 @@ +* corfu + #+begin_src emacs-lisp + (use-package corfu + :ensure t + :demand 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-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) + ;; (add-to-list 'corfu-excluded-modes 'notmuch-message-mode) + + (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-" . 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))) + + (when (display-graphic-p) + (add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1) + (global-corfu-mode 1)) + + #+end_src * erc *** package #+begin_src emacs-lisp @@ -168,3 +230,26 @@ (jao-shorten-modes 'signel-chat-mode)) (setq signel-report-deliveries t) #+end_src +* cdlatex + #+begin_src emacs-lisp + (use-package cdlatex + :ensure t + :hook ((org-mode . org-cdlatex-mode)) + :diminish ((cdlatex-mode . " £") + (org-cdlatex-mode . " £"))) + #+end_src +* maps + #+begin_src emacs-lisp + (use-package osm + :ensure t + :init + (with-eval-after-load 'org (require 'osm-ol)) + :config + (transient-define-prefix jao-transient-osm () + ["Open Street Maps" + ("s" "search" osm-search) + ("g" "goto" osm-goto) + ("b" "jump to bookmark" osm-bookmark-jump) + ("t" "server" osm-server)]) + :bind ("C-c M" . #'jao-transient-osm)) + #+end_src diff --git a/completion.org b/completion.org index 8fdeb23..20460f5 100644 --- a/completion.org +++ b/completion.org @@ -111,67 +111,61 @@ (marginalia-mode 1) #+end_src -* corfu +* company #+begin_src emacs-lisp - (use-package corfu + (use-package company :ensure t - :demand 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-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)))) + :custom ((company-backends '(company-capf + company-bbdb + company-files + company-dabbrev + company-keywords)) + (company-global-modes '(not slack-message-buffer-mode + circe-channel-mode + telega-chat-mode)) + (company-format-margin-function nil) ;; #'company-text-icons-margin + (company-idle-delay 0.2) + (company-lighter "") + (company-lighter-base "") + (company-show-numbers nil) + (company-selection-wrap-around t) + (company-tooltip-limit 15) + (company-tooltip-align-annotations t) + (company-tooltip-offset-display 'lines)) ;; 'scrollbar - (jao-corfu-no-auto eshell) - ;; (add-to-list 'corfu-excluded-modes 'notmuch-message-mode) - - (defun jao-corfu--active-p () - (and (>= corfu--index 0) (/= corfu--index corfu--preselect))) - - (defun jao-corfu-quit-or-insert () + :config + (defun jao-complete-at-point () + "Complete using company unless we're in the minibuffer." (interactive) - (if (jao-corfu--active-p) (corfu-insert) (corfu-quit))) + (if (or (not company-mode) (window-minibuffer-p)) + (completion-at-point) + (company-manual-begin))) - (defun jao-corfu-quit-or-previous () - (interactive) - (if (jao-corfu--active-p) - (corfu-previous) - (corfu-quit) - (previous-line))) + (defun jao-company-use-in-tab () + (global-set-key [remap completion-at-point] #'jao-complete-at-point) + (global-set-key [remap completion-symbol] #'jao-complete-at-point) + (global-set-key (kbd "M-TAB") #'jao-complete-at-point)) + + (jao-company-use-in-tab) - :bind (:map corfu-map - ("C-" . corfu-insert) - ("\r" . jao-corfu-quit-or-insert) - ("C-p" . jao-corfu-quit-or-previous))) + :bind (:map company-active-map - (defun corfu-in-minibuffer () - (when (not (bound-and-true-p vertico--input)) (corfu-mode 1))) + ("" . company-complete-common-or-cycle) + ("TAB" . company-complete-common-or-cycle) - (add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1) + ("C-h" . company-show-doc-buffer) + ("M-." . company-show-location) + ("C-" . company-complete-selection) + ([remap return] . company-abort) + ("RET" . company-abort) - (global-corfu-mode 1) + :filter (or (not (derived-mode-p 'eshell-mode)) + (company-explicit-action-p)) + ("" . company-complete-selection) + ("RET" . company-complete-selection)) + :diminish) + (unless (display-graphic-p) (global-company-mode 1)) #+end_src * vertico #+begin_src emacs-lisp @@ -616,10 +610,14 @@ (jao-recoll (format "dir:%s/doc " jao-org-dir))) (defun jao-recoll-notes () - "Use consult-recoll to search notes." (interactive) (jao-recoll (format "dir:%s " jao-org-notes-dir))) + (defun jao-recoll-consult-notes () + "Use consult-recoll to search notes." + (interactive) + (consult-recoll (format "dir:%s " jao-org-notes-dir))) + (defun jao-recoll-open-with-notmuch (fname) (let ((id (with-temp-buffer (insert-file fname) @@ -640,7 +638,7 @@ (transient-define-prefix jao-recoll-transient () [["Consult recoll queries" ("r" "consult recoll query" consult-recoll) - ("n" "consult recoll on notes" jao-org-notes-consult-recoll) + ("n" "consult recoll on notes" jao-recoll-consult-notes) ("d" "consult recoll on docs" jao-recoll-consult-docs) ("m" "consult recoll on messages" jao-recoll-consult-messages)] ["Recoll queries" diff --git a/notmuch.org b/notmuch.org index a8792c1..cdcb76f 100644 --- a/notmuch.org +++ b/notmuch.org @@ -210,7 +210,7 @@ (use-package notmuch :init - (setq notmuch-address-use-company nil + (setq notmuch-address-use-company t notmuch-address-command (if jao-notmuch-enabled 'internal 'as-is) notmuch-always-prompt-for-sender t notmuch-draft-folder "local" -- cgit v1.2.3