From cd86ac2869f4d1822dd8a6167e34673f6dfa3fa8 Mon Sep 17 00:00:00 2001 From: Bruce D'Arcus Date: Fri, 24 Mar 2023 11:46:20 -0400 Subject: [PATCH] docs(indicators): add code comment for align logic `citar--make-indicator-symbols` is the key function for indicator formatting and alignment; this adds an explanation in the code for future reference. See: #764 --- citar.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/citar.el b/citar.el index d7a31d1a..674d8d00 100644 --- a/citar.el +++ b/citar.el @@ -887,6 +887,15 @@ visible in the completion UI." (if matchtagp sym emptysym) padding)) (pos (length str))) + ;; See https://github.com/emacs-citar/citar/issues/764 for explanation of what this code is doing. + ;; + ;; We say that the last character of the padding should be replaced by a space which stretches to the + ;; position we want to. + ;; + ;; So for example if the icon has string width 1 but occupies 0.9 the space will stretch to occupy 1.1 + ;; and if the icon occupies 1.5 it will shrink to occupy 0.5. + ;; + ;; Emacs 29 has `vtable', which we might use here in the future as well. (put-text-property (- pos 1) pos 'display (cons 'space (list :align-to (string-width str)))