From da02a954facd0b86282a2fe598ceacf63684bc1e Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Wed, 4 Jan 2023 12:16:30 +0200 Subject: [PATCH] mu4e: avoid some compiler warnings --- mu4e/mu4e-contrib.el | 28 ++++++++++++++++++++++------ mu4e/mu4e-org.el | 43 +++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 24 deletions(-) diff --git a/mu4e/mu4e-contrib.el b/mu4e/mu4e-contrib.el index 28f29c2a..4a520f8c 100644 --- a/mu4e/mu4e-contrib.el +++ b/mu4e/mu4e-contrib.el @@ -130,6 +130,22 @@ For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"") (push (buffer-name buffer) buffers)))) (nreverse buffers))) + + +;; backward compat until 27.1 is univeral. +(defalias 'mu4e--flatten-list + (if (fboundp 'flatten-list) + #'flatten-list + (with-no-warnings + #'eshell-flatten-list))) + +;; backward compat ntil 28.1 is universal. +(defalias 'mu4e--mm-default-file-type + (if (fboundp 'mm-default-file-type) + #'mm-default-file-type + (with-no-warnings + #'mm-default-file-encoding))) + (defun eshell/mu4e-attach (&rest args) "Attach files to a mu4e message using eshell with ARGS. If no mu4e buffers found, compose a new message and then attach @@ -141,10 +157,10 @@ the file." (files-to-attach (delq nil (mapcar (lambda (f) (if (or (not (file-exists-p f)) - (file-directory-p f)) - nil - (expand-file-name f))) - (eshell-flatten-list (reverse args)))))) + (file-directory-p f)) + nil + (expand-file-name f))) + (mu4e--flatten-list (reverse args)))))) ;; warn if user tries to attach without any files marked (if (null files-to-attach) (error "No files to attach") @@ -173,8 +189,8 @@ the file." (goto-char (point-max)) ; attach at end of buffer (while files-to-attach (mml-attach-file (car files-to-attach) - (or (mm-default-file-encoding - (car files-to-attach)) + (or (mu4e--mm-default-file-type + (car files-to-attach)) "application/octet-stream") nil) (setq files-to-attach (cdr files-to-attach))) (message "Attached file(s) %s" files-str)) diff --git a/mu4e/mu4e-org.el b/mu4e/mu4e-org.el index 109a842c..7ffdb4e0 100644 --- a/mu4e/mu4e-org.el +++ b/mu4e/mu4e-org.el @@ -61,10 +61,17 @@ Example usage: If non-nil, `org-store-link' in `mu4e-headers-mode' links to the the current query; otherwise, it links to the message at point.") +;; backward compat until org >= 9.3 is univeral. +(defalias 'mu4e--org-link-store-props + (if (fboundp 'org-link-store-props) + #'org-link-store-props + (with-no-warnings + #'org-store-link-props))) + (defun mu4e--org-store-link-query () "Store a link to a mu4e query." - (setq org-store-link-plist nil) ; reset - (org-store-link-props + (setq org-store-link-plist nil) ; reset + (mu4e--org-link-store-props :type "mu4e" :query (mu4e-last-query) :date (format-time-string "%FT%T") ;; avoid error @@ -80,22 +87,22 @@ the current query; otherwise, it links to the message at point.") (date (format-time-string "%FT%T" (plist-get msg :date))) (msgid (or (plist-get msg :message-id) (mu4e-error "Cannot link message without message-id"))) - (props `(:type "mu4e" - :date ,date - :from ,(mu4e-contact-full from) - :fromname ,(mu4e-contact-name from) - :fromnameoraddress ,(or (mu4e-contact-name from) - (mu4e-contact-email from)) ;; mu4e-specific - :maildir ,(plist-get msg :maildir) - :message-id ,msgid - :path ,(plist-get msg :path) - :subject ,(plist-get msg :subject) - :to ,(mu4e-contact-full to) - :tonameoraddress ,(or (mu4e-contact-name to) - (mu4e-contact-email to)) ;; mu4e-specific - :link ,(concat "mu4e:msgid:" msgid) - :description ,(funcall mu4e-org-link-desc-func msg)))) - (apply #'org-store-link-props props))) + (props `(:type "mu4e" + :date ,date + :from ,(mu4e-contact-full from) + :fromname ,(mu4e-contact-name from) + :fromnameoraddress ,(or (mu4e-contact-name from) + (mu4e-contact-email from)) ;; mu4e-specific + :maildir ,(plist-get msg :maildir) + :message-id ,msgid + :path ,(plist-get msg :path) + :subject ,(plist-get msg :subject) + :to ,(mu4e-contact-full to) + :tonameoraddress ,(or (mu4e-contact-name to) + (mu4e-contact-email to)) ;; mu4e-specific + :link ,(concat "mu4e:msgid:" msgid) + :description ,(funcall mu4e-org-link-desc-func msg)))) + (apply #'mu4e--org-link-store-props props))) (defun mu4e-org-store-link () "Store a link to a mu4e message or query.