From 5630273d51113974068d9ed539ce5c501bcc9a30 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 28 Oct 2012 19:31:13 +0200 Subject: [PATCH] * mu4e: add functions mu4e-message-field-at-point, mu4e-message-has-field --- mu4e/mu4e-message.el | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-message.el b/mu4e/mu4e-message.el index 474d3fd5..5ba0c794 100644 --- a/mu4e/mu4e-message.el +++ b/mu4e/mu4e-message.el @@ -106,11 +106,17 @@ Thus, function will return nil for empty lists, non-existing body-txt or body-ht val) ;; non-nil -> just return it ((member field '(:subject :message-id :path :maildir :in-reply-to)) "") ;; string fields except body-txt, body-html: nil -> "" + ((member field '(:body-html :body-txt)) + val) ((member field '(:docid :size)) 0) ;; numeric type: nil -> 0 - (t + (t val)))) ;; otherwise, just return nil +(defsubst mu4e-message-has-field (msg field) + "Return t if MSG contains FIELD, nil otherwise." + (plist-member msg field)) + (defsubst mu4e-message-at-point (&optional noerror) "Get the message s-expression for the message at point in either the headers buffer or the view buffer, or nil if there is no such @@ -120,7 +126,12 @@ there is no message at point." (if msg msg (unless noerror (mu4e-warn "No message at point"))))) - + +(defsubst mu4e-message-field-at-point (field) + "Get the field FIELD from the message at point; equivalent to + (mu4e-message-field (mu4e-message-at-point FIELD))." + (mu4e-message-field (mu4e-message-at-point) field)) + (defun mu4e-message-body-text (msg) "Get the body in text form for this message, which is either :body-txt, or if not available, :body-html converted to text. By default, it