mu4e-org: Don't trigger errors outside mu4e

The functions only work when in mu4e-view-mode/mu4e-headers-mode, which
implies that mu4e is already loaded. So no need to check.

Fixes #1829.
This commit is contained in:
Dirk-Jan C. Binnema 2020-11-14 17:30:22 +02:00
parent df0f78d891
commit 13118ae173
1 changed files with 7 additions and 10 deletions

View File

@ -59,8 +59,6 @@ the current query; otherwise, it links to the message at point.")
(defun mu4e~org-store-link-message ()
"Store a link to a mu4e message."
(unless (fboundp 'mu4e-message-at-point)
(error "Please load mu4e before mu4e-org"))
(setq org-store-link-plist nil)
(let* ((msg (mu4e-message-at-point))
(from (car-safe (plist-get msg :from)))
@ -88,14 +86,13 @@ It links to the last known query when in `mu4e-headers-mode' with
`mu4e-org-link-query-in-headers-mode' set; otherwise it links to
a specific message, based on its message-id, so that links stay
valid even after moving the message around."
(unless (fboundp 'mu4e-message-at-point)
(error "Please load mu4e before mu4e-org"))
(if (and (eq major-mode 'mu4e-headers-mode)
mu4e-org-link-query-in-headers-mode)
(mu4e~org-store-link-query)
(when (mu4e-message-at-point t)
(mu4e~org-store-link-message))))
;
(when (derived-mode-p '(mu4e-view-mode mu4e-headers-mode))
(if (and (derived-mode-p '(mu4e-headers-mode))
mu4e-org-link-query-in-headers-mode)
(mu4e~org-store-link-query)
(when (mu4e-message-at-point)
(mu4e~org-store-link-message)))))
;
(defun mu4e-org-open (link)
"Open the org LINK.
Open the mu4e message (for links starting with 'msgid:') or run