From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#24612: 26.0.50; calc: insertion/deletion of chars not at point in calc minibuffer Date: Tue, 4 Oct 2016 20:32:18 +0900 (JST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1475581099 20571 195.159.176.226 (4 Oct 2016 11:38:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Oct 2016 11:38:19 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) To: 24612@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 04 13:38:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brO31-0004S9-DZ for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Oct 2016 13:38:11 +0200 Original-Received: from localhost ([::1]:41638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brO2z-0005aI-PX for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Oct 2016 07:38:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brNy7-0001aP-97 for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:33:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brNy2-0000lp-BR for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:33:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brNy2-0000lf-7b for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1brNy2-00024V-3Z for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Oct 2016 11:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24612 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14755807597928 (code B ref -1); Tue, 04 Oct 2016 11:33:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Oct 2016 11:32:39 +0000 Original-Received: from localhost ([127.0.0.1]:43834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brNxf-00023o-8G for submit@debbugs.gnu.org; Tue, 04 Oct 2016 07:32:39 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52535) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brNxd-00023Z-OP for submit@debbugs.gnu.org; Tue, 04 Oct 2016 07:32:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brNxX-0000R6-9W for submit@debbugs.gnu.org; Tue, 04 Oct 2016 07:32:32 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:52216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brNxX-0000QS-5k for submit@debbugs.gnu.org; Tue, 04 Oct 2016 07:32:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brNxU-0001AV-6Q for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:32:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brNxO-0000Lp-OX for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:32:27 -0400 Original-Received: from mail-pa0-x243.google.com ([2607:f8b0:400e:c03::243]:35332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brNxO-0000LU-FF for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2016 07:32:22 -0400 Original-Received: by mail-pa0-x243.google.com with SMTP id t6so6281075pae.2 for ; Tue, 04 Oct 2016 04:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:subject:message-id:user-agent:mime-version; bh=3fviPeMtVb3E08cY/g+BwL1KE63nlqzVRl4nENev6jk=; b=m8WCU9jAzhRYJ3MMDxdURBzGQOzSqD5gAhDv4YJWvyynm/1Y+f7cDLx6cvPfZpkuYa hUuSukqk5SOhdfDUMeMX4Gyh6uZhZ/bDbuDezmiSy4wNzgTpE5p1aglLFvIuTwMeZMIE hmBv4kLntsxwvYolsz6fj+2y2Zl1htTriBYkid6SGvu4S49LfTCKCtCctpktGPJpxsvX 8MBFl9ZrblO83PcrqRbeHYfvrBgMy0rgg7wQrhTKcUD/WGA0KGAOG2v4CdRRuTQ8nxMU pLh5CEvVmqs4u6b4R3KXCz5WLguarxztA/Rm6CxnK+FKq0TKK2PX0aUbkhSmwkkw/FuL O6Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:subject:message-id:user-agent :mime-version; bh=3fviPeMtVb3E08cY/g+BwL1KE63nlqzVRl4nENev6jk=; b=IYmznJ9Uzor/CGF4XDfdh7HXgXoQpYzptyp+r/0f5iepLbFeHlxZJOsx4Rnvhuu9zz 4E682FjFgJtR5C1WRvt31iaQroV4REV0QrJ7KfaNLX17mlRiuFNn5uNqUvErzc2hkQW2 mc0vAymud7Y2jtKXe8JKZiMIGc5V5BEh07rZv3w63CRNq7/hU5Lel70dBEBkf2JCyxFT HARagF4OaWCGESi9HglFIj64HqnTvOHcq5ZVV6bdim4FPYsc74lzBSZbLMFcWAgHxT6C eyc5HbevL7DbV4aoVsGKCj1AnEF8DvLIbgsUSwzHsSkLEIoTzwtGGYX/kVXGuYS6sylI jGYQ== X-Gm-Message-State: AA6/9RlNNEDEfV97b8G+2tuCEO4AdVvNuWRAs2udtejUVzEdX5oUUtiq5h+YQzcQ4nNnsA== X-Received: by 10.66.88.40 with SMTP id bd8mr4269713pab.6.1475580741390; Tue, 04 Oct 2016 04:32:21 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id c21sm7402591pfc.79.2016.10.04.04.32.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Oct 2016 04:32:20 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:124031 Archived-At: 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 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) ; 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) ; number: 13 IV) C-a 8 ; number: 813 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From fc4ac0c2a32ebb771583514dc6519539eaa9ac9b Mon Sep 17 00:00:00 2001 From: Tino Calancha 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