Skip to content

Commit

Permalink
docs(indicators): add code comment for align logic
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
bdarcus committed Mar 24, 2023
1 parent 91a392f commit cd86ac2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions citar.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit cd86ac2

Please sign in to comment.