Subject: Re: bug#49593: Emacs overrides normal-erase-is-backspace

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 16 Jul 2021 12:04:42 +0200

"Paul W. Rankin" <[email-masked]> writes:

> normal-erase-is-backspace is maybe; marked as "CHANGED outside of
> Customize"

The doc string does say:

Setting this variable with setq doesn't take effect.  Programmatically,
call `normal-erase-is-backspace-mode' (which see) instead.

But setting it with `custom-set-variables' should work, I'd have
thought?  Hm...

(custom-set-variables '(normal-erase-is-backspace t))

sets it to `maybe', so it's not a startup problem (there's been some
with Customize)...

Hm, looking at the code to `normal-erase-is-backspace-mode', I don't see
how that's supposed to work at all.  The value is only used in
`normal-erase-is-backspace-setup-frame', and calling
`normal-erase-is-backspace-mode' doesn't actually change the value of
the variable, which explains why `custom-set-variables' does nothing.

The following change seems to fix the issue:

diff --git a/lisp/simple.el b/lisp/simple.el
index 322693f631..01851e0a0a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9505,9 +9505,9 @@ normal-erase-is-backspace
   :set (lambda (symbol value)
 	 ;; The fboundp is because of a problem with :set when
 	 ;; dumping Emacs.  It doesn't really matter.
-	 (if (fboundp 'normal-erase-is-backspace-mode)
-	     (normal-erase-is-backspace-mode (or value 0))
-	   (set-default symbol value))))
+	 (when (fboundp 'normal-erase-is-backspace-mode)
+	   (normal-erase-is-backspace-mode (or value 0)))
+	 (set-default symbol value)))
 
 (defun normal-erase-is-backspace-setup-frame (&optional frame)
   "Set up `normal-erase-is-backspace-mode' on FRAME, if necessary."

But is that the correct fix?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no