mu4e: use if-let*, when-let*
Avoid the silly byte-compilation warning
This commit is contained in:
@ -257,7 +257,7 @@ the message."
|
|||||||
"Browse the archive for a mailing list message MSG.
|
"Browse the archive for a mailing list message MSG.
|
||||||
See `mu4e-mailing-list-archive-url'."
|
See `mu4e-mailing-list-archive-url'."
|
||||||
(interactive (list (mu4e-message-at-point)))
|
(interactive (list (mu4e-message-at-point)))
|
||||||
(if-let ((url (mu4e-mailing-list-archive-url msg)))
|
(if-let* ((url (mu4e-mailing-list-archive-url msg)))
|
||||||
(browse-url url)
|
(browse-url url)
|
||||||
(mu4e-warn "No archive available for this message")))
|
(mu4e-warn "No archive available for this message")))
|
||||||
|
|
||||||
|
|||||||
@ -152,7 +152,7 @@ I.e., very new messages.")
|
|||||||
(defun mu4e-jump-to-favorite ()
|
(defun mu4e-jump-to-favorite ()
|
||||||
"Jump to to the favorite bookmark, if any."
|
"Jump to to the favorite bookmark, if any."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when-let ((fav (mu4e--bookmark-query (mu4e-bookmark-favorite))))
|
(when-let* ((fav (mu4e--bookmark-query (mu4e-bookmark-favorite))))
|
||||||
(mu4e-search-bookmark fav)))
|
(mu4e-search-bookmark fav)))
|
||||||
|
|
||||||
(defun mu4e--bookmarks-modeline-item ()
|
(defun mu4e--bookmarks-modeline-item ()
|
||||||
@ -160,7 +160,7 @@ I.e., very new messages.")
|
|||||||
|
|
||||||
This uses the one special ':favorite' bookmark, and if there is
|
This uses the one special ':favorite' bookmark, and if there is
|
||||||
one, creates a propertized string for display in the modeline."
|
one, creates a propertized string for display in the modeline."
|
||||||
(when-let ((fav ;; any results for the favorite bookmark item?
|
(when-let* ((fav ;; any results for the favorite bookmark item?
|
||||||
(seq-find (lambda (bm) (plist-get bm :favorite))
|
(seq-find (lambda (bm) (plist-get bm :favorite))
|
||||||
(mu4e-query-items 'bookmarks))))
|
(mu4e-query-items 'bookmarks))))
|
||||||
(cl-destructuring-bind (&key unread count delta-unread
|
(cl-destructuring-bind (&key unread count delta-unread
|
||||||
|
|||||||
@ -131,7 +131,7 @@ The address are either plain e-mail addresses or regexps (strings
|
|||||||
address patterns (if any)."
|
address patterns (if any)."
|
||||||
(seq-remove
|
(seq-remove
|
||||||
(lambda (addr) (and no-regexp (string-match-p "^/.*/" addr)))
|
(lambda (addr) (and no-regexp (string-match-p "^/.*/" addr)))
|
||||||
(when-let ((props (mu4e-server-properties)))
|
(when-let* ((props (mu4e-server-properties)))
|
||||||
(plist-get props :personal-addresses))))
|
(plist-get props :personal-addresses))))
|
||||||
|
|
||||||
(defun mu4e-personal-address-p (addr)
|
(defun mu4e-personal-address-p (addr)
|
||||||
|
|||||||
@ -387,7 +387,7 @@ also marked as Seen.
|
|||||||
|
|
||||||
Function assumes that it is executed in the context of the
|
Function assumes that it is executed in the context of the
|
||||||
message buffer."
|
message buffer."
|
||||||
(when-let ((buf (find-file-noselect path)))
|
(when-let* ((buf (find-file-noselect path)))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(let ((in-reply-to (message-field-value "in-reply-to"))
|
(let ((in-reply-to (message-field-value "in-reply-to"))
|
||||||
(forwarded-from)
|
(forwarded-from)
|
||||||
@ -445,14 +445,14 @@ appropriate flag at the message forwarded or replied-to."
|
|||||||
;; typically, draft is gone and the sent message appears in sent. Update flags
|
;; typically, draft is gone and the sent message appears in sent. Update flags
|
||||||
;; for related messages, i.e. for Forwarded ('Passed') and Replied messages,
|
;; for related messages, i.e. for Forwarded ('Passed') and Replied messages,
|
||||||
;; try to set the appropriate flag at the message forwarded or replied-to.
|
;; try to set the appropriate flag at the message forwarded or replied-to.
|
||||||
(when-let ((fcc-path (message-field-value "Fcc")))
|
(when-let* ((fcc-path (message-field-value "Fcc")))
|
||||||
(mu4e--set-parent-flags fcc-path)
|
(mu4e--set-parent-flags fcc-path)
|
||||||
;; we end up with a ((buried) buffer here, visiting the
|
;; we end up with a ((buried) buffer here, visiting the
|
||||||
;; fcc-path; not quite sure why. But let's get rid of it (#2681)
|
;; fcc-path; not quite sure why. But let's get rid of it (#2681)
|
||||||
(when-let ((buf (find-buffer-visiting fcc-path)))
|
(when-let* ((buf (find-buffer-visiting fcc-path)))
|
||||||
(kill-buffer buf)))
|
(kill-buffer buf)))
|
||||||
;; remove draft
|
;; remove draft
|
||||||
(when-let ((draft (buffer-file-name)))
|
(when-let* ((draft (buffer-file-name)))
|
||||||
(mu4e--server-remove draft)))
|
(mu4e--server-remove draft)))
|
||||||
|
|
||||||
(defun mu4e--compose-before-send ()
|
(defun mu4e--compose-before-send ()
|
||||||
@ -492,7 +492,7 @@ Creates a buffer NAME and returns it."
|
|||||||
(defun mu4e--message-is-yours-p ()
|
(defun mu4e--message-is-yours-p ()
|
||||||
"Mu4e's override for `message-is-yours-p'."
|
"Mu4e's override for `message-is-yours-p'."
|
||||||
(seq-some (lambda (field)
|
(seq-some (lambda (field)
|
||||||
(if-let ((recip (message-field-value field)))
|
(if-let* ((recip (message-field-value field)))
|
||||||
(mu4e-personal-or-alternative-address-p
|
(mu4e-personal-or-alternative-address-p
|
||||||
(car (mail-header-parse-address recip)))))
|
(car (mail-header-parse-address recip)))))
|
||||||
'("From" "Sender")))
|
'("From" "Sender")))
|
||||||
@ -596,7 +596,7 @@ COMPOSE-TYPE and PARENT are as in `mu4e--draft'."
|
|||||||
(set-visited-file-name ;; make it a draft file
|
(set-visited-file-name ;; make it a draft file
|
||||||
(mu4e--draft-message-path (mu4e--draft-basename) parent)))
|
(mu4e--draft-message-path (mu4e--draft-basename) parent)))
|
||||||
;; fcc
|
;; fcc
|
||||||
(when-let ((fcc-path (mu4e--fcc-path (mu4e--draft-basename) parent)))
|
(when-let* ((fcc-path (mu4e--fcc-path (mu4e--draft-basename) parent)))
|
||||||
(message-add-header (concat "Fcc: " fcc-path "\n")))
|
(message-add-header (concat "Fcc: " fcc-path "\n")))
|
||||||
|
|
||||||
(mu4e--prepare-draft-headers compose-type)
|
(mu4e--prepare-draft-headers compose-type)
|
||||||
|
|||||||
@ -669,7 +669,7 @@ This is suitable for displaying in the header view."
|
|||||||
|
|
||||||
(defsubst mu4e~headers-insert-header (msg pos)
|
(defsubst mu4e~headers-insert-header (msg pos)
|
||||||
"Insert a header for MSG at point POS."
|
"Insert a header for MSG at point POS."
|
||||||
(when-let ((line (mu4e~message-header-line msg))
|
(when-let* ((line (mu4e~message-header-line msg))
|
||||||
(docid (plist-get msg :docid)))
|
(docid (plist-get msg :docid)))
|
||||||
(goto-char pos)
|
(goto-char pos)
|
||||||
(insert
|
(insert
|
||||||
@ -1436,7 +1436,7 @@ If SUBTHREAD is non-nil, only apply to subthread."
|
|||||||
(if (functionp mu4e-view-auto-mark-as-read)
|
(if (functionp mu4e-view-auto-mark-as-read)
|
||||||
(funcall mu4e-view-auto-mark-as-read msg)
|
(funcall mu4e-view-auto-mark-as-read msg)
|
||||||
mu4e-view-auto-mark-as-read)))
|
mu4e-view-auto-mark-as-read)))
|
||||||
(when-let ((buf (mu4e-get-view-buffer (current-buffer) nil)))
|
(when-let* ((buf (mu4e-get-view-buffer (current-buffer) nil)))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(mu4e-loading-mode 1)))
|
(mu4e-loading-mode 1)))
|
||||||
(mu4e--server-view docid mark-as-read)))
|
(mu4e--server-view docid mark-as-read)))
|
||||||
|
|||||||
@ -259,7 +259,7 @@ Return the matching choice value (cdr of the cell)."
|
|||||||
(mapconcat #'car choices ", "))))
|
(mapconcat #'car choices ", "))))
|
||||||
(while (not chosen)
|
(while (not chosen)
|
||||||
(message nil) ;; this seems needed...
|
(message nil) ;; this seems needed...
|
||||||
(when-let ((kar (read-char-exclusive prompt)))
|
(when-let* ((kar (read-char-exclusive prompt)))
|
||||||
(when (eq kar ?\e) (keyboard-quit)) ;; `read-char-exclusive' is a C
|
(when (eq kar ?\e) (keyboard-quit)) ;; `read-char-exclusive' is a C
|
||||||
;; function and doesn't check for
|
;; function and doesn't check for
|
||||||
;; `keyboard-quit', there we need to
|
;; `keyboard-quit', there we need to
|
||||||
@ -543,7 +543,7 @@ Or go to the top level if there is none."
|
|||||||
|
|
||||||
(defun mu4e--jump-to-bookmark (bookmark)
|
(defun mu4e--jump-to-bookmark (bookmark)
|
||||||
"View the message referred to by BOOKMARK."
|
"View the message referred to by BOOKMARK."
|
||||||
(when-let ((msgid (bookmark-prop-get bookmark 'message-id)))
|
(when-let* ((msgid (bookmark-prop-get bookmark 'message-id)))
|
||||||
(mu4e-view-message-with-message-id msgid)))
|
(mu4e-view-message-with-message-id msgid)))
|
||||||
|
|
||||||
;;; Macros
|
;;; Macros
|
||||||
|
|||||||
@ -40,7 +40,7 @@ e.g. public-inbox-based archives."
|
|||||||
(defmacro mu4e-x-seq-url (base-url)
|
(defmacro mu4e-x-seq-url (base-url)
|
||||||
"Construct x-seq archive URL for MSG or nil if not found."
|
"Construct x-seq archive URL for MSG or nil if not found."
|
||||||
`(lambda (msg)
|
`(lambda (msg)
|
||||||
(when-let ((xseq (mu4e-fetch-field msg "X-Seq")))
|
(when-let* ((xseq (mu4e-fetch-field msg "X-Seq")))
|
||||||
(concat ,base-url "/" xseq))))
|
(concat ,base-url "/" xseq))))
|
||||||
|
|
||||||
;;; Configuration
|
;;; Configuration
|
||||||
|
|||||||
@ -238,9 +238,9 @@ Returns the full path."
|
|||||||
(defun mu4e-sexp-at-point ()
|
(defun mu4e-sexp-at-point ()
|
||||||
"Show or hide the s-expression for the message-at-point, if any."
|
"Show or hide the s-expression for the message-at-point, if any."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if-let ((win (get-buffer-window mu4e--sexp-buffer-name)))
|
(if-let* ((win (get-buffer-window mu4e--sexp-buffer-name)))
|
||||||
(delete-window win)
|
(delete-window win)
|
||||||
(when-let ((msg (mu4e-message-at-point 'noerror)))
|
(when-let* ((msg (mu4e-message-at-point 'noerror)))
|
||||||
(when (buffer-live-p mu4e--sexp-buffer-name)
|
(when (buffer-live-p mu4e--sexp-buffer-name)
|
||||||
(kill-buffer mu4e--sexp-buffer-name))
|
(kill-buffer mu4e--sexp-buffer-name))
|
||||||
(with-current-buffer-window
|
(with-current-buffer-window
|
||||||
|
|||||||
@ -97,7 +97,7 @@ There are some internal fields as well, e.g. ; subject to change:
|
|||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
(when-let ((part (get-text-property (point) 'gnus-data))
|
(when-let* ((part (get-text-property (point) 'gnus-data))
|
||||||
(index (get-text-property (point) 'gnus-part)))
|
(index (get-text-property (point) 'gnus-part)))
|
||||||
(when (and part (numberp index) (not (member index indices)))
|
(when (and part (numberp index) (not (member index indices)))
|
||||||
(let* ((disp (mm-handle-disposition part))
|
(let* ((disp (mm-handle-disposition part))
|
||||||
|
|||||||
@ -206,7 +206,7 @@ Reset individual folding states."
|
|||||||
"Unfold thread at point and store state unless NO-SAVE is t."
|
"Unfold thread at point and store state unless NO-SAVE is t."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless (eq (line-end-position) (point-max))
|
(unless (eq (line-end-position) (point-max))
|
||||||
(when-let ((overlay (mu4e-thread-is-folded)))
|
(when-let* ((overlay (mu4e-thread-is-folded)))
|
||||||
(unless no-save
|
(unless no-save
|
||||||
(mu4e-thread--save-state 'unfolded))
|
(mu4e-thread--save-state 'unfolded))
|
||||||
(delete-overlay overlay))))
|
(delete-overlay overlay))))
|
||||||
|
|||||||
@ -615,7 +615,7 @@ As a side-effect, a message that is being viewed loses its
|
|||||||
;; buffer-local state that *must* survive is correctly copied
|
;; buffer-local state that *must* survive is correctly copied
|
||||||
;; across.
|
;; across.
|
||||||
(let ((linked-headers-buffer))
|
(let ((linked-headers-buffer))
|
||||||
(when-let ((existing-buffer (mu4e-get-view-buffer nil nil)))
|
(when-let* ((existing-buffer (mu4e-get-view-buffer nil nil)))
|
||||||
;; required; this state must carry over from the killed buffer
|
;; required; this state must carry over from the killed buffer
|
||||||
;; to the new one.
|
;; to the new one.
|
||||||
(setq linked-headers-buffer mu4e-linked-headers-buffer)
|
(setq linked-headers-buffer mu4e-linked-headers-buffer)
|
||||||
@ -749,7 +749,7 @@ determine which browser function to use."
|
|||||||
"Refresh the message view."
|
"Refresh the message view."
|
||||||
;;; XXX: sometimes, side-effect: increase the header-buffers size
|
;;; XXX: sometimes, side-effect: increase the header-buffers size
|
||||||
(interactive)
|
(interactive)
|
||||||
(when-let ((msg (and (derived-mode-p 'mu4e-view-mode)
|
(when-let* ((msg (and (derived-mode-p 'mu4e-view-mode)
|
||||||
mu4e--view-message)))
|
mu4e--view-message)))
|
||||||
(mu4e-view-quit)
|
(mu4e-view-quit)
|
||||||
(mu4e-view msg)))
|
(mu4e-view msg)))
|
||||||
@ -789,7 +789,7 @@ Note that for some messages, this can trigger high CPU load."
|
|||||||
((or ':path ':maildir ':list)
|
((or ':path ':maildir ':list)
|
||||||
(mu4e--view-gnus-insert-header field fieldval))
|
(mu4e--view-gnus-insert-header field fieldval))
|
||||||
(':message-id
|
(':message-id
|
||||||
(when-let ((msgid (plist-get msg :message-id)))
|
(when-let* ((msgid (plist-get msg :message-id)))
|
||||||
(mu4e--view-gnus-insert-header field (format "<%s>" msgid))))
|
(mu4e--view-gnus-insert-header field (format "<%s>" msgid))))
|
||||||
(':mailing-list
|
(':mailing-list
|
||||||
(let ((list (plist-get msg :list)))
|
(let ((list (plist-get msg :list)))
|
||||||
@ -1109,7 +1109,7 @@ Article Treatment' for more options."
|
|||||||
;; This function assumes `gnus-article-mime-handle-alist' is sorted by
|
;; This function assumes `gnus-article-mime-handle-alist' is sorted by
|
||||||
;; pertinence, i.e. the first HTML part found in it is the most important one.
|
;; pertinence, i.e. the first HTML part found in it is the most important one.
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(if-let ((html-part
|
(if-let*((html-part
|
||||||
(seq-find (lambda (handle)
|
(seq-find (lambda (handle)
|
||||||
(equal (mm-handle-media-type (cdr handle))
|
(equal (mm-handle-media-type (cdr handle))
|
||||||
"text/html"))
|
"text/html"))
|
||||||
|
|||||||
@ -263,7 +263,7 @@ This is an action function for buffer display, see Info
|
|||||||
node `(elisp) Buffer Display Action Functions'. It should be
|
node `(elisp) Buffer Display Action Functions'. It should be
|
||||||
called only by `display-buffer' or a function directly or
|
called only by `display-buffer' or a function directly or
|
||||||
indirectly called by the latter."
|
indirectly called by the latter."
|
||||||
(when-let ((window (or (display-buffer-reuse-window buffer alist)
|
(when-let* ((window (or (display-buffer-reuse-window buffer alist)
|
||||||
(display-buffer-same-window buffer alist)
|
(display-buffer-same-window buffer alist)
|
||||||
(display-buffer-pop-up-window buffer alist)
|
(display-buffer-pop-up-window buffer alist)
|
||||||
(display-buffer-use-some-window buffer alist))))
|
(display-buffer-use-some-window buffer alist))))
|
||||||
@ -364,9 +364,9 @@ and `mu4e-headers-visible-lines' or
|
|||||||
This function is best called from the hook
|
This function is best called from the hook
|
||||||
`mu4e-view-rendered-hook'."
|
`mu4e-view-rendered-hook'."
|
||||||
(unless (mu4e-current-buffer-type-p 'view)
|
(unless (mu4e-current-buffer-type-p 'view)
|
||||||
(mu4e-error "Cannot resize as this is not a valid view buffer."))
|
(mu4e-error "Cannot resize as this is not a valid view buffer"))
|
||||||
(when-let (win (and mu4e-linked-headers-buffer
|
(when-let* ((win (and mu4e-linked-headers-buffer
|
||||||
(get-buffer-window mu4e-linked-headers-buffer)))
|
(get-buffer-window mu4e-linked-headers-buffer)))
|
||||||
;; This can fail for any number of reasons. If it does, we do
|
;; This can fail for any number of reasons. If it does, we do
|
||||||
;; nothing. If the user has customized the window display we may
|
;; nothing. If the user has customized the window display we may
|
||||||
;; find it impossible to resize the window, and that should not be
|
;; find it impossible to resize the window, and that should not be
|
||||||
@ -377,7 +377,7 @@ This function is best called from the hook
|
|||||||
(window-width win nil))
|
(window-width win nil))
|
||||||
t t nil))
|
t t nil))
|
||||||
((eq mu4e-split-view 'horizontal)
|
((eq mu4e-split-view 'horizontal)
|
||||||
(set-window-text-height win mu4e-headers-visible-lines))))))
|
(set-window-text-height win mu4e-headers-visible-lines)))))))
|
||||||
|
|
||||||
(provide 'mu4e-window)
|
(provide 'mu4e-window)
|
||||||
;;; mu4e-window.el ends here
|
;;; mu4e-window.el ends here
|
||||||
|
|||||||
Reference in New Issue
Block a user