[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 01e7b1e 206/449: New minor mode for nnir summary
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 01e7b1e 206/449: New minor mode for nnir summary buffers |
Date: |
Fri, 27 Nov 2020 23:15:40 -0500 (EST) |
branch: externals/gnorb
commit 01e7b1ef48bf47813fdb2461d28397b2ea72efe7
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
New minor mode for nnir summary buffers
* lisp/nngnorb.el (gnorb-summary-minor-mode): New minor mode in effect
in nnir summary buffers created by Gnorb.
(gnorb-reply-advice): Function called as advice to gnus-summary-reply.
(gnorb-summary-exit): Exit the summary buffer and restore layout.
(gnorb-summary-disassociate-message): Disassociate message under point
from the TODO heading.
* lisp/gnorb-gnus.el (gnorb-gnus-search-messages): Activate new minor
mode.
---
lisp/gnorb-gnus.el | 3 +-
lisp/nngnorb.el | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+), 1 deletion(-)
diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index 6cd37ba..1ca0263 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -567,7 +567,8 @@ work."
;; the following seems to simply be ignored under gnus 5.13
(list (cons 'nnir-specs (list (cons 'nnir-query-spec `((query . ,str)))
(cons 'nnir-group-spec `((,nnir-address
nil)))))
- (cons 'nnir-artlist nil)))))
+ (cons 'nnir-artlist nil)))
+ (gnorb-summary-minor-mode)))
;;; Automatic noticing of relevant messages
diff --git a/lisp/nngnorb.el b/lisp/nngnorb.el
index 2beb224..e3eb6ce 100644
--- a/lisp/nngnorb.el
+++ b/lisp/nngnorb.el
@@ -147,6 +147,144 @@ be scanned for gnus messages, and those messages
displayed."
(when (and (integerp artno) (> artno 0))
(push (vector server-group artno 100) vectors)))))))))
+(defvar gnorb-summary-minor-mode-map (make-sparse-keymap)
+ "Keymap for use in Gnorb's *Summary* minor mode.")
+
+(define-minor-mode gnorb-summary-minor-mode
+ "A minor mode for use in nnir *Summary* buffers created by Gnorb.
+
+These *Summary* buffers are usually created by calling
+`gnorb-org-view', or by initiating an nnir search on a nngnorb server.
+
+While active, this mode provides some Gnorb-specific commands,
+and also advises Gnus' reply-related commands in order to
+continue to provide tracking of sent messages."
+ nil " Gnorb" gnorb-summary-minor-mode-map)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-exit]
+ 'gnorb-summary-exit)
+
+(define-key gnorb-summary-minor-mode-map (kbd "C-c d")
+ 'gnorb-summary-disassociate-message)
+
+;; All this is pretty horrible, but it's the only way to get sane
+;; behavior, there are no appropriate hooks, and I want to avoid
+;; advising functions.
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-very-wide-reply-with-original]
+ 'gnorb-summary-very-wide-reply-with-original)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-wide-reply-with-original]
+ 'gnorb-summary-wide-reply-with-original)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-reply]
+ 'gnorb-summary-reply)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-very-wide-reply]
+ 'gnorb-summary-very-wide-reply)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-reply-with-original]
+ 'gnorb-summary-reply-with-original)
+
+(define-key gnorb-summary-minor-mode-map
+ [remap gnus-summary-wide-reply]
+ 'gnorb-summary-wide-reply)
+
+
+(defun gnorb-summary-wide-reply (&optional yank)
+ (interactive
+ (list (and current-prefix-arg
+ (gnus-summary-work-articles 1))))
+ (gnorb-summary-reply yank t)
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-reply-with-original (n &optional wide)
+ (interactive "P")
+ (gnorb-summary-reply (gnus-summary-work-articles n) wide)
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-very-wide-reply (&optional yank)
+ (interactive
+ (list (and current-prefix-arg
+ (gnus-summary-work-articles 1))))
+ (gnorb-summary-reply yank t (gnus-summary-work-articles yank))
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-reply (&optional yank wide very-wide)
+ (interactive)
+ (gnus-summary-reply yank wide very-wide)
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-wide-reply-with-original (n)
+ (interactive "P")
+ (gnorb-summary-reply-with-original n t)
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-very-wide-reply-with-original (n)
+ (interactive "P")
+ (gnorb-summary-reply
+ (gnus-summary-work-articles n) t (gnus-summary-work-articles n))
+ (gnorb-summary-reply-hook))
+
+(defun gnorb-summary-reply-hook (&rest args)
+ "Function that runs after any command that creates a reply."
+ ;; Not actually a "hook"
+ (let* ((msg-id (aref message-reply-headers 4))
+ (org-id (car-safe (gnus-registry-get-id-key msg-id 'gnorb-ids))))
+ (when org-id
+ (save-restriction
+ (save-excursion
+ (widen)
+ (message-narrow-to-headers-or-head)
+ (goto-char (point-at-bol))
+ (open-line 1)
+ (message-insert-header
+ (intern gnorb-mail-header)
+ org-id)
+ (add-to-list 'message-exit-actions
+ 'gnorb-org-restore-after-send))))))
+
+(defun gnorb-summary-exit ()
+ "Like `gnus-summary-exit', but restores the gnorb window conf."
+ (interactive)
+ (call-interactively 'gnus-summary-exit)
+ (gnorb-restore-layout))
+
+(defun gnorb-summary-disassociate-message ()
+ "Disassociate a message from its Org TODO.
+
+This is used in a Gnorb-created *Summary* buffer to remove the
+connection between the message and whichever Org TODO resulted in
+the message being included in this search."
+ (interactive)
+ (let* ((msg-id (gnus-fetch-original-field "message-id"))
+ (org-ids (gnus-registry-get-id-key msg-id 'gnorb-ids))
+ chosen)
+ (when org-ids
+ (if (= (length org-ids) 1)
+ ;; Only one associated Org TODO.
+ (progn (gnus-registry-set-id-key msg-id 'gnorb-ids)
+ (setq chosen (car org-ids)))
+ ;; Multiple associated TODOs, prompt to choose one.
+ (setq chosen
+ (cdr
+ (org-completing-read
+ "Choose a TODO to disassociate from: "
+ (mapcar
+ (lambda (h)
+ (cons (gnorb-pretty-outline h) h))
+ org-ids))))
+ (gnus-registry-set-id-key msg-id 'gnorb-ids
+ (remove chosen org-ids)))
+ (message "Message disassociated from %s"
+ (gnorb-pretty-outline chosen)))))
+
(defvar nngnorb-status-string "")
(defun nngnorb-retrieve-headers (articles &optional group server fetch-old)
- [elpa] externals/gnorb d04bf53 178/449: Rename/move the registry-entry function, (continued)
- [elpa] externals/gnorb d04bf53 178/449: Rename/move the registry-entry function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 452a3f0 177/449: Basic skeleton of registry usage, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb eaa4bf4 181/449: Begin shifting candidate finding to the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7f4dbed 180/449: Don't check for relevant headings if not tracking, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 093c4ed 185/449: Spurious 'g', Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 8121bf5 188/449: Stop creating hash table entries and GNORB_MSG_IDS, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 7b70966 190/449: Look up tracked messages via the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5ba511e 198/449: Dispense with the "insert a link" message, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 05e6a02 204/449: Docstring for gnorb-msg-id-to-link, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4f302fa 205/449: New gnorb-collect-ids utility function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 01e7b1e 206/449: New minor mode for nnir summary buffers,
Stefan Monnier <=
- [elpa] externals/gnorb 69ddfd3 212/449: Delete duplicate org-ids for outgoing messages, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 36303d9 213/449: Do a better job of dealing with reference headers, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 01645a4 215/449: Allowing fetching attachments from specific IDs, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 305a704 216/449: Don't append the message-exit-action, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d0d196f 222/449: Check prefix arg correctly, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9a76fad 226/449: Use org-element-interpret-data to get paragraph text, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 09346e0 141/449: BBDB message link list needs closing newline, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 69980d3 143/449: Improvements to nnir-run-gnorb, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ebce811 144/449: Also check for nnir when storing BBDB message links, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5101731 150/449: Improvements to TODOs made from outgoing messages, Stefan Monnier, 2020/11/27