0

How to insert and right-align text that is not of the default font size?

This doesn't work:

(let* ((text "abcd")
       (len (length text)))
  (insert
   "\n"
   (propertize " " 'display `((height 0.5) (space :align-to (- right (,len . width)))))
   (propertize "12345" 'font-lock-face 'error 'display '(height 0.5))
  "\n"))
3
  • It doesn't line up on the right side. It's outside the visible space.
    – jo-so
    Jan 13, 2021 at 13:55
  • Have you tried to run the code in the scratch buffer? Is 12345 on the right side of the screen at you?
    – jo-so
    Jan 13, 2021 at 17:38
  • If you don't take all information I put into the question, how can you rate, if there's something missing? Might the part you are ignoring be the missing piece?
    – jo-so
    Jan 13, 2021 at 21:47

1 Answer 1

1

The example in the question works fine. There's a bug in Emacs 27.1 that makes it fail. See the discussion on the mailing list: Why is (1 . width) zero?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.