Appease the byte compiler and clean up the code

This commit is contained in:
Mickey Petersen 2022-12-06 09:46:39 +00:00
parent 8ac172cd08
commit 42add64683
6 changed files with 37 additions and 35 deletions

View File

@ -76,7 +76,7 @@
(require 'mu4e-message)
(require 'mu4e-draft)
(require 'mu4e-context)
(require 'mu4e-window)
;;; Configuration
;; see mu4e-drafts.el
@ -502,8 +502,7 @@ See `mu4e-compose-crypto-policy' for more details."
(sign (mml-secure-message-sign))
(encrypt (mml-secure-message-encrypt)))))
(cl-defun mu4e~compose-handler (compose-type &optional original-msg includes
switch-function)
(cl-defun mu4e~compose-handler (compose-type &optional original-msg includes)
"Create a new draft message, or open an existing one.
COMPOSE-TYPE determines the kind of message to compose and is a
@ -542,7 +541,7 @@ are optional."
(let ((draft-buffer))
(let ((winconf (current-window-configuration)))
(condition-case nil
(setq draft-buffer (mu4e-draft-open compose-type original-msg switch-function))
(setq draft-buffer (mu4e-draft-open compose-type original-msg))
(quit (set-window-configuration winconf)
(mu4e-message "Operation aborted")
(cl-return-from mu4e~compose-handler))))
@ -797,8 +796,7 @@ draft message."
;;;###autoload
(defun mu4e~compose-mail (&optional to subject other-headers _continue
switch-function yank-action
_send-actions _return-action)
yank-action _send-actions _return-action)
"This is mu4e's implementation of `compose-mail'.
Quoting its docstring:
@ -814,9 +812,6 @@ HEADER and VALUE are strings.
CONTINUE, if non-nil, says to continue editing a message already
being composed. Interactively, CONTINUE is the prefix argument.
SWITCH-FUNCTION, if non-nil, is a function to use to
switch to and display the buffer used for mail composition.
YANK-ACTION, if non-nil, is an action to perform, if and when
necessary, to insert the raw text of the message being replied
to. It has the form (FUNCTION . ARGS). The user agent will apply
@ -833,11 +828,11 @@ called after the mail has been sent or put aside, and the mail
buffer buried."
(unless (mu4e-running-p)
(mu4e))
(mu4e))
;; create a new draft message 'resetting' (as below) is not actually needed in
;; this case, but let's prepare for the re-edit case as well
(mu4e~compose-handler 'new nil nil switch-function)
(mu4e~compose-handler 'new nil nil)
(when (message-goto-to) ;; reset to-address, if needed
(message-delete-line))

View File

@ -665,7 +665,7 @@ will be the same as in the original."
"The drafts-folder for this compose buffer.
This is based on `mu4e-drafts-folder', which is evaluated once.")
(defun mu4e~draft-open-file (path switch-function)
(defun mu4e~draft-open-file (path)
"Open the the draft file at PATH."
(find-file-noselect path))
@ -676,7 +676,7 @@ This is based on `mu4e-drafts-folder', which is evaluated once.")
(mu4e-root-maildir) draft-dir (mu4e~draft-message-filename-construct "DS")))
(defun mu4e-draft-open (compose-type &optional msg switch-function)
(defun mu4e-draft-open (compose-type &optional msg)
"Open a draft file for a message MSG.
In case of a new message (when COMPOSE-TYPE is `reply', `forward'
or `new'), open an existing draft (when COMPOSE-TYPE is `edit'),
@ -699,7 +699,7 @@ Returns the newly-created draft buffer."
;; full path, but we cannot really know 'drafts folder'... we make a
;; guess
(setq draft-dir (mu4e--guess-maildir (mu4e-message-field msg :path)))
(setq draft-buffer (mu4e~draft-open-file (mu4e-message-field msg :path) switch-function)))
(setq draft-buffer (mu4e~draft-open-file (mu4e-message-field msg :path))))
(resend
;; case-2: copy some exisisting message to a draft message, then edit
@ -707,7 +707,7 @@ Returns the newly-created draft buffer."
(setq draft-dir (mu4e--guess-maildir (mu4e-message-field msg :path)))
(let ((draft-path (mu4e~draft-determine-path draft-dir)))
(copy-file (mu4e-message-field msg :path) draft-path)
(setq draft-buffer (mu4e~draft-open-file draft-path switch-function))))
(setq draft-buffer (mu4e~draft-open-file draft-path))))
((reply forward new)
;; case-3: creating a new message; in this case, we can determine
@ -719,7 +719,7 @@ Returns the newly-created draft buffer."
(reply (mu4e~draft-reply-construct msg))
(forward (mu4e~draft-forward-construct msg))
(new (mu4e~draft-newmsg-construct)))))
(setq draft-buffer (mu4e~draft-open-file draft-path switch-function))
(setq draft-buffer (mu4e~draft-open-file draft-path))
(set-buffer draft-buffer)
(insert initial-contents)
(newline)

View File

@ -724,7 +724,7 @@ docid is not found."
(defun mu4e~headers-view-this-message-p (docid)
"Is DOCID currently being viewed?"
(mu4e-get-view-buffers (lambda (buf) (eq docid (plist-get mu4e~view-message :docid)))))
(mu4e-get-view-buffers (lambda (_) (eq docid (plist-get mu4e~view-message :docid)))))
;; note: this function is very performance-sensitive
(defun mu4e~headers-append-handler (msglst)
@ -1771,23 +1771,30 @@ other windows."
;;; Loading messages
;;
(defvar-local mu4e--loading-overlay-bg nil
"Internal variable that holds the loading overlay for the background.")
(defvar-local mu4e--loading-overlay-text nil
"Internal variable that holds the loading overlay for the text.")
(define-minor-mode mu4e-loading-mode
"Minor mode for buffers awaiting data from mu"
:init-value nil :lighter " Loading" :keymap nil
(if mu4e-loading-mode
(progn
(when mu4e-dim-when-loading
(set (make-variable-buffer-local 'mu4e--loading-overlay-bg)
(let ((overlay (make-overlay (point-min) (point-max))))
(overlay-put overlay 'face `(:foreground "gray22" :background
,(face-attribute 'default :background)))
(overlay-put overlay 'priority 9998)
overlay)))
(set (make-variable-buffer-local 'mu4e--loading-overlay-text)
(let ((overlay (make-overlay (point-min) (point-min))))
(overlay-put overlay 'priority 9999)
(overlay-put overlay 'before-string (propertize "Loading…\n" 'face 'mu4e-header-title-face))
overlay)))
(setq mu4e--loading-overlay-bg
(let ((overlay (make-overlay (point-min) (point-max))))
(overlay-put overlay 'face `(:foreground "gray22" :background
,(face-attribute 'default :background)))
(overlay-put overlay 'priority 9998)
overlay)))
(setq mu4e--loading-overlay-text
(let ((overlay (make-overlay (point-min) (point-min))))
(overlay-put overlay 'priority 9999)
(overlay-put overlay 'before-string (propertize "Loading…\n" 'face 'mu4e-header-title-face))
overlay)))
(when mu4e--loading-overlay-bg
(delete-overlay mu4e--loading-overlay-bg))
(when mu4e--loading-overlay-text

View File

@ -98,7 +98,7 @@ is the target directory (for \"move\")")
(defun mu4e--mark-find-headers-buffer ()
"Find the headers buffer, if any."
(seq-find (lambda (b)
(seq-find (lambda (_)
(mu4e-current-buffer-type-p 'headers))
(buffer-list)))

View File

@ -222,11 +222,11 @@ if you otherwise want to use `mu4e-index-lazy-check'."
This function uses `display-buffer' with a default preset.
To override this behavior, customize `display-buffer-alist'."
(let ((win (display-buffer buf `(display-buffer-at-bottom
(preserve-size . (nil . t))
(height . ,height)
(window-height . fit-window-to-buffer)))))
(set-window-buffer (get-buffer-window buf) buf)))
(display-buffer buf `(display-buffer-at-bottom
(preserve-size . (nil . t))
(height . ,height)
(window-height . fit-window-to-buffer)))
(set-window-buffer (get-buffer-window buf) buf))
(defun mu4e--update-sentinel-func (proc _msg)
"Sentinel function for the update process PROC."

View File

@ -58,7 +58,7 @@ Follows the format of `format-time-string'."
(defcustom mu4e-dim-when-loading t
"Dim buffer text when loading new data.
If non-nil, dim some buffers during data retrieval and rendering. Disable this if you"
If non-nil, dim some buffers during data retrieval and rendering."
:type 'boolean
:group 'mu4e)