4

Is there a way to prettify symbols without running into alignment issues? E.g. replacing not with ¬is visually pleasing, but screws up code alignment, b/c not is 3 chars while ¬ is one char.

Since prettifying symbols only changes the way text is displayed, not how it's actually stored, it doesn't make sense for operations like text alignment to use the prettified instead of underlying representations.

Drew
  • 75,699
  • 9
  • 109
  • 225
Tianxiang Xiong
  • 3,848
  • 16
  • 27
  • 2
    Agreed; I consider the feature unusable on account of this issue. – phils May 02 '17 at 23:32
  • 2
    http://endlessparentheses.com/using-prettify-symbols-in-clojure-and-elisp-without-breaking-indentation.html is about padding the 'pretty' symbol so that it's *actually* the same width as the text it's replacing, which works around the alignment issue (at the cost of not being quite as pretty). I can see that being acceptable for very short text, but not for something like the word "lambda", so YMMV. – phils May 02 '17 at 23:37
  • 1
    `lambda` is OK b/c you don't align with the end of the word, but with the second character, so it works out. That's not the case with `not`, etc. – Tianxiang Xiong May 03 '17 at 00:34
  • Good point; it would be an abnormal formatting of a lambda form for it to trigger an issue (e.g. a "one liner" where the body actually ended up being split over a second line). Not a typical scenario at all. – phils May 03 '17 at 01:04
  • `(push '("not" . (?\s (Bc . Bl) ?¬ (Br . Bc) ?\s (Bl . Br) ?\s)) prettify-symbols-alist)` is one way to make `not` align. You can fiddle around with the spaces etc. as in http://endlessparentheses.com/using-prettify-symbols-in-clojure-and-elisp-without-breaking-indentation.html to make it the way you want it. Although, I'd consider it a much nicer solution to have a wider symbol, but I don't think you can do that within prettify-symbols, you'll probably have to mess with `set-fontset-font` for that. – unhammer Jul 05 '17 at 11:12

0 Answers0