From 8bfbc312ef7cb1f8f2cfd4ea8feda99af86e48a3 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 14 Jun 2022 11:14:02 +0200 Subject: [PATCH] Avoid recording passwords' chars * src/keyboard.c (syms_of_keyboard): un-obsolete `inhibit--record-char'. * lisp/subr.el (read-passwd): use `inhibit--record-char' to inhibit passwords recording. --- lisp/subr.el | 7 +------ src/keyboard.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 50ae357a13..29f9706c39 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1883,12 +1883,6 @@ 'inhibit-nul-byte-detection (make-obsolete-variable 'load-dangerous-libraries "no longer used." "27.1") -(defvar inhibit--record-char nil - "Obsolete variable. -This was used internally by quail.el and keyboard.c in Emacs 27. -It does nothing in Emacs 28.") -(make-obsolete-variable 'inhibit--record-char nil "28.1") - (define-obsolete-function-alias 'compare-window-configurations #'window-configuration-equal-p "29.1") @@ -3048,6 +3042,7 @@ read-passwd (use-local-map read-passwd-map) (setq-local inhibit-modification-hooks nil) ;bug#15501. (setq-local show-paren-mode nil) ;bug#16091. + (setq-local inhibit--record-char t) (add-hook 'post-command-hook #'read-password--hide-password nil t)) (unwind-protect (let ((enable-recursive-minibuffers t) diff --git a/src/keyboard.c b/src/keyboard.c index 55d710ed62..fbdc0e9107 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3307,6 +3307,10 @@ help_char_p (Lisp_Object c) static void record_char (Lisp_Object c) { + /* subr.el/read-passwd binds this to avoid recording passwords. */ + if (inhibit_record_char) + return; + int recorded = 0; if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement))) @@ -12992,6 +12996,14 @@ syms_of_keyboard (void) changed. */); Vdisplay_monitors_changed_functions = Qnil; + DEFVAR_BOOL ("inhibit--record-char", + inhibit_record_char, + doc: /* If non-nil, don't record input events. +This inhibits recording input events for the purposes of keyboard +macros, dribble file, and `recent-keys'. +Internal use only. */); + inhibit_record_char = false; + pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper); } -- 2.36.1