-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotmuch-microdata.el
More file actions
70 lines (57 loc) · 2.53 KB
/
notmuch-microdata.el
File metadata and controls
70 lines (57 loc) · 2.53 KB
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
;;; notmuch-microdata.el --- Notmuch email actions -*- lexical-binding: t -*-
;; Copyright 2021-2025 Steven Allen <steven@stebalien.com>
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This package contains three functions for acting on email actions.
;;; Code:
(require 'microdata)
(require 'notmuch)
(require 'browse-url)
;;;###autoload
(defun notmuch-microdata-search-action-view ()
"Execute the `view' action."
(interactive)
(let ((id (car (split-string (car (notmuch-search-find-stable-query)) " ")))
(coding-system-for-read 'no-conversion))
(with-temp-buffer
(call-process notmuch-command nil t nil "show" "--format=raw" id)
(when-let* ((action (car (microdata-email-actions-by-type "ViewAction"))))
(message "%s: %s" (car action) (cdr action))
(browse-url (cdr action))))))
(defun notmuch-microdata-show--get-actions ()
"Return all microdata actions in the current notmuch message."
(let (actions)
(with-current-notmuch-show-message (setq actions (microdata-email-actions)))
actions))
;;;###autoload
(defun notmuch-microdata-show-action ()
"Pick an action to perform on the email."
(interactive)
(if-let* ((actions (notmuch-microdata-show--get-actions)))
(when-let* ((selected (completing-read "Action: " actions nil t))
(action (alist-get selected actions nil nil 'equal))
(url (alist-get 'url action)))
(browse-url url))
(user-error "No actions defined!")))
;;;###autoload
(defun notmuch-microdata-show-action-view ()
"Execute the `view' action."
(interactive)
(with-current-notmuch-show-message
(when-let* ((action (car (microdata-email-actions-by-type "ViewAction"))))
(message "%s: %s" (car action) (cdr action))
(browse-url (cdr action)))))
(provide 'notmuch-microdata)
;;; notmuch-microdata.el ends here