[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: prettify-symbols-mode to handle "\alpha-\beta" ...
From: |
Christopher Dimech |
Subject: |
Re: prettify-symbols-mode to handle "\alpha-\beta" ... |
Date: |
Thu, 4 Feb 2021 05:21:14 +0100 |
We should find the best way to do this rather than a hack
that is likely to be rejected by emacs-devel. pretty-symbols
is a good candidate for this because it is intended for use
with general programming modes. Texinfo has today evolved
like a programming language with its support for plain-tex
and commands for mathjax.
Whilst texinfo.el takes care of texinfo commands, it completely
disregards the use of tex constructs and the focus on displaying
mathematical expressions within texinfo.
---------------------
Christopher Dimech
General Administrator - Naiad Informatics - GNU Project (Geocomputation)
- Geophysical Simulation
- Geological Subsurface Mapping
- Disaster Preparedness and Mitigation
- Natural Resource Exploration and Production
- Free Software Advocacy
> Sent: Thursday, February 04, 2021 at 4:04 PM
> From: "Stefan Monnier" <monnier@iro.umontreal.ca>
> To: "Óscar Fuentes" <ofv@wanadoo.es>
> Cc: emacs-devel@gnu.org
> Subject: Re: prettify-symbols-mode to handle "\alpha-\beta" ...
>
> > Supporting what you want would require either changing what texinfo
> > considers a symbol or changing prettify-symbols-mode to work on
> > something else instead of symbols.
>
> The second can be done without changing the code of
> `prettify-symbols-mode`: you want to change
> `prettify-symbols-compose-predicate` which contains the function that decides
> whether a given occurrence should be prettified or not.
>
> E.g. the default is the function `prettify-symbols-default-compose-p`
> defined as follows:
>
> (defun prettify-symbols-default-compose-p (start end _match)
> "Return true iff the symbol MATCH should be composed.
> The symbol starts at position START and ends at position END.
> This is the default for `prettify-symbols-compose-predicate'
> which is suitable for most programming languages such as C or Lisp."
> ;; Check that the chars should really be composed into a symbol.
> (let* ((syntaxes-beg (if (memq (char-syntax (char-after start)) '(?w
> ?_))
> '(?w ?_) '(?. ?\\)))
> (syntaxes-end (if (memq (char-syntax (char-before end)) '(?w ?_))
> '(?w ?_) '(?. ?\\))))
> (not (or (memq (char-syntax (or (char-before start) ?\s))
> syntaxes-beg)
> (memq (char-syntax (or (char-after end) ?\s)) syntaxes-end)
> (nth 8 (syntax-ppss))))))
>
> You'd presumably want to then define your own such function which does
> pretty much the same except that it doesn't accept the syntax `_`:
>
> (defun texinf-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)))))
>
>
> -- Stefan
>
>
>
- prettify-symbols-mode to handle "\alpha-\beta" ..., pietru, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Óscar Fuentes, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., pietru, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Óscar Fuentes, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., pietru, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Stefan Monnier, 2021/02/03
- Re: prettify-symbols-mode to handle "\alpha-\beta" ...,
Christopher Dimech <=
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Stefan Monnier, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Stefan Monnier, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Stefan Monnier, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Stefan Monnier, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., Christopher Dimech, 2021/02/04
- Re: prettify-symbols-mode to handle "\alpha-\beta" ..., pietru, 2021/02/05