From 870a3222c45dfb65f4a9692c73be973f77aeb9ed Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 3 Aug 2025 10:30:46 +1000 Subject: [emacs] gnus with isync --- emacs/.emacs.d/init/ycp-gnus.el | 1 + emacs/.emacs.d/lisp/my/my-gnus.el | 23 +++++++++++++++++++++++ emacs/.emacs.d/lisp/my/my-wget.el | 3 +-- 3 files changed, 25 insertions(+), 2 deletions(-) (limited to 'emacs') diff --git a/emacs/.emacs.d/init/ycp-gnus.el b/emacs/.emacs.d/init/ycp-gnus.el index 9e89ee9..50901dd 100644 --- a/emacs/.emacs.d/init/ycp-gnus.el +++ b/emacs/.emacs.d/init/ycp-gnus.el @@ -147,6 +147,7 @@ (my-package gnus-group (require 'my-gnus) (my-keybind gnus-group-mode-map + "g" #'my-gnus-group-refresh "n" #'next-line "p" #'previous-line "m" #'my-gnus-group-compose diff --git a/emacs/.emacs.d/lisp/my/my-gnus.el b/emacs/.emacs.d/lisp/my/my-gnus.el index 6a2142b..ff0ec64 100644 --- a/emacs/.emacs.d/lisp/my/my-gnus.el +++ b/emacs/.emacs.d/lisp/my/my-gnus.el @@ -419,5 +419,28 @@ The archiving target comes from `my-gnus-group-alist'." (let ((inhibit-message nil)) (message "Copied region with %d links." (length pairs))))) +(defun my-isync-sync-mail () + "Call `mbsync' to sync mail" + (interactive) + (message "isync in progress...") + (set-process-sentinel + (start-process "isync" "*isync*" "mbsync" "-a") + (lambda (proc event) + (let ((status (process-exit-status proc))) + (when (eq status 0) + (message "isync in progress... done: %s" + (with-current-buffer (process-buffer proc) + (goto-char (point-max)) + (re-search-backward " ") + (buffer-substring (1+ (point)) (point-max)))) + (gnus-group-get-new-news)))))) + +(defun my-gnus-group-refresh (arg) + "Call `gnus-group-get-new-news' or, with a prefix arg, `my-isync-sync-mail'" + (interactive "P") + (if arg + (my-isync-sync-mail) + (gnus-group-get-new-news))) + (provide 'my-gnus) ;;; my-gnus.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-wget.el b/emacs/.emacs.d/lisp/my/my-wget.el index e7283aa..a55bb12 100644 --- a/emacs/.emacs.d/lisp/my/my-wget.el +++ b/emacs/.emacs.d/lisp/my/my-wget.el @@ -53,8 +53,7 @@ (my-start-process-with-torsocks no-tor "wget" "*wget*" "wget" url "-c" "-O" filename) (lambda (proc event) - (let ((ps (process-status proc)) - (status (process-exit-status proc))) + (let ((status (process-exit-status proc))) (if (eq status 0) (progn (message "[DONE] Fetched %s to %s" url filename) -- cgit v1.2.3