emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#38796-lossage-limit cc09a33 2/4: Allow disable the record of keystro


From: Tino Calancha
Subject: bug#38796-lossage-limit cc09a33 2/4: Allow disable the record of keystrokes (lossage)
Date: Sun, 28 Jun 2020 17:34:41 -0400 (EDT)

branch: bug#38796-lossage-limit
commit cc09a334c72ff615d6593b752cf0ea79ba8b1eca
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>

    Allow disable the record of keystrokes (lossage)
    
    Use 1 as the minimum value for lossage-limit; such a value
    is equivalent to not recording the keystrokes: having just 1 entry,
    will be overwritten with the view-lossage call itself.
    
    * test/src/keyboard-tests.el (keyboard-lossage-limit): Update test.
    * src/keyboard.c (MIN_NUM_RECENT_KEYS): Delete it.
    (lossage_limit): Add security note in the doctring.
    * lisp/cus-start.el (lossage-limit): Let users choose to disable
    the record of the keystrokes.
    * doc/emacs/help.texi (Misc Help): Update manual.
    * etc/NEWS (Changes in Emacs 28.1):
    Mention that it's possible to disable the record of keystrokes.
---
 doc/emacs/help.texi        | 10 ++++++++--
 etc/NEWS                   |  3 ++-
 lisp/cus-start.el          |  6 +++++-
 src/keyboard.c             | 11 ++++++-----
 test/src/keyboard-tests.el |  2 +-
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index e2c0dc6..69ea967 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -569,8 +569,14 @@ use @kbd{C-h l} (@code{view-lossage}).  @kbd{C-h l} 
displays your last
 input keystrokes and the commands they invoked.  By default, Emacs
 stores the last 300 events; if you wish, you can change this number
 with the option @code{lossage-limit}.
-If you see commands that you are not familiar with, you can use @kbd{C-h k} or
-@kbd{C-h f} to find out what they do.
+If you see commands that you are not familiar with, you can use @kbd{C-h k}
+or @kbd{C-h f} to find out what they do.
+If you don't like that Emacs saves your keystrokes, then you can
+set @code{lossage-limit} equal to 1; such a value effectively disables the
+record of the keystrokes.  Please, do not set this option with @code{setq}
+neither let-bind it; that will likely crash Emacs.  Use instead the
+customization menu, which also updates the internal structure holding
+the keystrokes.
 
 @kindex C-h e
 @findex view-echo-area-messages
diff --git a/etc/NEWS b/etc/NEWS
index da204c5..1777617 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -72,7 +72,8 @@ useful on systems such as FreeBSD which ships only with 
"etc/termcap".
 
 +++
 ** The new option 'lossage-limit' controls the maximum number
-of keystrokes and commands recorded.
+of keystrokes and commands recorded.  The value 1 disables
+the record of keystrokes.
 
 ** Support for '(box . SIZE)' 'cursor-type'.
 By default, 'box' cursor always has a filled box shape.  But if you
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 1ebf554..bd4ff3a 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -352,7 +352,11 @@ Leaving \"Default\" unchecked is equivalent with 
specifying a default of
             ;; indent.c
             (indent-tabs-mode indent boolean)
             ;; keyboard.c
-             (lossage-limit keyboard integer "28.1"
+             (lossage-limit keyboard
+                            (choice (const :tag "Do not record keystrokes" 1)
+                                    integer)
+                            "28.1"
+                            :standard 300
                             :set (lambda (_ val) (update-lossage-limit val)))
             (meta-prefix-char keyboard character)
             (auto-save-interval auto-save integer)
diff --git a/src/keyboard.c b/src/keyboard.c
index a4d27c9..9af1b9b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -103,8 +103,6 @@ static KBOARD *all_kboards;
 /* True in the single-kboard state, false in the any-kboard state.  */
 static bool single_kboard;
 
-#define MIN_NUM_RECENT_KEYS (100)
-
 /* Index for storing next element into recent_keys.  */
 static int recent_keys_index;
 
@@ -10444,7 +10442,7 @@ usage: (update-lossage-limit ARG)  */)
     user_error ("Value must be a positive integer");
   int osize = ASIZE (recent_keys);
   eassert (lossage_limit == osize);
-  int min_size = MIN_NUM_RECENT_KEYS;
+  int min_size = 1;
   int new_size = XFIXNAT (arg);
 
   if (new_size == osize)
@@ -11749,8 +11747,11 @@ call from Lisp the following expression:
 
   (update-lossage-limit new-limit)
 
-That takes care of both, the variable and the internal vector.*/);
-  lossage_limit = 3 * MIN_NUM_RECENT_KEYS;
+That takes care of both, the variable and the internal vector.
+
+Security note: The value 1 makes impossible to recover a typed string
+with `view-lossage'.*/);
+  lossage_limit = 300;
 
   recent_keys = make_nil_vector (lossage_limit);
   staticpro (&recent_keys);
diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el
index 017d239..4541c38 100644
--- a/test/src/keyboard-tests.el
+++ b/test/src/keyboard-tests.el
@@ -38,7 +38,7 @@
     (update-lossage-limit val)
     (should (= val lossage-limit)))
   (let ((current-limit lossage-limit))
-    (should-error (update-lossage-limit 5))
+    (should-error (update-lossage-limit 0))
     (should-error (update-lossage-limit "200"))
     (should (= lossage-limit current-limit))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]