GNU bug report logs - #67536
29.1; Calc mode's math-read-preprocess-string conses unnecessarily

Previous Next

Package: emacs;

Reported by: Raffael Stocker <r.stocker <at> mnet-mail.de>

Date: Wed, 29 Nov 2023 21:32:02 UTC

Severity: normal

Found in version 29.1

Done: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 67536 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Raffael Stocker <r.stocker <at> mnet-mail.de>
Cc: 67536 <at> debbugs.gnu.org
Subject: Re: 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 <at> mnet-mail.de>
> Cc: 67536 <at> 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?




This bug report was last modified 1 year and 155 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.