diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2026-04-13 22:18:16 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2026-04-13 22:18:16 +0300 |
| commit | 7cd51eec44128bbbf46dfa90e32b5f128674a67f (patch) | |
| tree | 9712546dd000d27f2d77185d8e533755a1888ff6 | |
| parent | 6455c498e6143bcfdbd53c880e26b6ca60acf98a (diff) | |
mu4e: mu4e-mime-parts: small cleanups
Small refactorings in mu4e--part-affixation, factoring out some shared
code.
| -rw-r--r-- | mu4e/mu4e-mime-parts.el | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/mu4e/mu4e-mime-parts.el b/mu4e/mu4e-mime-parts.el index e0daa4f..47c00b4 100644 --- a/mu4e/mu4e-mime-parts.el +++ b/mu4e/mu4e-mime-parts.el @@ -229,39 +229,30 @@ COMPLETIONS is the list of completion strings to affixate." 'face 'mu4e-system-face)) (target (propertize (or (plist-get part :target-dir) "") 'face 'mu4e-system-face)) - ;; Prefer the real filename: `nerd-icons' matches filenames - ;; against regexes, so a specific name like `foo.patch' picks - ;; a better icon than the dummy `file.patch' derived from the - ;; MIME type. Only fall back to the MIME type when there's - ;; no filename. (icon (or (and (> (length raw-filename) 0) (mu4e-file-name-to-icon raw-filename)) (mu4e-mime-type-to-icon (plist-get part :mime-type)))) (prefix (if icon (concat icon " ") "")) - (suffix + ;; For 'attachment the candidate itself is the filename; for + ;; 'mime-part the candidate is a numeric part-id, so prepend + ;; the filename here. Either way, pad to align the columns + ;; that follow. + (filename-col (pcase type ('attachment - (concat - (make-string (- (+ longest-filename 2) - (length (format "%s" candidate))) ?\s) - (format "%20s" mimetype) - " " - (format "%8s" size) - " " - (format "%s" (concat "-> " target)))) + (make-string (- (+ longest-filename 2) + (length (format "%s" candidate))) ?\s)) ('mime-part - (concat - " " - filename - (make-string (- (+ longest-filename 2) - (length filename)) ?\s) - (format "%20s" mimetype) - " " - (format "%8s" size) - " " - (format "%s" (concat "-> " target)))) - (_ (mu4e-error "Unsupported annotation type %s" type))))) + (concat " " filename + (make-string (- (+ longest-filename 2) + (length filename)) ?\s))) + (_ (mu4e-error "Unsupported annotation type %s" type)))) + (suffix + (concat filename-col + (format "%20s" mimetype) " " + (format "%8s" size) " " + "-> " target))) (list candidate prefix suffix))) completions)) |
