--- a/.emacs-my Mon Feb 22 11:32:37 2021 +0200
+++ b/.emacs-my Wed Apr 07 22:48:39 2021 +0300
@@ -1652,10 +1652,13 @@
(insert result)))))
(defun my-calc-line (arg)
- "Evaluate expression in current line and display the result in
-the echo area by skipping final '=' sign. With prefix ARG
-non-nil, insert the result at the end of line and space if
-necessary for delimiting."
+ "Evaluate calc expression in current line and display the
+result in the echo area by skipping everything after the final
+'=' sign.
+
+With prefix ARG non-nil or repeating command interactively,
+insert the result at the end of line + add a space if necessary
+for delimiting clearing everything after '=' sign if it is here."
(interactive "P")
(require 'calc)
(save-excursion
@@ -1667,9 +1670,13 @@
(setq end (point))
(setq expr (buffer-substring-no-properties beg end))
(setq result (calc-eval expr))
- (if (null arg)
+ (if (and (null arg) (not (eq 'my-calc-line last-command)))
(message "%s = %s" expr result)
(end-of-line)
+ (setq end (point))
+ (when (search-backward "=" beg t)
+ (forward-char 1)
+ (delete-region (point) end))
(unless (eq (char-before) ?\ )
(insert ?\ ))
(insert result)))))