mu4e: avoid some compiler warnings

This commit is contained in:
Dirk-Jan C. Binnema
2023-01-04 12:16:30 +02:00
parent b1b11eb0cb
commit da02a954fa
2 changed files with 47 additions and 24 deletions

View File

@ -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))