summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-07-02 12:01:48 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-07-11 18:37:32 -0700
commitc8e8eb064164f638138834a3a23356f3ecade139 (patch)
treed39bc1c267c068d9796fcd288b3ed0259e45ed0a
parent84fc8830bbb6d5b10e46f8c895d8c2f7e1313910 (diff)
downloaddotfiles-c8e8eb064164f638138834a3a23356f3ecade139.tar.gz
add spw/sync-notmuch-nnselect
-rw-r--r--.emacs.d/init.el39
1 files changed, 31 insertions, 8 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 6187648e..f6617b5c 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -684,12 +684,6 @@ layout (which I use by default)."
(setenv "TZ" "MST")
(set-time-zone-rule "/usr/share/zoneinfo/America/Phoenix"))
-;; If NNTPSERVER has been configured by the local administrator, accept Gnus'
-;; defaults. Otherwise, set the default select method to nnnil so that typing
-;; 'M-x gnus' does not hang.
-(with-eval-after-load 'gnus
- (unless (gnus-getenv-nntpserver) (setq gnus-select-method '(nnnil ""))))
-
(when-let ((bash (executable-find "bash")))
(setq shell-file-name "bash")
(setenv "SHELL" bash)
@@ -1001,8 +995,6 @@ to open them using `spw/try-external-open'")
(global-set-key "\C-cgp" #'cperl-perldoc)
(global-set-key "\C-cgk" #'save-buffers-kill-emacs)
-(global-set-key "\C-cG" #'gnus)
-
;; Have M-c, M-l and M-u be consistent in all of them exiting Isearch -- the
;; fact that M-c doesn't keeps tripping me up. While we're here, drop similar
;; isearch-mode-map bindings; all these commands have a binding under M-s too.
@@ -3237,6 +3229,37 @@ scroll through them."
(notmuch-show-refresh-view))
+;;;; Gnus
+
+;; If NNTPSERVER has been configured by the local administrator, accept Gnus'
+;; defaults. Otherwise, set the default select method to nnnil so that typing
+;; 'M-x gnus' does not hang.
+(with-eval-after-load 'gnus
+ (unless (gnus-getenv-nntpserver) (setq gnus-select-method '(nnnil ""))))
+
+(global-set-key "\C-cG" #'gnus)
+
+(defun spw/sync-notmuch-nnselect (name query)
+ "Update or add Gnus-saved notmuch query NAME to have query QUERY."
+ (require 'gnus) (require 'nnselect)
+ (unless (gnus-alive-p) (gnus-no-server))
+ (let ((nname (nnselect-add-prefix name))
+ (specs
+ `((nnselect-function . gnus-search-run-query)
+ (nnselect-args . ((search-query-spec
+ (query . ,query) (thread . t) (raw . t))
+ (search-group-spec ("nnmaildir:fmail")))))))
+ (if (gnus-group-entry nname)
+ (gnus-group-set-parameter nname 'nnselect-specs specs)
+ (with-current-buffer gnus-group-buffer
+ (save-excursion
+ (goto-char (point-max))
+ ;; From `gnus-group-make-search-group' (though marked "temporary"?).
+ (gnus-group-make-group name (list 'nnselect "nnselect") nil
+ `((nnselect-specs . ,specs)
+ (nnselect-artlist . nil))))))))
+
+
;;;; Assorted packages
(spw/when-library-available magit