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)
This commit is contained in:
Eli Zaretskii 2026-05-17 10:57:53 +03:00
parent 1832a93547
commit d89054627c

View file

@ -103,7 +103,8 @@
;; 3 Bottom of current formula (marker). ;; 3 Bottom of current formula (marker).
;; 4 Top of current formula's delimiters (marker). ;; 4 Top of current formula's delimiters (marker).
;; 5 Bottom 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. ;; 7 Non-nil if formula is embedded within a single line.
;; 8 Internal representation of current formula. ;; 8 Internal representation of current formula.
;; 9 Variable assigned by this formula, or nil. ;; 9 Variable assigned by this formula, or nil.
@ -1140,7 +1141,8 @@ The command \\[yank] can retrieve it from there."
(insert str) (insert str)
(set-marker (aref info 3) (+ (point) adjbot)) (set-marker (aref info 3) (+ (point) adjbot))
(set-marker (aref info 5) (+ (point) delta)) (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) (if (eq (car-safe val) 'calcFunc-evalto)
(progn (progn
(setq evalled (nth 2 val) (setq evalled (nth 2 val)