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: pietru
Subject: Re: prettify-symbols-mode to handle "\alpha-\beta" ...
Date: Fri, 5 Feb 2021 23:22:05 +0100


> Sent: Saturday, February 06, 2021 at 10:09 AM
> From: "Gregory Heytings" <gregory@heytings.org>
> To: pietru@caramail.com
> Cc: emacs-devel@gnu.org
> Subject: Re: prettify-symbols-mode to handle "\alpha-\beta" ...
>
> 
> >
> > Would allowing a regexp solve the expression \alpha-\beta, \alpha+\beta, 
> > \alpha/\beta, so that \alpha and \beta are prettified seperately?
> >
> 
> That's not necessary.  Just follow Stefan's advice:
> 
> (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)))
> 
> This does what you want.

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

However, \alpha, \alpha. \alpha() \alpha[] work well with \alpha being 
prettifyied
even though the next character is a comma, period and parenthesis.

To cater for prettifying tex, we could have another function where one can 
construct
the prettify.   






reply via email to

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