mu4e-(actions|control|org|update).el: tidy up

Fix flycheck warnings, and use '--' instead of '~' for private
variables/functions.
This commit is contained in:
Dirk-Jan C. Binnema
2021-08-30 22:02:49 +03:00
parent 162f5896ae
commit 3a39eff1df
5 changed files with 56 additions and 49 deletions

View File

@ -1,4 +1,4 @@
;;; mu4e-contrib.el -- part of mu4e, the mu mail user agent -*- lexical-binding: t -*-
;;; mu4e-contrib.el -- part of mu4e -*- lexical-binding: t -*-
;; Copyright (C) 2013-2021 Dirk-Jan C. Binnema
@ -48,7 +48,8 @@
(mu4e-mark-execute-all t))
(defun mu4e-headers-mark-all ()
"Mark all messages within current query results and ask user to execute which action."
"Mark all headers for some action,
Ask user what action to execute."
(interactive)
(mu4e-headers-mark-for-each-if
(cons 'something nil)
@ -59,22 +60,25 @@
;;
;; Allow bookmarking a mu4e buffer in regular emacs bookmarks.
(defun mu4e~view-set-bookmark-make-record-fn ()
(defun mu4e--view-set-bookmark-make-record-fn ()
"Make a bookmar record function (view)."
(set (make-local-variable 'bookmark-make-record-function)
'mu4e-view-bookmark-make-record))
(defun mu4e~headers-set-bookmark-make-record-fn ()
(defun mu4e--headers-set-bookmark-make-record-fn ()
"Make a bookmar record function (headers)."
(set (make-local-variable 'bookmark-make-record-function)
'mu4e-view-bookmark-make-record))
;; Probably this can be moved to mu4e-view.el.
(add-hook 'mu4e-view-mode-hook #'mu4e~view-set-bookmark-make-record-fn)
(add-hook 'mu4e-view-mode-hook #'mu4e--view-set-bookmark-make-record-fn)
;; And this can be moved to mu4e-headers.el.
(add-hook 'mu4e-headers-mode-hook #'mu4e~headers-set-bookmark-make-record-fn)
(add-hook 'mu4e-headers-mode-hook #'mu4e--headers-set-bookmark-make-record-fn)
(defun mu4e-view-bookmark-make-record ()
"Make a bookmark entry for a mu4e buffer. Note that this is an
emacs bookmark, not to be confused with `mu4e-bookmarks'."
"Make a bookmark entry for a mu4e buffer.
Note that this is an Emacs bookmark, not to be confused with
`mu4e-bookmarks'."
(let* ((msg (mu4e-message-at-point))
(maildir (plist-get msg :maildir))
(date (format-time-string "%Y%m%d" (plist-get msg :date)))
@ -122,26 +126,26 @@ BOOKMARK is a bookmark name or a bookmark record."
;; '("hMark as ham" . mu4e-register-msg-as-ham) t)
(defvar mu4e-register-as-spam-cmd nil
"Command for invoking spam processor to register message as spam,
for example for bogofilter, use \"/usr/bin/bogofilter -Ns < %s\" ")
"Command for invoking spam processor to register message as spam.
For example for bogofilter, use \"/usr/bin/bogofilter -Ns < %s\"")
(defvar mu4e-register-as-ham-cmd nil
"Command for invoking spam processor to register message as ham.
For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"")
(defun mu4e-register-msg-as-spam (msg)
"Mark message as spam."
"Register MSG as spam."
(interactive)
(let* ((path (shell-quote-argument (mu4e-message-field msg :path)))
(command (format mu4e-register-as-spam-cmd path))) ;; re-register msg as spam
(command (format mu4e-register-as-spam-cmd path)))
(shell-command command))
(mu4e-mark-at-point 'delete nil))
(defun mu4e-register-msg-as-ham (msg)
"Mark message as ham."
"Register MSG as ham."
(interactive)
(let* ((path (shell-quote-argument(mu4e-message-field msg :path)))
(command (format mu4e-register-as-ham-cmd path))) ;; re-register msg as ham
(command (format mu4e-register-as-ham-cmd path)))
(shell-command command))
(mu4e-mark-at-point 'something nil))
@ -151,7 +155,7 @@ For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"")
;; '("hMark as ham" . mu4e-view-register-msg-as-ham) t)
(defun mu4e-view-register-msg-as-spam (msg)
"Mark message as spam (view mode)."
"Register MSG as spam (view mode)."
(interactive)
(let* ((path (shell-quote-argument (mu4e-message-field msg :path)))
(command (format mu4e-register-as-spam-cmd path)))
@ -159,7 +163,7 @@ For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"")
(mu4e-view-mark-for-delete))
(defun mu4e-view-register-msg-as-ham (msg)
"Mark message as ham (view mode)."
"Mark MSG as ham (view mode)."
(interactive)
(let* ((path (shell-quote-argument(mu4e-message-field msg :path)))
(command (format mu4e-register-as-ham-cmd path)))
@ -173,8 +177,8 @@ For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"")
;; eshell. Does not depend on gnus.
(defun mu4e~active-composition-buffers ()
"Return all active mu4e composition buffers"
(defun mu4e--active-composition-buffers ()
"Return all active mu4e composition buffers."
(let (buffers)
(save-excursion
(dolist (buffer (buffer-list t))
@ -184,15 +188,17 @@ For example for bogofile, use \"/usr/bin/bogofilter -Sn < %s\"")
(nreverse buffers)))
(defun eshell/mu4e-attach (&rest args)
"Attach files to a mu4e message using eshell. If no mu4e
buffers found, compose a new message and then attach the file."
"Attach files to a mu4e message using eshell with ARGS.
If no mu4e buffers found, compose a new message and then attach
the file."
(let ((destination nil)
(files-str nil)
(bufs nil)
;; Remove directories from the list
(files-to-attach
(delq nil (mapcar
(lambda (f) (if (or (not (file-exists-p f)) (file-directory-p f))
(lambda (f) (if (or (not (file-exists-p f))
(file-directory-p f))
nil
(expand-file-name f)))
(eshell-flatten-list (reverse args))))))
@ -203,7 +209,7 @@ buffers found, compose a new message and then attach the file."
(mapconcat
(lambda (f) (file-name-nondirectory f))
files-to-attach ", "))
(setq bufs (mu4e~active-composition-buffers))
(setq bufs (mu4e--active-composition-buffers))
;; set up destination mail composition buffer
(if (and bufs
(y-or-n-p "Attach files to existing mail composition buffer? "))
@ -224,7 +230,8 @@ buffers found, compose a new message and then attach 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 (mm-default-file-encoding
(car files-to-attach))
"application/octet-stream") nil)
(setq files-to-attach (cdr files-to-attach)))
(message "Attached file(s) %s" files-str))