branch: externals/marginalia commit 6d48ed54be87969e3ce53a24dbc63ec72ec6a91a Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add more help-echo, in particular for truncated annotations --- marginalia.el | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/marginalia.el b/marginalia.el index 54bfede186..67763b9795 100644 --- a/marginalia.el +++ b/marginalia.el @@ -363,10 +363,14 @@ for performance profiling of the annotators.") (get-text-property (1- (length str)) 'face str))) (ell (if face (propertize (marginalia--ellipsis) 'face face) - (marginalia--ellipsis)))) - (if (< width 0) - (nreverse (truncate-string-to-width (reverse str) (- width) 0 ?\s ell)) - (truncate-string-to-width str width 0 ?\s ell)))) + (marginalia--ellipsis))) + (trunc + (if (< width 0) + (nreverse (truncate-string-to-width (reverse str) (- width) 0 ?\s ell)) + (truncate-string-to-width str width 0 ?\s ell)))) + (unless (string-prefix-p str trunc) + (put-text-property 0 (length trunc) 'help-echo str trunc)) + trunc)) (cl-defmacro marginalia--field (field &key truncate face width format) "Format FIELD as a string according to some options. @@ -514,7 +518,7 @@ t cl-type" (and (get s 'cl--class) '("t" . "cl-type")))))) ;; cl-find-class, cl--find-class (setq class (delq nil class)) (propertize - (format "%-6s" (mapconcat #'car class "")) + (format " %-6s" (mapconcat #'car class "")) 'help-echo (mapconcat (pcase-lambda (`(,x . ,y)) (concat x " " y)) class "\n")))) @@ -881,14 +885,12 @@ component of a full file path." ;; File owner at the left ((marginalia--file-owner attrs) :face 'marginalia-file-owner) ((marginalia--file-modes attrs)) - ((file-size-human-readable (file-attribute-size attrs)) - :face 'marginalia-size :width -7) + ((marginalia--file-size attrs) :face 'marginalia-size :width -7) ((marginalia--time (file-attribute-modification-time attrs)) :face 'marginalia-date :width -12)) (marginalia--fields ((marginalia--file-modes attrs)) - ((file-size-human-readable (file-attribute-size attrs)) - :face 'marginalia-size :width -7) + ((marginalia--file-size attrs) :face 'marginalia-size :width -7) ((marginalia--time (file-attribute-modification-time attrs)) :face 'marginalia-date :width -12) ;; File owner at the right @@ -913,6 +915,11 @@ These annotations are skipped for remote paths." (or (user-login-name uid) uid) (or (group-name gid) gid))))) +(defun marginalia--file-size (attrs) + "Return formatted file size given ATTRS." + (propertize (file-size-human-readable (file-attribute-size attrs)) + 'help-echo (number-to-string (file-attribute-size attrs)))) + (defun marginalia--file-modes (attrs) "Return fontified file modes given the ATTRS." ;; Without caching this can a be significant portion of the time @@ -967,9 +974,11 @@ These annotations are skipped for remote paths." (defun marginalia--time (time) "Format file age TIME, suitably for use in annotations." - (if (< (float-time (time-since time)) marginalia-max-relative-age) - (marginalia--time-relative time) - (marginalia--time-absolute time))) + (propertize + (if (< (float-time (time-since time)) marginalia-max-relative-age) + (marginalia--time-relative time) + (marginalia--time-absolute time)) + 'help-echo (format-time-string "%Y-%m-%d %T" time))) (defvar-local marginalia--project-root 'unset) (defun marginalia--project-root ()