From d89054627c4ead0b35c09e895884d4cfca926e24 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 17 May 2026 10:57:53 +0300 Subject: [PATCH] Fix updates of embedded formulas by 'calc-embedded-update-formula' * lisp/calc/calc-embed.el (calc-embedded-update): Use 'buffer-substring' to better track the string representation of the formula when it is being edited. Suggested by gnu@publik.slmail.me. Also, update commentary. (Bug#80901) --- lisp/calc/calc-embed.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el index 7b3c5daaede..631efe9069b 100644 --- a/lisp/calc/calc-embed.el +++ b/lisp/calc/calc-embed.el @@ -103,7 +103,8 @@ ;; 3 Bottom of current formula (marker). ;; 4 Top of current formula's delimiters (marker). ;; 5 Bottom of current formula's delimiters (marker). -;; 6 String representation of current formula. +;; 6 String representation of current formula (actually, the +;; buffer-substring between positions given by 2 and 3 above. ;; 7 Non-nil if formula is embedded within a single line. ;; 8 Internal representation of current formula. ;; 9 Variable assigned by this formula, or nil. @@ -1140,7 +1141,8 @@ The command \\[yank] can retrieve it from there." (insert str) (set-marker (aref info 3) (+ (point) adjbot)) (set-marker (aref info 5) (+ (point) delta)) - (aset info 6 str)))))) + (aset info 6 (buffer-substring (aref info 2) + (aref info 3)))))))) (if (eq (car-safe val) 'calcFunc-evalto) (progn (setq evalled (nth 2 val)