3

I'm trying to use compose-region with TABs but fail to see difference.

I'd like to get 'sqrt' composed to '√' but taking as much space as original text and aligned to the right.

I tried each of:

(compose-region begin end "√")
(compose-region begin end "\t√")
(compose-region begin end "√\t")
(compose-region begin end "\t√\t")

but fail to see any difference. Is there a way to compose region but keep its width?

Emacs is 24.4.

5

As far as I understand, compose-region and the underlying composition text property can only result in displaying a single glyph (which may be built from several parts). When you pass multiple glyphs, they are assembled together in a single cell. The TAB character says to enlarge the cell so that the composite glyph fits entirely. It doesn't result in enlarging or padding the glyph to fill the cell.

What you want can be done with the display property instead.

(put-text-property begin end 'display "   √")

You may want to put this property in an overlay (especially as modifying overlays doesn't mark the buffer content as modified, unlike direct manipulation of text properties).

| improve this answer | |
2

Better answer is in http://endlessparentheses.com/using-prettify-symbols-in-clojure-and-elisp-without-breaking-indentation.html

One way to fix the width, is to join two spaces together, and then stick the inequality on top of them.

(add-to-list 'endless/clojure-prettify-alist
             '(">=" . (?\s (Br . Bl) ?\s (Bc . Bc) ?≥)))
(add-to-list 'endless/clojure-prettify-alist
             '("<=" . (?\s (Br . Bl) ?\s (Bc . Bc) ?≤)))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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