From 4a65300d729cb29bbe32365b56fc6cb8447ddfb6 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Wed, 10 Jul 2024 21:35:36 +0300 Subject: [PATCH] emacs: more lazy loading & termux --- .emacs.d/init.el | 18 +++++-- .emacs.d/mail.el | 131 +---------------------------------------------- Emacs.org | 18 +++++-- Mail.org | 8 +-- 4 files changed, 33 insertions(+), 142 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 915a800..cf8f079 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -2684,9 +2684,13 @@ Returns ( . ) or nil." (use-package flycheck-package :straight t - :after flycheck - :config - (flycheck-package-setup)) + :defer t + :init + (defun my/flycheck-package-setup () + (require 'flycheck-package) + (flycheck-package-setup) + (remove-hook 'emacs-lisp-mode-hook #'my/flycheck-package-setup)) + (add-hook 'emacs-lisp-mode-hook #'my/flycheck-package-setup)) (add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode) ;; (add-hook 'emacs-lisp-mode-hook #'smartparens-strict-mode) @@ -7742,6 +7746,14 @@ base toot." (use-package devdocs-browser :straight t + :commands (devdocs-browser-open + devdocs-browser-open-in + devdocs-browser-install-doc + devdocs-browser-uninstall-doc + devdocs-browser-download-offline-data + devdocs-browser-remove-offline-data + devdocs-browser-upgrade-all-docs + devdocs-browser-update-docs) :init (my-leader-def :infix "hd" diff --git a/.emacs.d/mail.el b/.emacs.d/mail.el index 9138f73..b80aaac 100644 --- a/.emacs.d/mail.el +++ b/.emacs.d/mail.el @@ -1,28 +1,5 @@ -(setq user-mail-address "thexcloud@gmail.com") -(setq user-full-name "Pavel Korytov") - -(let ((dir "/home/pavel/.guix-extra-profiles/mail/mail/share/emacs/site-lisp")) - (when (file-directory-p dir) - (let ((default-directory dir)) - (normal-top-level-add-subdirs-to-load-path)))) - -(use-package notmuch - :straight t - :if my/is-termux) - -(defun my/notmuch-toggle-trash () - (interactive) - (evil-collection-notmuch-toggle-tag "trash" "search" #'ignore)) - -(defun my/notmuch-toggle-inbox () - (interactive) - (evil-collection-notmuch-toggle-tag "inbox" "search" #'ignore)) - -(defun my/notmuch-toggle-unread () - (interactive) - (evil-collection-notmuch-toggle-tag "unread" "search" #'ignore)) - (use-package notmuch + :if (not my/is-termux) ;; :ensure nil :commands (notmuch notmuch-search) :init @@ -49,109 +26,3 @@ (setq notmuch-address-command 'as-is) (add-hook 'notmuch-hello-mode-hook (lambda () (display-line-numbers-mode 0)))) - -(my-leader-def - "am" (my/command-in-persp "notmuch" "mail" 0 (notmuch))) - -(my/persp-add-rule - notmuch-hello-mode 0 "mail" - notmuch-search-mode 0 "mail" - notmuch-tree-mode 0 "mail" - notmuch-message-mode 0 "mail") - -(setq notmuch-saved-searches - '((:name "drafts" :query "tag:draft" :key "d") - (:name "main (inbox)" :query "tag:main AND tag:inbox" :key "mi") - (:name "main (unread)" :query "tag:main AND tag:unread" :key "mu") - (:name "main (sent)" :query "tag:main AND tag:sent" :key "ms") - (:name "main (all mail)" :query "tag:main" :key "ma") - (:name "progin (inbox)" :query "tag:progin AND tag:inbox" :key "pi") - (:name "progin (unread)" :query "tag:progin AND tag:unread" :key "pu") - (:name "progin (sent)" :query "tag:progin AND tag:sent" :key "ps") - (:name "progin (all mail)" :query "tag:progin" :key "pa") - (:name "pvkorytov (inbox)" :query "tag:pvkorytov AND tag:inbox" :key "vi") - (:name "pvkorytov (unread)" :query "tag:pvkorytov AND tag:unread" :key "vu") - (:name "pvkorytov (sent)" :query "tag:pvkorytov AND tag:sent" :key "vs") - (:name "pvkorytov (all mail)" :query "tag:pvkorytov" :key "va"))) -(setq notmuch-show-empty-saved-searches nil) - -(general-define-key - :states '(normal visual) - :keymaps '(notmuch-hello-mode-map) - "f" #'notmuch-jump-search) - -(with-eval-after-load 'notmuch - (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)) - -(setq mml-secure-key-preferences - '((OpenPGP - (sign - ("thexcloud@gmail.com" "914472A1FD6775C166F96EBEED739ADF81C78160")) - (encrypt)) - (CMS - (sign) - (encrypt)))) - -(defun my/message-insert-signature-need-on-top () - t) - -(defun my/message-maybe-fix-signature (&rest _) - (when (my/message-insert-signature-need-on-top) - (save-excursion - (goto-char (point-min)) - (when (re-search-forward message-signature-separator nil t) - (move-beginning-of-line 0) - (kill-region (point) (point-max))) - (message-goto-body) - (when (re-search-forward (rx "sign=pgpmime") nil t) - (forward-line)) - (insert (current-kill 0)) - (insert "\n\n") - (set-buffer-modified-p nil)))) - -(with-eval-after-load 'notmuch-mua - (advice-add #'notmuch-mua-reply :after #'my/message-maybe-fix-signature)) - -(defun my/message-ensure-subject () - (unless (or (message-field-value "Subject") - (y-or-n-p "No subject. Send? ")) - (user-error "Aborting."))) - -(add-hook 'notmuch-mua-send-hook #'my/message-ensure-subject) - -(defvar my/ru-formal-pronous - '("вы" "вас" "вам" "вами" "ваш" "ваша" "ваше" "ваши" "вашего" - "вашей" "вашему" "вашим" "вашем" "вашеми")) - -(defvar my/ru-formal-pronous-regex - (regexp-opt - (mapcar (lambda (p) (format " %s " p)) my/ru-formal-pronous) 'words)) - -(defun my/message-ensure-capitalized-formal-pronouns () - (interactive) - (save-excursion - (message-goto-body) - (cl-block nil - (let ((case-fold-search nil) - confirmed) - (while (re-search-forward my/ru-formal-pronous-regex nil t) - (let* ((match (match-string 0)) - (capitalized (capitalize match)) - (beg (match-beginning 0)) - (end (match-end 0))) - (if (or confirmed - (y-or-n-p (format "Replace %s with %s? " - match capitalized))) - (progn - (delete-region beg end) - (insert capitalized) - (setq confirmed t)) - (cl-return)))))))) - -(add-hook 'notmuch-mua-send-hook #'my/message-ensure-capitalized-formal-pronouns) - -(defun my/ensure-password () - (interactive) - (my/password-store-get "Job/Digital/Email/pvkorytov@etu.ru")) - -(add-hook 'notmuch-mua-send-hook #'my/ensure-password) diff --git a/Emacs.org b/Emacs.org index 31d9e4e..5c4a310 100644 --- a/Emacs.org +++ b/Emacs.org @@ -3672,9 +3672,13 @@ A package that checks for the metadata in Emacs Lisp packages. #+begin_src emacs-lisp (use-package flycheck-package :straight t - :after flycheck - :config - (flycheck-package-setup)) + :defer t + :init + (defun my/flycheck-package-setup () + (require 'flycheck-package) + (flycheck-package-setup) + (remove-hook 'emacs-lisp-mode-hook #'my/flycheck-package-setup)) + (add-hook 'emacs-lisp-mode-hook #'my/flycheck-package-setup)) #+end_src **** General settings #+begin_src emacs-lisp @@ -10681,6 +10685,14 @@ There is a package called =devdocs= that does more or less the same, but I like #+begin_src emacs-lisp (use-package devdocs-browser :straight t + :commands (devdocs-browser-open + devdocs-browser-open-in + devdocs-browser-install-doc + devdocs-browser-uninstall-doc + devdocs-browser-download-offline-data + devdocs-browser-remove-offline-data + devdocs-browser-upgrade-all-docs + devdocs-browser-update-docs) :init (my-leader-def :infix "hd" diff --git a/Mail.org b/Mail.org index 2d085db..4de16fb 100644 --- a/Mail.org +++ b/Mail.org @@ -390,12 +390,7 @@ Then, the problem with my Guix setup is that Emacs by default doesn't see the el (normal-top-level-add-subdirs-to-load-path)))) #+end_src -On termux the above doesn't work so... -#+begin_src emacs-lisp -(use-package notmuch - :straight t - :if my/is-termux) -#+end_src +On termux the above doesn't work, and I don't need it here anyway. Some functions to toggle tags: #+begin_src emacs-lisp @@ -415,6 +410,7 @@ Some functions to toggle tags: And notmuch settings: #+begin_src emacs-lisp (use-package notmuch + :if (not my/is-termux) ;; :ensure nil :commands (notmuch notmuch-search) :init