From a15d43e2cd80307e2597f7888a4920d73fa58362 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Wed, 8 Jun 2022 15:39:39 +0200 Subject: [PATCH] Avoid recording chars when reading passwords * lisp/subr.el (read-passwd): inhibit char recording when reading a password. * src/keyboard.c (syms_of_keyboard, read_char): introduce `do-not-record-char' to inhibit char recording. --- lisp/subr.el | 1 + src/keyboard.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 50ae357a13..1007237fb6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3048,6 +3048,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 do-not-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..a628c2d2df 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3046,10 +3046,13 @@ read_char (int commandflag, Lisp_Object map, /* Store these characters into recent_keys, the dribble file if any, and the keyboard macro being defined, if any. */ - record_char (c); - recorded = true; - if (! NILP (also_record)) - record_char (also_record); + if (!do_not_record_char) + { + record_char (c); + recorded = true; + if (! NILP (also_record)) + record_char (also_record); + } /* Wipe the echo area. But first, if we are about to use an input method, @@ -3172,7 +3175,7 @@ read_char (int commandflag, Lisp_Object map, /* When we consume events from the various unread-*-events lists, we bypass the code that records input, so record these events now if they were not recorded already. */ - if (!recorded) + if (!recorded && !do_not_record_char) { record_char (c); recorded = true; @@ -12561,6 +12564,11 @@ syms_of_keyboard (void) \(Even if the operating system has support for stopping a process.) */); cannot_suspend = false; + DEFVAR_BOOL ("do-not-record-char", do_not_record_char, + doc: /* Non-nil means to not record chars. +Those chars would not appear in the dribble file or in `view-lossage'. */); + do_not_record_char = false; + DEFVAR_BOOL ("menu-prompting", menu_prompting, doc: /* Non-nil means prompt with menus when appropriate. This is done when reading from a keymap that has a prompt string, -- 2.36.0