[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnorb 6246244 106/449: Hinting for potentially-relevant
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnorb 6246244 106/449: Hinting for potentially-relevant incoming messages |
Date: |
Fri, 27 Nov 2020 23:15:19 -0500 (EST) |
branch: externals/gnorb
commit 6246244292f5338917fe90565cd748ab277b9d08
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Hinting for potentially-relevant incoming messages
Now that we have a quick-lookup cache for finding correlations between
messages and todo items, we can do more interesting stuff. Opening
messages can automatically flash a hint if the message is relevant to a
todo. A special mark can also be displayed next to relevant messages in
the *Summary* buffer.
lisp/gnorb-gnus.el: New options `gnorb-gnus-hint-relevant-article',
`gnorb-gnus-summary-mark-format-letter' and
`gnorb-gnus-summary-mark' control the above
behavior. New function
`gnorb-gnus-hint-relevant-message' is added to the
`gnus-article-prepare-hook', and a
gnus-user-format-function is constructed for the
appropriate format letter.
---
lisp/gnorb-gnus.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/lisp/gnorb-gnus.el b/lisp/gnorb-gnus.el
index c354157..7a5acb3 100644
--- a/lisp/gnorb-gnus.el
+++ b/lisp/gnorb-gnus.el
@@ -78,6 +78,29 @@ Basically behave as if all attachments have
\":gnus-attachments t\"."
:group 'gnorb-gnus
:type 'string)
+(defcustom gnorb-gnus-hint-relevant-article t
+ "When opening a gnus message, should gnorb let you know if the
+ message is relevant to an existing TODO?"
+ :group 'gnorb-gnus
+ :type 'boolean)
+
+(defcustom gnorb-gnus-summary-mark-format-letter "g"
+ "Format letter to be used as part of your
+ `gnus-summary-line-format', to indicate in the *Summary* buffer
+ which articles might be relevant to TODOs. Since this is a user
+ format code, it should be prefixed with %u, eg %ug. It will
+ result in the insertion of the value of
+ `gnorb-gnus-summary-mark', for relevant messages, or
+ else a space."
+ :group 'gnorb-gnus
+ :type 'string)
+
+(defcustom gnorb-gnus-summary-mark "ยก"
+ "Default mark to insert in the summary format line of articles
+ that are likely relevant to existing TODO headings."
+ :group 'gnorb-gnus
+ :type 'string)
+
(defcustom gnorb-gnus-trigger-refile-targets
'((org-agenda-files :maxlevel . 4))
"A value to use as an equivalent of `org-refile-targets' (which
@@ -432,5 +455,47 @@ work."
(cons 'nnir-group-spec `((,nnir-address)))))
(cons 'nnir-artlist nil)))))
+;;; Automatic noticing of relevant messages
+
+;; likely hooks for the summary buffer include:
+;; `gnus-parse-headers-hook'
+
+;; BBDB puts its notice stuff in the `gnus-article-prepare-hook',
+;; which seems as good a spot as any.
+
+(defun gnorb-gnus-hint-relevant-message ()
+ "When opening an article buffer, check the message to see if it
+is relevant to any existing TODO headings. If so, flash a message
+to that effect. This function is added to the
+`gnus-article-prepare-hook'. It will only do anything if the
+option `gnorb-gnus-hint-relevant-article' is non-nil."
+ (when gnorb-gnus-hint-relevant-article
+ (let ((ref-ids (gnus-fetch-original-field "references"))
+ (key
+ (where-is-internal 'gnorb-gnus-incoming-do-todo
+ nil t))
+ rel-headings)
+ (when ref-ids
+ (setq ref-ids (split-string ref-ids))
+ (when (setq rel-headings
+ (gnorb-org-find-visit-candidates ref-ids))
+ (message "Possible relevant TODO: %s, trigger with %s"
+ (org-format-outline-path
+ (cadr (car rel-headings)))
+ (if key
+ (key-description key)
+ "M-x gnorb-gnus-incoming-do-todo")))))))
+
+(add-hook 'gnus-article-prepare-hook 'gnorb-gnus-hint-relevant-message)
+
+(fset (intern (concat "gnus-user-format-function-"
+ gnorb-gnus-summary-mark-format-letter))
+ (lambda (header)
+ (let ((ref-ids (mail-header-references header)))
+ (if (and ref-ids
+ (gnorb-org-find-visit-candidates
+ (split-string ref-ids)))
+ gnorb-gnus-summary-mark
+ " "))))
(provide 'gnorb-gnus)
;;; gnorb-gnus.el ends here
- [elpa] externals/gnorb edab89d 110/449: Be more careful about cleaning up attachments, (continued)
- [elpa] externals/gnorb edab89d 110/449: Be more careful about cleaning up attachments, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6375f83 112/449: And append doesn't modify destructively..., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb f7b93f2 115/449: Whitespace/indentation cleanup, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e86d24a 119/449: Robustification of nngnorb nnir message viewing, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e089d66 129/449: Documenting recent additions in the README, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb d254f39 140/449: Merge and simplify handle-mail and email-subtree, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb de3a512 244/449: Releasing version 1, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 4b8a6da 255/449: New function for removing message/heading association, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb aaf8556 261/449: Be a good citizen about the cl package, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb de3182e 263/449: Shift location of org-reveal during trigger process, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 6246244 106/449: Hinting for potentially-relevant incoming messages,
Stefan Monnier <=
- [elpa] externals/gnorb a79cf72 126/449: Unwrap "if" from around function, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 0255247 133/449: Only notice records on message receipt, not sending, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb b70d845 168/449: Handle nil group values in registry entries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 880afd6 158/449: Register sent messages so we can view them later, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 25aa0f1 173/449: Use a marker in conjunction with window conf, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb e1129e9 170/449: Fix problems when BBDB is not present and gnorb-bbdb is not loaded., Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 5f96b98 167/449: Stupid typo, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 9a2f747 175/449: Don't hint messages in nnir or virtual summaries, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb ec44a6d 182/449: Continue shifting candidate finding to the registry, Stefan Monnier, 2020/11/27
- [elpa] externals/gnorb 927e401 184/449: New function for restoring window layout, Stefan Monnier, 2020/11/27