From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 67536@debbugs.gnu.org, monnier@iro.umontreal.ca,
Raffael Stocker <r.stocker@mnet-mail.de>
Subject: bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily
Date: Mon, 18 Dec 2023 11:55:10 +0100 [thread overview]
Message-ID: <11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com> (raw)
In-Reply-To: <83y1dumqnu.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 702 bytes --]
16 dec. 2023 kl. 10.40 skrev Eli Zaretskii <eliz@gnu.org>:
> Mattias, is this okay with you? Should I install these patches?
So very sorry for the hiatus. I've been a bit poorly and getting back will take some time.
Raffael, thank you for your dogged measurements. Of course my clumsy code didn't preserve the possibility for `math-read-replacement-list` to translate strings longer than a single character but that's what I get for sending off-cuff patches that way.
Here's another off-cuff patch that might work better (demonstrating that I've learned nothing).
Again it's most likely that no user ever changes `math-read-replacement-list\x1e` and the code could be simplified a lot.
[-- Attachment #2: calc-aent.diff --]
[-- Type: application/octet-stream, Size: 1652 bytes --]
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el
index 131f31afff7..ae04a850f5d 100644
--- a/lisp/calc/calc-aent.el
+++ b/lisp/calc/calc-aent.el
@@ -562,8 +562,8 @@ math-read-preprocess-string
;; Cache invalid, recompute.
(setq math--read-preprocess-re-cache
(list (rx-to-string
- `(or (group (+ (in ,math-read-superscripts)))
- (group (+ (in ,math-read-subscripts)))
+ `(or (or (+ (in ,math-read-superscripts))
+ (group (+ (in ,math-read-subscripts))))
(group (or ,@(mapcar #'car math-read-replacement-list))))
t)
math-read-replacement-list
@@ -572,13 +572,15 @@ math-read-preprocess-string
(replace-regexp-in-string
(nth 0 math--read-preprocess-re-cache)
(lambda (s)
- (let ((r (mapconcat (lambda (c)
- (cadr (assoc (char-to-string c)
- math-read-replacement-list)))
- s)))
- (cond ((match-beginning 1) (concat "^(" r ")"))
- ((match-beginning 2) (concat "_(" r ")"))
- (t r))))
+ (if (match-beginning 2)
+ (cadr (assoc s math-read-replacement-list))
+ (concat (if (match-beginning 1) "_" "^")
+ "("
+ (mapconcat (lambda (c)
+ (cadr (assoc (char-to-string c)
+ math-read-replacement-list)))
+ s)
+ ")")))
str t))
;; The next few variables are local to math-read-exprs (and math-read-expr
next prev parent reply other threads:[~2023-12-18 10:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 21:29 bug#67536: 29.1; Calc mode's math-read-preprocess-string conses unnecessarily Raffael Stocker
2023-11-30 7:00 ` Eli Zaretskii
2023-11-30 18:28 ` Raffael Stocker
2023-11-30 19:14 ` Eli Zaretskii
2023-12-01 17:34 ` Raffael Stocker
2023-12-01 18:12 ` Eli Zaretskii
2023-12-01 21:10 ` Raffael Stocker
2023-12-02 8:03 ` Eli Zaretskii
2023-12-02 14:56 ` Mattias Engdegård
2023-12-02 19:26 ` Raffael Stocker
2023-12-03 10:43 ` Mattias Engdegård
2023-12-03 11:13 ` Raffael Stocker
2023-12-03 11:58 ` Mattias Engdegård
2023-12-05 18:14 ` Raffael Stocker
2023-12-16 9:40 ` Eli Zaretskii
2023-12-18 10:55 ` Mattias Engdegård [this message]
2023-12-18 11:39 ` Raffael Stocker
2023-12-19 16:16 ` Mattias Engdegård
2023-12-19 17:09 ` Raffael Stocker
2023-12-19 18:15 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11C36862-05F6-47B2-AFEB-D51B969EAAA5@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=67536@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=r.stocker@mnet-mail.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).