help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Convert some Latex expressions in Emacs.


From: Michael Heerdegen
Subject: Re: Convert some Latex expressions in Emacs.
Date: Wed, 18 May 2022 01:45:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> I rechecked the description here [1], and still can't find any
> difference. Why do you say they are different?
>
> [1] https://www.emacswiki.org/emacs/peg.el

PEGs can match more "complicated" things than regexps can,
e.g. mathematical formulas.  Theory here:

 https://en.wikipedia.org/wiki/Parsing_expression_grammar

Unlike regexps, a PEG contains a set of named "rules" (as know from
formal grammars).  These are allowed to be recursive and interdependent.
This also allows to describe a "matcher" in a more structured and
better (human)readable way.

peg.el is implemented in Elisp and has some additional features like
executing Elisp code while matching is performed.

Still, when familiar with regexps, PEGs also look familiar, as you have
already noticed.

But I mentioned this only because I noticed your academical background,
and thought that somebody who likes GAP also might be interested in that
approach.  If you just want to get things done, DON'T look at PEGs, use
regexps (`query-replace-regexp', C-M-%) for now.

Should not be hard to do: removing stuff works by replacing with the
empty string.  You may want to know how to refer to the matched string
and how to use Lisp expressions to calculate parts of the replacement
string, that's explained here:

  (info "(emacs) Regexp Replace")

and the rest should be doable quite trivially.  Or do you have any
concrete questions or problems?  Or should we spell some things out?


Michael.




reply via email to

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