emacs-devel
[Top][All Lists]
Advanced

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

Re: prettify-symbols-mode to handle "\alpha-\beta" ...


From: Gregory Heytings
Subject: Re: prettify-symbols-mode to handle "\alpha-\beta" ...
Date: Fri, 05 Feb 2021 23:04:04 +0000


(defun texinfo-prettify-symbols-compose-p (start end _match)
   ;; We know the matches all start with a backslash and end with
   ;; a word-element.
   (not (or (memq (char-before start) '(?\\))
            (memq (char-syntax (or (char-after end) ?\s)) '(?w))
            (nth 8 (syntax-ppss)))))
(add-hook 'texinfo-mode-hook
           (lambda ()
             (push '("\\alpha" . ?α) prettify-symbols-alist)
             (push '("\\beta" . ?β) prettify-symbols-alist)
             (setq prettify-symbols-compose-predicate 
'texinfo-prettify-symbols-compose-p)
             (prettify-symbols-mode)))

That is not completely correct because for "\alpha-\beta", only \beta is prettified.

No, \alpha-\beta is prettified correctly. Tested with Emacs 25, 26, 27 and 28.

Have tried it in a texinfo document using

@tex
$\alpha -\beta \gamma \alpha - \beta \gamma \alpha, \alpha. \alpha- \alpha() 
\alpha[]$
@end tex


This works correctly with vanilla Emacs, with the "defun" and "add-hook" above.
reply via email to

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