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)))) (push (buffer-name buffer) buffers))))
(nreverse 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) (defun eshell/mu4e-attach (&rest args)
"Attach files to a mu4e message using eshell with ARGS. "Attach files to a mu4e message using eshell with ARGS.
If no mu4e buffers found, compose a new message and then attach If no mu4e buffers found, compose a new message and then attach
@ -141,10 +157,10 @@ the file."
(files-to-attach (files-to-attach
(delq nil (mapcar (delq nil (mapcar
(lambda (f) (if (or (not (file-exists-p f)) (lambda (f) (if (or (not (file-exists-p f))
(file-directory-p f)) (file-directory-p f))
nil nil
(expand-file-name f))) (expand-file-name f)))
(eshell-flatten-list (reverse args)))))) (mu4e--flatten-list (reverse args))))))
;; warn if user tries to attach without any files marked ;; warn if user tries to attach without any files marked
(if (null files-to-attach) (if (null files-to-attach)
(error "No files to attach") (error "No files to attach")
@ -173,8 +189,8 @@ the file."
(goto-char (point-max)) ; attach at end of buffer (goto-char (point-max)) ; attach at end of buffer
(while files-to-attach (while files-to-attach
(mml-attach-file (car files-to-attach) (mml-attach-file (car files-to-attach)
(or (mm-default-file-encoding (or (mu4e--mm-default-file-type
(car files-to-attach)) (car files-to-attach))
"application/octet-stream") nil) "application/octet-stream") nil)
(setq files-to-attach (cdr files-to-attach))) (setq files-to-attach (cdr files-to-attach)))
(message "Attached file(s) %s" files-str)) (message "Attached file(s) %s" files-str))

View File

@ -61,10 +61,17 @@ Example usage:
If non-nil, `org-store-link' in `mu4e-headers-mode' links to the If non-nil, `org-store-link' in `mu4e-headers-mode' links to the
the current query; otherwise, it links to the message at point.") 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 () (defun mu4e--org-store-link-query ()
"Store a link to a mu4e query." "Store a link to a mu4e query."
(setq org-store-link-plist nil) ; reset (setq org-store-link-plist nil) ; reset
(org-store-link-props (mu4e--org-link-store-props
:type "mu4e" :type "mu4e"
:query (mu4e-last-query) :query (mu4e-last-query)
:date (format-time-string "%FT%T") ;; avoid error :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))) (date (format-time-string "%FT%T" (plist-get msg :date)))
(msgid (or (plist-get msg :message-id) (msgid (or (plist-get msg :message-id)
(mu4e-error "Cannot link message without message-id"))) (mu4e-error "Cannot link message without message-id")))
(props `(:type "mu4e" (props `(:type "mu4e"
:date ,date :date ,date
:from ,(mu4e-contact-full from) :from ,(mu4e-contact-full from)
:fromname ,(mu4e-contact-name from) :fromname ,(mu4e-contact-name from)
:fromnameoraddress ,(or (mu4e-contact-name from) :fromnameoraddress ,(or (mu4e-contact-name from)
(mu4e-contact-email from)) ;; mu4e-specific (mu4e-contact-email from)) ;; mu4e-specific
:maildir ,(plist-get msg :maildir) :maildir ,(plist-get msg :maildir)
:message-id ,msgid :message-id ,msgid
:path ,(plist-get msg :path) :path ,(plist-get msg :path)
:subject ,(plist-get msg :subject) :subject ,(plist-get msg :subject)
:to ,(mu4e-contact-full to) :to ,(mu4e-contact-full to)
:tonameoraddress ,(or (mu4e-contact-name to) :tonameoraddress ,(or (mu4e-contact-name to)
(mu4e-contact-email to)) ;; mu4e-specific (mu4e-contact-email to)) ;; mu4e-specific
:link ,(concat "mu4e:msgid:" msgid) :link ,(concat "mu4e:msgid:" msgid)
:description ,(funcall mu4e-org-link-desc-func msg)))) :description ,(funcall mu4e-org-link-desc-func msg))))
(apply #'org-store-link-props props))) (apply #'mu4e--org-link-store-props props)))
(defun mu4e-org-store-link () (defun mu4e-org-store-link ()
"Store a link to a mu4e message or query. "Store a link to a mu4e message or query.