blob 82c31a5bd5ed008a7ac11307ec457c5fd233ebd8 3064 bytes (raw)
name: lisp/org-notmuch.el # note: path name is non-authoritative(*)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
| | ;;; org-notmuch.el --- Support for links to notmuch messages from within Org-mode
;; Author: David Bremner <david@tethera.net>
;; License: GPL3+
;;; Commentary:
;; This file implements links to notmuch messages from within Org-mode.
;; Link types supported include
;; - notmuch:id:message-id
;; - notmuch:show:search-terms
;; - notmuch:search:search-terms
;;
;; The latter two pass the search terms to the corresponding notmuch-*
;; function. 'id:' is an abbreviation for 'show:id:' search-terms is
;; a space delimited list of notmuch search-terms.
;;
;; Currently storing links is supported in notmuch-search and
;; notmuch-show mode. It might make sense to support notmuch-folder
;; mode too. Because threads-ids are currently not save/restore safe,
;; they are converted into a list of message-ids.
;;
;; Org-mode loads this module by default - if this is not what you want,
;; configure the variable `org-modules'.
;;; Code:
;; Install the link type
(org-add-link-type "notmuch" 'org-notmuch-open)
(add-hook 'org-store-link-functions 'org-notmuch-store-link)
;; Configuration
(defvar org-notmuch-mid-limit 10
"Maximum number of message ids to store for a thread")
;; Implementation
(defun org-notmuch-store-link ()
"Store a link to the currently selected thread."
(require 'notmuch)
(when (memq major-mode '(notmuch-show-mode notmuch-search-mode))
(if (equal major-mode 'notmuch-search-mode)
(org-notmuch-do-store-link
(org-notmuch-build-thread-link)
(notmuch-search-find-authors)
(notmuch-search-find-subject))
(org-notmuch-do-store-link (notmuch-show-get-message-id)
(notmuch-show-get-from)
(notmuch-show-get-subject)))))
;; sigh. there doesn't seem to be such a function.
(defun org-notmuch-n-first (list n)
(if (> n 0)
(cons (car list)
(org-notmuch-n-first (cdr list) (1- n)))
nil))
(defun org-notmuch-build-thread-link ()
"Expand the thread-id on the current line to a list of message-ids"
(require 'notmuch-query)
(let* ((current-thread (or (notmuch-search-find-thread-id)
(error "End of search results")))
(message-ids
(org-notmuch-n-first
(notmuch-query-get-message-ids current-thread)
org-notmuch-mid-limit)))
(concat "show:"
(mapconcat (lambda (id) (concat "id:" id)) message-ids " "))))
(defun org-notmuch-do-store-link (id author subject)
(let ((link (org-make-link "notmuch:" id)))
(org-store-link-props :type "notmuch" :from author :subject subject)
(org-add-link-props :link link :description (org-email-link-description))
link))
(defun org-notmuch-open (link)
"Open a link with notmuch. id: or show: links are opened directly with notmuch-show
otherwise notmuch-search is used to give an index view"
(require 'notmuch)
(cond
((string-match "^show:\\(.*\\)" link)
(notmuch-show (match-string 1 link)))
((string-match "^search:\\(.*\\)" link)
(notmuch-search (match-string 1 link)))
((string-match "^id:.*" link)
(notmuch-show link))
(t (notmuch-search link))))
(provide 'org-notmuch)
|
debug log:
solving 82c31a5 ...
found 82c31a5 in https://list.orgmode.org/orgmode/1270514576-12432-2-git-send-email-bremner@unb.ca/
applying [1/1] https://list.orgmode.org/orgmode/1270514576-12432-2-git-send-email-bremner@unb.ca/
diff --git a/lisp/org-notmuch.el b/lisp/org-notmuch.el
new file mode 100644
index 0000000..82c31a5
1:13: trailing whitespace.
;; Link types supported include
1:45: trailing whitespace.
(org-notmuch-do-store-link
1:63: trailing whitespace.
(let* ((current-thread (or (notmuch-search-find-thread-id)
1:65: trailing whitespace.
(message-ids
1:66: trailing whitespace.
(org-notmuch-n-first
Checking patch lisp/org-notmuch.el...
Applied patch lisp/org-notmuch.el cleanly.
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.
index at:
100644 82c31a5bd5ed008a7ac11307ec457c5fd233ebd8 lisp/org-notmuch.el
(*) Git path names are given by the tree(s) the blob belongs to.
Blobs themselves have no identifier aside from the hash of its contents.^
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).