* bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer
@ 2016-10-04 11:32 Tino Calancha
2019-06-25 0:00 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Tino Calancha @ 2016-10-04 11:32 UTC (permalink / raw)
To: 24612
It is very counter-intuitive how to modify things in the calc minibuffer.
Insertions and deletions are respect to the digit in the right hand side.
You can set the point before any digit, but <backspace> will always delete
the last one.
emacs -Q
M-x calc RET
9123
I) C-a C-d ; Delete 3 instead of 9, number:912
II) C-b C-b; Point is right after 9.
III) <backspace> ; Delete 2 instead of 9, number: 91
IV) C-a 8 ; Number: 918 instead of 891.
I find easier if the behaviour is as follows:
M-x calc RET
9123
I) C-a C-d ; number: 123
II) C-e C-b ; Point is right after 2.
III) <backspace> ; number: 13
IV) C-a 8 ; number: 813
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From fc4ac0c2a32ebb771583514dc6519539eaa9ac9b Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Tue, 4 Oct 2016 20:23:29 +0900
Subject: [PATCH] calc: insert/delete chars in calc minibuffer at point
* lisp/calc/calc.el (calcDigit-delchar): New command to delete chars
forward in the calc minibuffer.
(calc-digit-map): Bind calcDigit-delchar to '\C-d'.
(calcDigit-key): Do not go to (point-max) in calc minibuffer
before insert a digit (Bug#24612).
---
lisp/calc/calc.el | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index 7ae8fdf..c230ed9 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1120,8 +1120,26 @@ calc-digit-map
(append (where-is-internal 'delete-backward-char global-map)
(where-is-internal 'backward-delete-char global-map)
(where-is-internal 'backward-delete-char-untabify global-map)
- '("\C-d"))
- '("\177" "\C-d")))
+ '("\177"))
+ '("\177")))
+
+(mapc (lambda (x)
+ (ignore-errors
+ (define-key calc-digit-map x 'calcDigit-delchar)
+ (define-key calc-mode-map x 'calc-pop)
+ (define-key calc-mode-map
+ (if (and (vectorp x) (featurep 'xemacs))
+ (if (= (length x) 1)
+ (vector (if (consp (aref x 0))
+ (cons 'meta (aref x 0))
+ (list 'meta (aref x 0))))
+ "\e\C-d")
+ (vconcat "\e" x))
+ 'calc-pop-above)))
+ (if calc-scan-for-dels
+ (append (where-is-internal 'delete-forward-char global-map)
+ '("\C-d"))
+ '("\C-d")))
(defvar calc-dispatch-map
(let ((map (make-keymap)))
@@ -2383,7 +2401,6 @@ calc-minibuffer-contains
(defun calcDigit-key ()
(interactive)
- (goto-char (point-max))
(if (or (and (memq last-command-event '(?+ ?-))
(> (buffer-size) 0)
(/= (preceding-char) ?e))
@@ -2426,8 +2443,7 @@ calcDigit-key
(delete-char 1))
(if (looking-at "-")
(delete-char 1)
- (insert "-")))
- (goto-char (point-max)))
+ (insert "-"))))
((eq last-command-event ?p)
(if (or (calc-minibuffer-contains ".*\\+/-.*")
(calc-minibuffer-contains ".*mod.*")
@@ -2480,17 +2496,9 @@ calcDigit-key
(setq calc-prev-prev-char calc-prev-char
calc-prev-char last-command-event))
-
(defun calcDigit-backspace ()
(interactive)
- (goto-char (point-max))
- (cond ((calc-minibuffer-contains ".* \\+/- \\'")
- (backward-delete-char 5))
- ((calc-minibuffer-contains ".* mod \\'")
- (backward-delete-char 5))
- ((calc-minibuffer-contains ".* \\'")
- (backward-delete-char 2))
- ((eq last-command 'calcDigit-start)
+ (cond ((eq last-command 'calcDigit-start)
(erase-buffer))
(t (backward-delete-char 1)))
(if (= (calc-minibuffer-size) 0)
@@ -2499,6 +2507,20 @@ calcDigit-backspace
(calcDigit-nondigit))))
+(defun calcDigit-delchar ()
+ (interactive)
+ (cond ((looking-at-p " \\+/- \\'")
+ (delete-char 5))
+ ((looking-at-p " mod \\'")
+ (delete-char 5))
+ ((looking-at-p " \\'")
+ (delete-char 2))
+ ((eq last-command 'calcDigit-start)
+ (erase-buffer))
+ (t (unless (eobp) (delete-char 1))))
+ (when (= (calc-minibuffer-size) 0)
+ (setq last-command-event 13)
+ (calcDigit-nondigit)))
(defconst math-bignum-digit-length
--
2.9.3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.4 (x86_64-pc-linux-gnu, GTK+ Version 3.22.0)
of 2016-10-04 built on calancha-pc
Repository revision: e2913dc880b9843bf69cf885270551bafeb46120
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer
2016-10-04 11:32 bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer Tino Calancha
@ 2019-06-25 0:00 ` Lars Ingebrigtsen
2020-08-11 13:42 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-25 0:00 UTC (permalink / raw)
To: Tino Calancha; +Cc: 24612
Tino Calancha <tino.calancha@gmail.com> writes:
> It is very counter-intuitive how to modify things in the calc minibuffer.
> Insertions and deletions are respect to the digit in the right hand side.
> You can set the point before any digit, but <backspace> will always delete
> the last one.
>
> emacs -Q
>
> M-x calc RET
> 9123
> I) C-a C-d ; Delete 3 instead of 9, number:912
> II) C-b C-b; Point is right after 9.
> III) <backspace> ; Delete 2 instead of 9, number: 91
> IV) C-a 8 ; Number: 918 instead of 891.
Yes, that's supremely confusing. I don't think anything else in Emacs
works this way?
> I find easier if the behaviour is as follows:
> M-x calc RET
> 9123
> I) C-a C-d ; number: 123
> II) C-e C-b ; Point is right after 2.
> III) <backspace> ; number: 13
> IV) C-a 8 ; number: 813
I think I) here sounds a bit unusual, too. Wouldn't it be better if
that just gave an error as normal?
But, anyway, I'm guessing this behavior is on purpose. I'm not a calc
user, but is there anybody here who are? And are attached to the
current way this works?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer
2019-06-25 0:00 ` Lars Ingebrigtsen
@ 2020-08-11 13:42 ` Lars Ingebrigtsen
0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-11 13:42 UTC (permalink / raw)
To: Tino Calancha; +Cc: 24612
Lars Ingebrigtsen <larsi@gnus.org> writes:
>> emacs -Q
>>
>> M-x calc RET
>> 9123
>> I) C-a C-d ; Delete 3 instead of 9, number:912
>> II) C-b C-b; Point is right after 9.
>> III) <backspace> ; Delete 2 instead of 9, number: 91
>> IV) C-a 8 ; Number: 918 instead of 891.
[...]
> But, anyway, I'm guessing this behavior is on purpose. I'm not a calc
> user, but is there anybody here who are? And are attached to the
> current way this works?
I went ahead and applied the patch to Emacs 28, but if there's any
complaints, I guess we should revert it. The new behaviour sounds a lot
less confusing than the old one, though, but I'm not a regular Calc
user.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-11 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-04 11:32 bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer Tino Calancha
2019-06-25 0:00 ` Lars Ingebrigtsen
2020-08-11 13:42 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.