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.
|
||||
See `mu4e-mailing-list-archive-url'."
|
||||
(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)
|
||||
(mu4e-warn "No archive available for this message")))
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ I.e., very new messages.")
|
||||
(defun mu4e-jump-to-favorite ()
|
||||
"Jump to to the favorite bookmark, if any."
|
||||
(interactive)
|
||||
(when-let ((fav (mu4e--bookmark-query (mu4e-bookmark-favorite))))
|
||||
(when-let* ((fav (mu4e--bookmark-query (mu4e-bookmark-favorite))))
|
||||
(mu4e-search-bookmark fav)))
|
||||
|
||||
(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
|
||||
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))
|
||||
(mu4e-query-items 'bookmarks))))
|
||||
(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)."
|
||||
(seq-remove
|
||||
(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))))
|
||||
|
||||
(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
|
||||
message buffer."
|
||||
(when-let ((buf (find-file-noselect path)))
|
||||
(when-let* ((buf (find-file-noselect path)))
|
||||
(with-current-buffer buf
|
||||
(let ((in-reply-to (message-field-value "in-reply-to"))
|
||||
(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
|
||||
;; for related messages, i.e. for Forwarded ('Passed') and Replied messages,
|
||||
;; 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)
|
||||
;; we end up with a ((buried) buffer here, visiting the
|
||||
;; 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)))
|
||||
;; remove draft
|
||||
(when-let ((draft (buffer-file-name)))
|
||||
(when-let* ((draft (buffer-file-name)))
|
||||
(mu4e--server-remove draft)))
|
||||
|
||||
(defun mu4e--compose-before-send ()
|
||||
@ -492,7 +492,7 @@ Creates a buffer NAME and returns it."
|
||||
(defun mu4e--message-is-yours-p ()
|
||||
"Mu4e's override for `message-is-yours-p'."
|
||||
(seq-some (lambda (field)
|
||||
(if-let ((recip (message-field-value field)))
|
||||
(if-let* ((recip (message-field-value field)))
|
||||
(mu4e-personal-or-alternative-address-p
|
||||
(car (mail-header-parse-address recip)))))
|
||||
'("From" "Sender")))
|
||||
@ -596,7 +596,7 @@ COMPOSE-TYPE and PARENT are as in `mu4e--draft'."
|
||||
(set-visited-file-name ;; make it a draft file
|
||||
(mu4e--draft-message-path (mu4e--draft-basename) parent)))
|
||||
;; 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")))
|
||||
|
||||
(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)
|
||||
"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)))
|
||||
(goto-char pos)
|
||||
(insert
|
||||
@ -1436,7 +1436,7 @@ If SUBTHREAD is non-nil, only apply to subthread."
|
||||
(if (functionp mu4e-view-auto-mark-as-read)
|
||||
(funcall mu4e-view-auto-mark-as-read msg)
|
||||
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
|
||||
(mu4e-loading-mode 1)))
|
||||
(mu4e--server-view docid mark-as-read)))
|
||||
|
||||
@ -259,7 +259,7 @@ Return the matching choice value (cdr of the cell)."
|
||||
(mapconcat #'car choices ", "))))
|
||||
(while (not chosen)
|
||||
(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
|
||||
;; function and doesn't check for
|
||||
;; `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)
|
||||
"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)))
|
||||
|
||||
;;; Macros
|
||||
|
||||
@ -40,7 +40,7 @@ e.g. public-inbox-based archives."
|
||||
(defmacro mu4e-x-seq-url (base-url)
|
||||
"Construct x-seq archive URL for MSG or nil if not found."
|
||||
`(lambda (msg)
|
||||
(when-let ((xseq (mu4e-fetch-field msg "X-Seq")))
|
||||
(when-let* ((xseq (mu4e-fetch-field msg "X-Seq")))
|
||||
(concat ,base-url "/" xseq))))
|
||||
|
||||
;;; Configuration
|
||||
|
||||
@ -238,9 +238,9 @@ Returns the full path."
|
||||
(defun mu4e-sexp-at-point ()
|
||||
"Show or hide the s-expression for the message-at-point, if any."
|
||||
(interactive)
|
||||
(if-let ((win (get-buffer-window mu4e--sexp-buffer-name)))
|
||||
(if-let* ((win (get-buffer-window mu4e--sexp-buffer-name)))
|
||||
(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)
|
||||
(kill-buffer mu4e--sexp-buffer-name))
|
||||
(with-current-buffer-window
|
||||
|
||||
@ -97,7 +97,7 @@ There are some internal fields as well, e.g. ; subject to change:
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(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)))
|
||||
(when (and part (numberp index) (not (member index indices)))
|
||||
(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."
|
||||
(interactive)
|
||||
(unless (eq (line-end-position) (point-max))
|
||||
(when-let ((overlay (mu4e-thread-is-folded)))
|
||||
(when-let* ((overlay (mu4e-thread-is-folded)))
|
||||
(unless no-save
|
||||
(mu4e-thread--save-state 'unfolded))
|
||||
(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
|
||||
;; across.
|
||||
(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
|
||||
;; to the new one.
|
||||
(setq linked-headers-buffer mu4e-linked-headers-buffer)
|
||||
@ -749,7 +749,7 @@ determine which browser function to use."
|
||||
"Refresh the message view."
|
||||
;;; XXX: sometimes, side-effect: increase the header-buffers size
|
||||
(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-quit)
|
||||
(mu4e-view msg)))
|
||||
@ -789,7 +789,7 @@ Note that for some messages, this can trigger high CPU load."
|
||||
((or ':path ':maildir ':list)
|
||||
(mu4e--view-gnus-insert-header field fieldval))
|
||||
(':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))))
|
||||
(':mailing-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
|
||||
;; pertinence, i.e. the first HTML part found in it is the most important one.
|
||||
(save-excursion
|
||||
(if-let ((html-part
|
||||
(if-let*((html-part
|
||||
(seq-find (lambda (handle)
|
||||
(equal (mm-handle-media-type (cdr handle))
|
||||
"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
|
||||
called only by `display-buffer' or a function directly or
|
||||
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-pop-up-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
|
||||
`mu4e-view-rendered-hook'."
|
||||
(unless (mu4e-current-buffer-type-p 'view)
|
||||
(mu4e-error "Cannot resize as this is not a valid view buffer."))
|
||||
(when-let (win (and mu4e-linked-headers-buffer
|
||||
(get-buffer-window mu4e-linked-headers-buffer)))
|
||||
(mu4e-error "Cannot resize as this is not a valid view buffer"))
|
||||
(when-let* ((win (and mu4e-linked-headers-buffer
|
||||
(get-buffer-window mu4e-linked-headers-buffer)))
|
||||
;; This can fail for any number of reasons. If it does, we do
|
||||
;; nothing. If the user has customized the window display we may
|
||||
;; 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))
|
||||
t t nil))
|
||||
((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)
|
||||
;;; mu4e-window.el ends here
|
||||
|
||||
Reference in New Issue
Block a user