[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] more symbols in pretty

From: Tassilo Horn
Subject: Re: [AUCTeX-devel] more symbols in pretty
Date: Thu, 22 Oct 2015 11:05:12 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Uwe Brauer <address@hidden> writes:

>> To decide if something is to be prettified, there's
>> `prettify-symbols-compose-predicate' which is
>> `TeX--prettify-symbols-compose-p' in AUCTeX.  Basically, that looks
>> at the char after the found symbol to decide if it is to be
>> prettified.
>> Examples:
>>   \alpha     ;; prettified
>>   \alphafoo  ;; not prettified cause foo is still part of the symbol
>>   \alpha2    ;; prettified because a number is not part of a macro
>>   \|U        ;; not prettified because the U could be part of the macro
> I see. I find the idea that
>>   \|U        ;; not prettified because the U could be part of the macro
> Could be a macro a bit odd, I would expect
> \|#1
> to be a macro, but I will not argue about it.

Well, it's all just heuristics.  Basically, AUCTeX
`TeX--prettify-symbols-compose-p' just asserts that
`tex--prettify-symbols-compose-p' returns non-nil and we're not in a
verbatim block.  But it's all just heuristics which generally assumes
that the prettified symbols have the form "\\\\[[:word:]]+".

You could try this definition:

--8<---------------cut here---------------start------------->8---
(defun tex--prettify-symbols-compose-p (_start end _match)
  (or (not (eq ?w (char-syntax (char-before end))))
      (let* ((after-char (char-after end))
             (after-syntax (char-syntax after-char)))
        (not (or
              ;; Don't compose address@hidden
              (eq after-char ?@)
              ;; The \alpha in \alpha2 or \alpha-\beta may be composed but
              ;; of course \alphax may not.
              (and (eq after-syntax ?w)
                   (not (memq after-char
                              '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?+ ?- ?' ?\"))))
              ;; Don't compose inside verbatim blocks.
              (eq 2 (nth 7 (syntax-ppss))))))))
--8<---------------cut here---------------end--------------->8---

But I'm not sure if that has wicked side-effects.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]