mirror of https://github.com/djcb/mu.git
mu4e-view-gnus: Fix some flycheck warnings (doc)
Update docstring to please flycheck.
This commit is contained in:
parent
2c99cb3374
commit
e6e2568178
|
@ -62,8 +62,7 @@
|
||||||
(mu4e~view-render-buffer msg))
|
(mu4e~view-render-buffer msg))
|
||||||
|
|
||||||
(defun mu4e-view-message-text (msg)
|
(defun mu4e-view-message-text (msg)
|
||||||
"Return the pristine message as a string, for replying/forwarding
|
"Return the pristine MSG as a string."
|
||||||
etc."
|
|
||||||
;; we need this for replying/forwarding, since the mu4e-compose
|
;; we need this for replying/forwarding, since the mu4e-compose
|
||||||
;; wants it that way.
|
;; wants it that way.
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
@ -96,8 +95,7 @@ determine which browser function to use."
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-render-buffer (msg)
|
(defun mu4e~view-render-buffer (msg)
|
||||||
"Render current buffer with MSG using Gnus' article mode in
|
"Render current buffer with MSG using Gnus' article mode."
|
||||||
buffer BUF."
|
|
||||||
(setq gnus-summary-buffer (get-buffer-create " *appease-gnus*"))
|
(setq gnus-summary-buffer (get-buffer-create " *appease-gnus*"))
|
||||||
(let* ((inhibit-read-only t)
|
(let* ((inhibit-read-only t)
|
||||||
(max-specpdl-size mu4e-view-max-specpdl-size)
|
(max-specpdl-size mu4e-view-max-specpdl-size)
|
||||||
|
@ -136,7 +134,7 @@ buffer BUF."
|
||||||
(setq mu4e~gnus-article-mime-handles nil)))
|
(setq mu4e~gnus-article-mime-handles nil)))
|
||||||
|
|
||||||
(defun mu4e~view-gnus-display-mime (msg)
|
(defun mu4e~view-gnus-display-mime (msg)
|
||||||
"Same as `gnus-display-mime' but include mu4e headers to MSG."
|
"Like `gnus-display-mime' but include mu4e headers to MSG."
|
||||||
(lambda (&optional ihandles)
|
(lambda (&optional ihandles)
|
||||||
(gnus-display-mime ihandles)
|
(gnus-display-mime ihandles)
|
||||||
(unless ihandles
|
(unless ihandles
|
||||||
|
@ -167,7 +165,7 @@ buffer BUF."
|
||||||
(gnus-treat-article 'head))))))
|
(gnus-treat-article 'head))))))
|
||||||
|
|
||||||
(defun mu4e~view-gnus-insert-header (field val)
|
(defun mu4e~view-gnus-insert-header (field val)
|
||||||
"Insert a header FIELD with value VAL in Gnus article view."
|
"Insert a header FIELD with value VAL."
|
||||||
(let* ((info (cdr (assoc field mu4e-header-info)))
|
(let* ((info (cdr (assoc field mu4e-header-info)))
|
||||||
(key (plist-get info :name))
|
(key (plist-get info :name))
|
||||||
(help (plist-get info :help)))
|
(help (plist-get info :help)))
|
||||||
|
@ -176,12 +174,12 @@ buffer BUF."
|
||||||
" " val "\n"))))
|
" " val "\n"))))
|
||||||
|
|
||||||
(defun mu4e~view-gnus-insert-header-custom (msg field)
|
(defun mu4e~view-gnus-insert-header-custom (msg field)
|
||||||
"Insert the custom FIELD in Gnus article view."
|
"Insert MSG's custom FIELD."
|
||||||
(let* ((info (cdr-safe (or (assoc field mu4e-header-info-custom)
|
(let* ((info (cdr-safe (or (assoc field mu4e-header-info-custom)
|
||||||
(mu4e-error "custom field %S not found" field))))
|
(mu4e-error "Custom field %S not found" field))))
|
||||||
(key (plist-get info :name))
|
(key (plist-get info :name))
|
||||||
(func (or (plist-get info :function)
|
(func (or (plist-get info :function)
|
||||||
(mu4e-error "no :function defined for custom field %S %S"
|
(mu4e-error "No :function defined for custom field %S %S"
|
||||||
field info)))
|
field info)))
|
||||||
(val (funcall func msg))
|
(val (funcall func msg))
|
||||||
(help (plist-get info :help)))
|
(help (plist-get info :help)))
|
||||||
|
@ -190,8 +188,7 @@ buffer BUF."
|
||||||
|
|
||||||
(define-advice gnus-icalendar-event-from-handle
|
(define-advice gnus-icalendar-event-from-handle
|
||||||
(:filter-args (handle-attendee) mu4e~view-fix-missing-charset)
|
(:filter-args (handle-attendee) mu4e~view-fix-missing-charset)
|
||||||
"Do not trigger an error when displaying an ical attachment
|
"Avoid error when displaying an ical attachment without a charset."
|
||||||
with no charset."
|
|
||||||
(if (and (boundp 'mu4e~view-rendering) mu4e~view-rendering)
|
(if (and (boundp 'mu4e~view-rendering) mu4e~view-rendering)
|
||||||
(let* ((handle (car handle-attendee))
|
(let* ((handle (car handle-attendee))
|
||||||
(attendee (cadr handle-attendee))
|
(attendee (cadr handle-attendee))
|
||||||
|
@ -204,25 +201,25 @@ with no charset."
|
||||||
(list handle attendee))
|
(list handle attendee))
|
||||||
handle-attendee))
|
handle-attendee))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-mode-p ()
|
(defun mu4e~view-mode-p ()
|
||||||
|
"Is the buffer in mu4e-view-mode or one of its descendants?"
|
||||||
(or (eq major-mode 'mu4e-view-mode)
|
(or (eq major-mode 'mu4e-view-mode)
|
||||||
(derived-mode-p '(mu4e-view-mode))))
|
(derived-mode-p '(mu4e-view-mode))))
|
||||||
|
|
||||||
(defun mu4e~view-nop (func &rest args)
|
(defun mu4e~view-nop (func &rest args)
|
||||||
"Do nothing when in mu4e-view-mode. This is useful for advising
|
"Do not invoke FUNC with ARGS when in mu4e-view-mode.
|
||||||
some Gnus-functionality that does not work in mu4e."
|
This is useful for advising some Gnus-functionality that does not work in mu4e."
|
||||||
(unless (mu4e~view-mode-p)
|
(unless (mu4e~view-mode-p)
|
||||||
(apply func args)))
|
(apply func args)))
|
||||||
|
|
||||||
(defun mu4e~view-button-reply (func &rest args)
|
(defun mu4e~view-button-reply (func &rest args)
|
||||||
"Advice to make `gnus-button-reply' links work in mu4e."
|
"Advise FUNC with ARGS to make `gnus-button-reply' links work in mu4e."
|
||||||
(if (mu4e~view-mode-p)
|
(if (mu4e~view-mode-p)
|
||||||
(mu4e-compose-reply)
|
(mu4e-compose-reply)
|
||||||
(apply func args)))
|
(apply func args)))
|
||||||
|
|
||||||
(defun mu4e~view-msg-mail (func &rest args)
|
(defun mu4e~view-msg-mail (func &rest args)
|
||||||
"Advice to make `gnus-msg-mail' links compose with mu4e."
|
"Advise FUNC with ARGS to make `gnus-msg-mail' links compose with mu4e."
|
||||||
(if (mu4e~view-mode-p)
|
(if (mu4e~view-mode-p)
|
||||||
(apply 'mu4e~compose-mail args)
|
(apply 'mu4e~compose-mail args)
|
||||||
(apply func args)))
|
(apply func args)))
|
||||||
|
@ -392,7 +389,7 @@ some Gnus-functionality that does not work in mu4e."
|
||||||
|
|
||||||
(set-keymap-parent map special-mode-map)
|
(set-keymap-parent map special-mode-map)
|
||||||
map)
|
map)
|
||||||
"Keymap for mu4e-view mode")
|
"Keymap for mu4e-view mode.")
|
||||||
|
|
||||||
(set-keymap-parent mu4e-view-mode-map button-buffer-map)
|
(set-keymap-parent mu4e-view-mode-map button-buffer-map)
|
||||||
(suppress-keymap mu4e-view-mode-map)
|
(suppress-keymap mu4e-view-mode-map)
|
||||||
|
@ -417,8 +414,8 @@ some Gnus-functionality that does not work in mu4e."
|
||||||
|
|
||||||
;; "Define the major-mode for the mu4e-view."
|
;; "Define the major-mode for the mu4e-view."
|
||||||
(define-derived-mode mu4e-view-mode gnus-article-mode "mu4e:view"
|
(define-derived-mode mu4e-view-mode gnus-article-mode "mu4e:view"
|
||||||
"Major mode for viewing an e-mail message in mu4e, based on
|
"Major mode for viewing an e-mail message in mu4e.
|
||||||
Gnus' article-mode."
|
Based on Gnus' article-mode."
|
||||||
;; Restore C-h b default behavior
|
;; Restore C-h b default behavior
|
||||||
(define-key mu4e-view-mode-map (kbd "C-h b") 'describe-bindings)
|
(define-key mu4e-view-mode-map (kbd "C-h b") 'describe-bindings)
|
||||||
;; ;; turn off gnus modeline changes and menu items
|
;; ;; turn off gnus modeline changes and menu items
|
||||||
|
@ -452,10 +449,9 @@ Article Treatment' for more options."
|
||||||
|
|
||||||
;;; MIME-parts
|
;;; MIME-parts
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-gather-mime-parts ()
|
(defun mu4e~view-gather-mime-parts ()
|
||||||
"Gather all MIME parts as an alist that uniquely maps the number
|
"Gather all MIME parts as an alist.
|
||||||
to the gnus-part."
|
The alist uniquely maps the number to the gnus-part."
|
||||||
(let ((parts '()))
|
(let ((parts '()))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
@ -469,7 +465,7 @@ to the gnus-part."
|
||||||
parts))
|
parts))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-view-save-attachments (&optional arg)
|
(defun mu4e-view-save-attachments (&optional _arg)
|
||||||
"Save mime parts from current mu4e gnus view buffer.
|
"Save mime parts from current mu4e gnus view buffer.
|
||||||
|
|
||||||
When helm-mode is enabled provide completion on attachments and
|
When helm-mode is enabled provide completion on attachments and
|
||||||
|
@ -504,7 +500,7 @@ containing commas."
|
||||||
dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir))
|
dir (if arg (read-directory-name "Save to directory: ") mu4e-attachment-dir))
|
||||||
(cl-loop for (f . h) in handles
|
(cl-loop for (f . h) in handles
|
||||||
when (member f files)
|
when (member f files)
|
||||||
do (mm-save-part-to-file h (expand-file-name f dir))))
|
do (mm-save-part h (expand-file-name f dir))))
|
||||||
(mu4e-message "No attached files found"))))
|
(mu4e-message "No attached files found"))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,9 +510,9 @@ containing commas."
|
||||||
;; some basic ones
|
;; some basic ones
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; save mime-part to a file
|
;; save MIME-part to a file
|
||||||
(:name "save" :handler gnus-article-save-part :receives index)
|
(:name "save" :handler gnus-article-save-part :receives index)
|
||||||
;; pipe mime part to some arbitrary shell command
|
;; pipe MIME-part to some arbitrary shell command
|
||||||
(:name "|pipe" :handler gnus-article-pipe-part :receives index)
|
(:name "|pipe" :handler gnus-article-pipe-part :receives index)
|
||||||
;; open with the default handler, if any
|
;; open with the default handler, if any
|
||||||
(:name "open" :handler mu4e~view-open-file :receives temp)
|
(:name "open" :handler mu4e~view-open-file :receives temp)
|
||||||
|
@ -544,7 +540,9 @@ containing commas."
|
||||||
(goto-char (point-min)))
|
(goto-char (point-min)))
|
||||||
(switch-to-buffer tmpbuf))) :receives pipe))
|
(switch-to-buffer tmpbuf))) :receives pipe))
|
||||||
|
|
||||||
"Actions for MIME-parts. Each is a plist with keys
|
"Specifies actions for MIME-parts.
|
||||||
|
|
||||||
|
Each of the actions is a plist with keys
|
||||||
`(:name <name> ;; name of the action; shortcut is first letter of name
|
`(:name <name> ;; name of the action; shortcut is first letter of name
|
||||||
|
|
||||||
:handler ;; one of:
|
:handler ;; one of:
|
||||||
|
@ -562,11 +560,11 @@ containing commas."
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-mime-part-to-temp-file (handle)
|
(defun mu4e~view-mime-part-to-temp-file (handle)
|
||||||
"Write mime-part N to a temporary file and return the file name.
|
"Write MIME-part HANDLE to a temporary file and return the file name.
|
||||||
The filename is deduced from the MIME-part's filename, or
|
The filename is deduced from the MIME-part's filename, or
|
||||||
otherwise random; the result is placed in temporary directory
|
otherwise random; the result is placed in a temporary directory
|
||||||
with a unique name. Returns the full path for the file
|
with a unique name. Returns the full path for the file created.
|
||||||
created. The directory and file are self-destructed."
|
The directory and file are self-destructed."
|
||||||
(let* ((tmpdir (make-temp-file "mu4e-temp-" t))
|
(let* ((tmpdir (make-temp-file "mu4e-temp-" t))
|
||||||
(fname (cdr-safe (assoc 'filename (assoc "attachment" (cdr handle)))))
|
(fname (cdr-safe (assoc 'filename (assoc "attachment" (cdr handle)))))
|
||||||
(fname (if fname
|
(fname (if fname
|
||||||
|
@ -579,8 +577,9 @@ created. The directory and file are self-destructed."
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-open-file (file &optional force-ask)
|
(defun mu4e~view-open-file (file &optional force-ask)
|
||||||
"Open FILE with default handler, if any. Otherwise, or if FORCE_ASK is set,
|
"Open FILE with default handler, if any.
|
||||||
ask user for the program to open with."
|
Otherwise, or if FORCE-ASK is set, ask user for the program to
|
||||||
|
open with."
|
||||||
(let* ((opener
|
(let* ((opener
|
||||||
(pcase system-type
|
(pcase system-type
|
||||||
(`darwin "open")
|
(`darwin "open")
|
||||||
|
@ -591,24 +590,21 @@ ask user for the program to open with."
|
||||||
(call-process prog nil 0 nil file)))
|
(call-process prog nil 0 nil file)))
|
||||||
|
|
||||||
(defun mu4e-view-mime-part-action (&optional n)
|
(defun mu4e-view-mime-part-action (&optional n)
|
||||||
"Apply some action on mime-part N in the current messsage.
|
"Apply some action to MIME-part N in the current messsage.
|
||||||
If N is not specified, ask for it. N can be supplied as a
|
If N is not specified, ask for it. For instance, '3 A o' opens
|
||||||
prefix-argument, and note that one does not need to prefix that
|
the third MIME-part."
|
||||||
with C-u.
|
|
||||||
|
|
||||||
I.e., '3 A o' opens the third MIME-part."
|
|
||||||
(interactive "NNumber of MIME-part: ")
|
(interactive "NNumber of MIME-part: ")
|
||||||
(let* ((parts (mu4e~view-gather-mime-parts))
|
(let* ((parts (mu4e~view-gather-mime-parts))
|
||||||
(options (mapcar (lambda (action) `(,(plist-get action :name) . ,action))
|
(options (mapcar (lambda (action) `(,(plist-get action :name) . ,action))
|
||||||
mu4e-view-mime-part-actions))
|
mu4e-view-mime-part-actions))
|
||||||
(handle (or (cdr-safe (cl-find-if (lambda (part) (eq (car part) n)) parts))
|
(handle (or (cdr-safe (cl-find-if (lambda (part) (eq (car part) n)) parts))
|
||||||
(mu4e-error "MIME-part %s not found" n)))
|
(mu4e-error "MIME-part %s not found" n)))
|
||||||
(action (or (and options (mu4e-read-option "Action on mime-part: " options))
|
(action (or (and options (mu4e-read-option "Action on MIME-part: " options))
|
||||||
(mu4e-error "No such action")))
|
(mu4e-error "No such action")))
|
||||||
(handler (or (plist-get action :handler)
|
(handler (or (plist-get action :handler)
|
||||||
(mu4e-error "No :handler found for action %S" action)))
|
(mu4e-error "No :handler item found for action %S" action)))
|
||||||
(receives (or (plist-get action :receives)
|
(receives (or (plist-get action :receives)
|
||||||
(mu4e-error "No :receives found for action %S" action))))
|
(mu4e-error "No :receives item found for action %S" action))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(cond
|
(cond
|
||||||
((functionp handler)
|
((functionp handler)
|
||||||
|
@ -644,4 +640,4 @@ I.e., '3 A o' opens the third MIME-part."
|
||||||
|
|
||||||
|
|
||||||
(provide 'mu4e-view-gnus)
|
(provide 'mu4e-view-gnus)
|
||||||
;;; mu4e-view.el ends here
|
;;; mu4e-view-gnus.el ends here
|
||||||
|
|
Loading…
Reference in New Issue