feat(mu4e): show size in part/attachment picker
This commit is contained in:
parent
b05d8e8082
commit
b489ae6452
1 changed files with 11 additions and 6 deletions
|
@ -192,10 +192,10 @@ Acts like a singular `mu4e-view-save-attachments', without the saving."
|
|||
(dolist (part parts)
|
||||
(let ((fname (cdr (assoc 'filename (assoc "attachment" (cdr part))))))
|
||||
(when fname
|
||||
(push (cons (if (featurep 'all-the-icons)
|
||||
(concat (all-the-icons-icon-for-file fname)
|
||||
" " fname)
|
||||
fname)
|
||||
(push (cons (concat (format "%-2s " (car part))
|
||||
(when (featurep 'all-the-icons) (all-the-icons-icon-for-file fname))
|
||||
(format " %s " fname)
|
||||
(format "(%s)" (file-size-human-readable (with-current-buffer (cadr part) (buffer-size)))))
|
||||
part)
|
||||
files))))
|
||||
(if files
|
||||
|
@ -210,7 +210,8 @@ Acts like a singular `mu4e-view-save-attachments', without the saving."
|
|||
(mu4e~view-mime-part-to-temp-file (cdr (+mu4e-view-select-attachment)))))
|
||||
|
||||
(defun +mu4e-view-select-part ()
|
||||
(let ((parts (mu4e~view-gather-mime-parts)) partinfo labeledparts maxfnamelen fnamefmt)
|
||||
(let ((parts (mu4e~view-gather-mime-parts)) partinfo labeledparts
|
||||
maxfnamelen fnamefmt maxsizelen sizefmt)
|
||||
(dolist (part parts)
|
||||
(push (list :index (car part)
|
||||
:mimetype (if (string= "text/plain" (caaddr part))
|
||||
|
@ -220,16 +221,20 @@ Acts like a singular `mu4e-view-save-attachments', without the saving."
|
|||
(caaddr part))
|
||||
:type (car (nth 5 part))
|
||||
:filename (cdr (assoc 'filename (assoc "attachment" (cdr part))))
|
||||
:size (file-size-human-readable (with-current-buffer (cadr part) (buffer-size)))
|
||||
:part part)
|
||||
partinfo))
|
||||
(setq maxfnamelen (apply #'max 7 (mapcar (lambda (i) (length (plist-get i :filename))) partinfo))
|
||||
fnamefmt (format " %%-%ds " maxfnamelen))
|
||||
fnamefmt (format " %%-%ds " maxfnamelen)
|
||||
maxsizelen (apply #'max (mapcar (lambda (i) (length (plist-get i :size))) partinfo))
|
||||
sizefmt (format "%%-%ds " maxsizelen))
|
||||
(dolist (pinfo partinfo)
|
||||
(push (cons (concat (propertize (format "%-2s " (plist-get pinfo :index)) 'face '(bold font-lock-type-face))
|
||||
(when (featurep 'all-the-icons)
|
||||
(all-the-icons-icon-for-file (or (plist-get pinfo :filename) "")))
|
||||
(format fnamefmt (or (plist-get pinfo :filename)
|
||||
(propertize (plist-get pinfo :type) 'face '(italic font-lock-doc-face))))
|
||||
(format sizefmt (propertize (plist-get pinfo :size) 'face 'font-lock-builtin-face))
|
||||
(propertize (plist-get pinfo :mimetype) 'face 'font-lock-constant-face))
|
||||
(plist-get pinfo :part))
|
||||
labeledparts))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue