summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-07-15 15:33:23 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-07-15 16:50:21 -0700
commit9a44d45168b01d17f3bc29b0bb348eb28b9d9d2f (patch)
treece524dbc400f7b3afefe24a98d2fa79072f21090
parent29c37dba62d23eafb021e9ae16112294d8651af7 (diff)
downloaddotfiles-9a44d45168b01d17f3bc29b0bb348eb28b9d9d2f.tar.gz
replace spw/with-less-gc and wrapper inside spw/gnus with advice
-rw-r--r--.emacs.d/init.el58
1 files changed, 26 insertions, 32 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index e3b5ec1e..d73588ee 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -551,13 +551,6 @@ that's something we can determine.")
(set-window-prev-buffers nil ,prev-buffers))
. ,keyword-arguments)))
-(defmacro spw/with-less-gc (&rest forms)
- "Execute FORMS with temporarily much higher GC thresholds."
- (declare (indent 0))
- `(let ((gc-cons-percentage 0.6)
- (gc-cons-threshold 402653184))
- ,@forms))
-
;;;; The *scratch* and *notes* buffers
@@ -1823,7 +1816,7 @@ The ideas behind these behaviours are as follows.
;; pass to that function, and if blank, do what function does now).
(defun spw/browse-gmane ()
(interactive)
- (spw/with-less-gc (gnus-no-server))
+ (gnus-no-server)
(gnus-group-browse-foreign-server '(nntp "news.gmane.io")))
(global-set-key "\C-cgG" #'spw/browse-gmane)
@@ -2723,30 +2716,31 @@ mutt's review view, after exiting EDITOR."
(with-eval-after-load 'gnus
(unless (gnus-getenv-nntpserver) (setq gnus-select-method '(nnnil ""))))
+(defun spw/gnus-startup-wrapper (orig-fun &rest args)
+ (if (and (daemonp) (file-directory-p "~/.fmail/")
+ (not (file-exists-p "~/.newsrc.eld")))
+ (user-error "Must use dedicated Emacs for Gnus first run")
+ (let ((gc-cons-percentage 0.6)
+ (gc-cons-threshold 402653184))
+ (apply orig-fun args))))
+(advice-add 'gnus :around #'spw/gnus-startup-wrapper)
+(advice-add 'gnus-no-server :around #'spw/gnus-startup-wrapper)
+
(defun spw/gnus (&optional fetch-and-inbox)
(interactive "P")
- (cl-flet ((gnus ()
- ;; Require a dedicated Emacs so that primary session is not
- ;; locked up for ages while maildir NOV files are generated.
- (if (and (daemonp) (file-directory-p "~/.fmail/")
- (not (file-exists-p "~/.newsrc.eld")))
- (user-error "Must use dedicated Emacs for Gnus first run")
- (spw/with-less-gc (gnus)))))
- (require 'gnus)
- (if (not fetch-and-inbox)
- (if (gnus-alive-p)
- (pop-to-buffer-same-window gnus-group-buffer)
- (spw/with-less-gc (gnus)))
- ;; We want to see mail that we think has just come in. This is the only
- ;; time we call 'notmuch new' without --no-hooks from Emacs rather than
- ;; just waiting for cron, because it's slow.
- (unless (gnus-alive-p) (spw/with-less-gc (gnus)))
- (with-temp-message "Fetching & indexing mail ..."
- (call-process "notmuch" nil nil nil "new"))
- (if (not (get-buffer "*Summary nnselect:Process-Weekday*"))
- (gnus-group-read-group nil t "nnselect:Process-Weekday")
- (pop-to-buffer-same-window "*Summary nnselect:Process-Weekday*")
- (gnus-summary-rescan-group)))))
+ (require 'gnus)
+ (if (not fetch-and-inbox)
+ (if (gnus-alive-p) (pop-to-buffer-same-window gnus-group-buffer) (gnus))
+ ;; We want to see mail that we think has just come in. This is the only
+ ;; time we call 'notmuch new' without --no-hooks from Emacs rather than
+ ;; just waiting for cron, because it's slow.
+ (unless (gnus-alive-p) (gnus))
+ (with-temp-message "Fetching & indexing mail ..."
+ (call-process "notmuch" nil nil nil "new"))
+ (if (not (get-buffer "*Summary nnselect:Process-Weekday*"))
+ (gnus-group-read-group nil t "nnselect:Process-Weekday")
+ (pop-to-buffer-same-window "*Summary nnselect:Process-Weekday*")
+ (gnus-summary-rescan-group))))
(global-set-key "\C-cgn" #'spw/gnus)
(defun spw/gnus-notmuch-ephemeral-search (query &optional limit)
@@ -2754,7 +2748,7 @@ mutt's review view, after exiting EDITOR."
(and current-prefix-arg
(prefix-numeric-value current-prefix-arg))))
(require 'gnus)
- (unless (gnus-alive-p) (spw/with-less-gc (gnus)))
+ (unless (gnus-alive-p) (gnus))
(gnus-group-read-ephemeral-group
(concat "nnselect-" (message-unique-id)) (list 'nnselect "nnselect")
nil (cons (current-buffer) gnus-current-window-configuration) nil nil
@@ -2870,7 +2864,7 @@ mutt's review view, after exiting EDITOR."
(setq spw/gnus-all-process-groups
(spw/nm| (mapcar #'cdr process-groups)))
(require 'gnus) (require 'nnselect)
- (unless (gnus-alive-p) (spw/with-less-gc (gnus-no-server)))
+ (unless (gnus-alive-p) (gnus-no-server))
;; Kill all summaries in case any of their queries have changed.
(catch 'done