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

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

bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecess


From: Eli Zaretskii
Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily
Date: Fri, 01 Dec 2023 20:12:46 +0200

> From: Raffael Stocker <r.stocker@mnet-mail.de>
> Cc: 67536@debbugs.gnu.org
> Date: Fri, 01 Dec 2023 18:34:10 +0100
> 
> I cleaned it up a bit and ran a few tests against the original function
> using an empty string, a string without anything to replace and a string
> requiring many replacements.  It seems to behave just as the original.

Thanks.

> I use cl-flet and (eval-when-compile (require 'cl-lib)).  I hope that is
> ok.

I'd prefer a simple internal function, or a lambda.

> +  (with-temp-buffer
> +    (cl-flet ((replace-all (regexp replacement)
> +                (goto-char 0)
> +                (while (re-search-forward regexp nil t)
> +                  (replace-match replacement))))
> +      (insert str)
> +      (replace-all (concat "[" math-read-superscripts "]+") "^(\\&)")
> +      (replace-all (concat "[" math-read-subscripts "]+") "_(\\&)")
> +      (dolist (rep-elem math-read-replacement-list)
> +        (replace-all (car rep-elem) (cadr rep-elem)))
> +      (buffer-string))))

I think buffer-substring-no-properties would be better than
buffer-string, as we don't need to copy any text properties, right?





reply via email to

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