mu4e-view: support icons for message view
Support showing the icons in the message view as well. (see previous commit)
This commit is contained in:
8
NEWS.org
8
NEWS.org
@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
- ~mu4e-compose-post-hook~ only runs once per message (buffer) (1.14.1)
|
- ~mu4e-compose-post-hook~ only runs once per message (buffer) (1.14.1)
|
||||||
|
|
||||||
- You can get icons for MIME-types when using ~mu4e-view-mime-part-action~, by
|
- You can get icons for MIME-types in the message-view and when using
|
||||||
configuring ~mu4e-file-name-to-icon-function~ (see docstring). E.g. when you
|
~mu4e-view-mime-part-action~, by configuring ~mu4e-file-name-to-icon-function~
|
||||||
have the "Nerd Icons" package, you can set this to
|
(see docstring). E.g. when you have the "Nerd Icons" package, you can set
|
||||||
~nerd-icons-icon-for-file~. (1.14.1)
|
this to ~nerd-icons-icon-for-file~. (1.14.1)
|
||||||
|
|
||||||
*** scm
|
*** scm
|
||||||
|
|
||||||
|
|||||||
@ -579,6 +579,7 @@ activates URLs (in plain-text mode only)."
|
|||||||
(charset (and charset (intern charset)))
|
(charset (and charset (intern charset)))
|
||||||
(mu4e--view-rendering t) ;; needed if e.g. an ics file is buttonized
|
(mu4e--view-rendering t) ;; needed if e.g. an ics file is buttonized
|
||||||
(gnus-article-emulate-mime nil) ;; avoid perf problems
|
(gnus-article-emulate-mime nil) ;; avoid perf problems
|
||||||
|
(gnus-mime-button-line-format "%{%([%p. %n]%)%}%e\n")
|
||||||
(gnus-newsgroup-charset
|
(gnus-newsgroup-charset
|
||||||
(if (and charset (coding-system-p charset)) charset
|
(if (and charset (coding-system-p charset)) charset
|
||||||
(detect-coding-region (point-min) (point-max) t)))
|
(detect-coding-region (point-min) (point-max) t)))
|
||||||
@ -601,6 +602,7 @@ activates URLs (in plain-text mode only)."
|
|||||||
;; just continue if some of the decoding fails.
|
;; just continue if some of the decoding fails.
|
||||||
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
||||||
(gnus-article-prepare-display)
|
(gnus-article-prepare-display)
|
||||||
|
(mu4e--view-add-mime-icons)
|
||||||
;; Only activate URLs in plain-text mode; in HTML mode
|
;; Only activate URLs in plain-text mode; in HTML mode
|
||||||
;; the renderer already provides its own clickable links
|
;; the renderer already provides its own clickable links
|
||||||
;; (#2094).
|
;; (#2094).
|
||||||
@ -703,6 +705,30 @@ render. After inserting, highlight the headers."
|
|||||||
gnus-article-highlight-headers))))
|
gnus-article-highlight-headers))))
|
||||||
(gnus-treat-article 'head)))
|
(gnus-treat-article 'head)))
|
||||||
|
|
||||||
|
(defun mu4e--view-add-mime-icons ()
|
||||||
|
"Add file icons before MIME attachment buttons.
|
||||||
|
Scan the buffer for Gnus MIME buttons (via the `gnus-data' text
|
||||||
|
property) and insert an icon before each one, based on the
|
||||||
|
filename."
|
||||||
|
(save-excursion
|
||||||
|
(let ((pos (point-min))
|
||||||
|
(positions nil)
|
||||||
|
(inhibit-read-only t))
|
||||||
|
;; Collect button start positions (forward scan).
|
||||||
|
(while (setq pos (next-single-property-change pos 'gnus-data))
|
||||||
|
(when (get-text-property pos 'gnus-data)
|
||||||
|
(push pos positions)) ;; naturally in reverse order
|
||||||
|
(setq pos (or (next-single-property-change pos 'gnus-data)
|
||||||
|
(point-max))))
|
||||||
|
;; Insert icons in reverse order so positions stay valid.
|
||||||
|
(dolist (p positions)
|
||||||
|
(when-let* ((handle (get-text-property p 'gnus-data))
|
||||||
|
((listp handle))
|
||||||
|
(name (mm-handle-filename handle))
|
||||||
|
(icon (mu4e-file-name-to-icon name)))
|
||||||
|
(goto-char p)
|
||||||
|
(insert icon " "))))))
|
||||||
|
|
||||||
(defun mu4e--view-gnus-display-mime (msg)
|
(defun mu4e--view-gnus-display-mime (msg)
|
||||||
"Like `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)
|
||||||
|
|||||||
Reference in New Issue
Block a user