all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#67395: Fix "Text is read-only" on backspacing initial calc input
@ 2023-11-23  2:02 George Kuzler
  2023-11-23 15:42 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: George Kuzler @ 2023-11-23  2:02 UTC (permalink / raw)
  To: 67395


[-- Attachment #1.1: Type: text/plain, Size: 2970 bytes --]

This is a one-line fix for a minor issue in calc-mode. When your last
command has caused the minibuffer to open for input - for example,
you've typed a digit - and you immediately press backspace, it should
clear the minibuffer and return you to *Calculator*. Instead, the
minibuffer is unchanged, and emacs prints the message "Text is
read-only". Note that you can then backspace again to delete the
minibuffer contents as normal; this bug only manifests if you try to
backspace right after the command that puts you in the minibuffer.

The issue is that `calcDigit-backspace' tries to clear the minibuffer with
`erase-buffer', which also tries to delete the prompt, which is
read-only. `delete-minibuffer-contents' would have the desired effect
since it doesn't try to delete the prompt. This change just replaces the
former function with the latter.



In GNU Emacs 29.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-09-24 built on
 e1d0f5fdfea948b9bb25e212c9c623e4
Windowing system distributor 'The X.Org Foundation', version 11.0.12302002
System Description: Fedora Linux 39 (Workstation Edition)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xpm --with-x-toolkit=gtk3 --with-gpm=no
 --with-xwidgets --with-modules --with-harfbuzz --with-cairo --with-json
 --with-native-compilation=aot --with-tree-sitter --with-sqlite3
 --with-webp --with-xinput2 build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
 -pipe -Wall -Werror=format-security
 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++
 'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g
 -grecord-gcc-switches -pipe -Wall -Werror=format-security
 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ''

[-- Attachment #1.2: Type: text/html, Size: 3292 bytes --]

[-- Attachment #2: calc-mode-backspace-fix.patch --]
[-- Type: text/x-patch, Size: 1280 bytes --]

From: George Kuzler <gkuzler@gmail.com>
Date: Wed, 22 Nov 2023 19:45:55 -0500
Subject: Fix "Text is read-only" on backspacing initial calc input

Immediately after calc-mode opens the minibuffer for input (because you typed a
digit, "e", etc), pressing backspace should clear the minibuffer and return you
to the *Calculator* buffer. Instead, it leaves the minibuffer as-is and prints
the message "Text is read-only"; this is because the function used,
`erase-buffer', tries to erase the read-only minibuffer prompt. Using
`delete-minibuffer-contents' fixes this, since it doesn't attempt to delete the
prompt.

* lisp/calc/calc.el (calcDigit-backspace): Use `delete-minibuffer-contents'
instead of `erase-buffer'.
---
 lisp/calc/calc.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index b347cc1da23..41aeb17c252 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -2491,7 +2491,7 @@ the United States."
 (defun calcDigit-backspace ()
   (interactive)
   (cond ((eq last-command 'calcDigit-start)
-	 (erase-buffer))
+	 (delete-minibuffer-contents))
 	(t (with-suppressed-warnings ((interactive-only backward-delete-char))
              (backward-delete-char 1))))
   (if (= (calc-minibuffer-size) 0)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#67395: Fix "Text is read-only" on backspacing initial calc input
  2023-11-23  2:02 bug#67395: Fix "Text is read-only" on backspacing initial calc input George Kuzler
@ 2023-11-23 15:42 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-11-23 15:42 UTC (permalink / raw)
  To: George Kuzler; +Cc: 67395-done

> From: George Kuzler <gkuzler@gmail.com>
> Date: Wed, 22 Nov 2023 21:02:31 -0500
> 
> This is a one-line fix for a minor issue in calc-mode. When your last
> command has caused the minibuffer to open for input - for example,
> you've typed a digit - and you immediately press backspace, it should
> clear the minibuffer and return you to *Calculator*. Instead, the
> minibuffer is unchanged, and emacs prints the message "Text is
> read-only". Note that you can then backspace again to delete the
> minibuffer contents as normal; this bug only manifests if you try to
> backspace right after the command that puts you in the minibuffer.
> 
> The issue is that `calcDigit-backspace' tries to clear the minibuffer with
> `erase-buffer', which also tries to delete the prompt, which is
> read-only. `delete-minibuffer-contents' would have the desired effect
> since it doesn't try to delete the prompt. This change just replaces the
> former function with the latter.

Thanks, I installed this on the emacs-29 branch, and I'm closing the
bug.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-23 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-23  2:02 bug#67395: Fix "Text is read-only" on backspacing initial calc input George Kuzler
2023-11-23 15:42 ` Eli Zaretskii

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.