aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTino Calancha2020-06-22 22:41:34 +0200
committerTino Calancha2020-06-26 19:06:23 +0200
commita60a05994aff16bc27f153ea8f765e15b92f21be (patch)
tree2f39e439b0f0194c45ec9d067f5d443035e9bd41
parent9723c2645c8f47e651a81a023e80f882d181cc3f (diff)
downloademacs-feature/bug#38796-lossage-limit.tar.gz
emacs-feature/bug#38796-lossage-limit.zip
Allow disable the record of keystrokes (lossage)feature/bug#38796-lossage-limit
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.
-rw-r--r--doc/emacs/help.texi10
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/cus-start.el6
-rw-r--r--src/keyboard.c11
-rw-r--r--test/src/keyboard-tests.el2
5 files changed, 22 insertions, 10 deletions
diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index e2c0dc68026..69ea96763b9 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
569input keystrokes and the commands they invoked. By default, Emacs 569input keystrokes and the commands they invoked. By default, Emacs
570stores the last 300 events; if you wish, you can change this number 570stores the last 300 events; if you wish, you can change this number
571with the option @code{lossage-limit}. 571with the option @code{lossage-limit}.
572If you see commands that you are not familiar with, you can use @kbd{C-h k} or 572If you see commands that you are not familiar with, you can use @kbd{C-h k}
573@kbd{C-h f} to find out what they do. 573or @kbd{C-h f} to find out what they do.
574If you don't like that Emacs saves your keystrokes, then you can
575set @code{lossage-limit} equal to 1; such a value effectively disables the
576record of the keystrokes. Please, do not set this option with @code{setq}
577neither let-bind it; that will likely crash Emacs. Use instead the
578customization menu, which also updates the internal structure holding
579the keystrokes.
574 580
575@kindex C-h e 581@kindex C-h e
576@findex view-echo-area-messages 582@findex view-echo-area-messages
diff --git a/etc/NEWS b/etc/NEWS
index da204c58258..17776173e04 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -72,7 +72,8 @@ useful on systems such as FreeBSD which ships only with "etc/termcap".
72 72
73+++ 73+++
74** The new option 'lossage-limit' controls the maximum number 74** The new option 'lossage-limit' controls the maximum number
75of keystrokes and commands recorded. 75of keystrokes and commands recorded. The value 1 disables
76the record of keystrokes.
76 77
77** Support for '(box . SIZE)' 'cursor-type'. 78** Support for '(box . SIZE)' 'cursor-type'.
78By default, 'box' cursor always has a filled box shape. But if you 79By 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 1ebf554b2bb..bd4ff3a74be 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
352 ;; indent.c 352 ;; indent.c
353 (indent-tabs-mode indent boolean) 353 (indent-tabs-mode indent boolean)
354 ;; keyboard.c 354 ;; keyboard.c
355 (lossage-limit keyboard integer "28.1" 355 (lossage-limit keyboard
356 (choice (const :tag "Do not record keystrokes" 1)
357 integer)
358 "28.1"
359 :standard 300
356 :set (lambda (_ val) (update-lossage-limit val))) 360 :set (lambda (_ val) (update-lossage-limit val)))
357 (meta-prefix-char keyboard character) 361 (meta-prefix-char keyboard character)
358 (auto-save-interval auto-save integer) 362 (auto-save-interval auto-save integer)
diff --git a/src/keyboard.c b/src/keyboard.c
index a4d27c94fba..9af1b9ba50b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -103,8 +103,6 @@ static KBOARD *all_kboards;
103/* True in the single-kboard state, false in the any-kboard state. */ 103/* True in the single-kboard state, false in the any-kboard state. */
104static bool single_kboard; 104static bool single_kboard;
105 105
106#define MIN_NUM_RECENT_KEYS (100)
107
108/* Index for storing next element into recent_keys. */ 106/* Index for storing next element into recent_keys. */
109static int recent_keys_index; 107static int recent_keys_index;
110 108
@@ -10444,7 +10442,7 @@ usage: (update-lossage-limit ARG) */)
10444 user_error ("Value must be a positive integer"); 10442 user_error ("Value must be a positive integer");
10445 int osize = ASIZE (recent_keys); 10443 int osize = ASIZE (recent_keys);
10446 eassert (lossage_limit == osize); 10444 eassert (lossage_limit == osize);
10447 int min_size = MIN_NUM_RECENT_KEYS; 10445 int min_size = 1;
10448 int new_size = XFIXNAT (arg); 10446 int new_size = XFIXNAT (arg);
10449 10447
10450 if (new_size == osize) 10448 if (new_size == osize)
@@ -11749,8 +11747,11 @@ call from Lisp the following expression:
11749 11747
11750 (update-lossage-limit new-limit) 11748 (update-lossage-limit new-limit)
11751 11749
11752That takes care of both, the variable and the internal vector.*/); 11750That takes care of both, the variable and the internal vector.
11753 lossage_limit = 3 * MIN_NUM_RECENT_KEYS; 11751
11752Security note: The value 1 makes impossible to recover a typed string
11753with `view-lossage'.*/);
11754 lossage_limit = 300;
11754 11755
11755 recent_keys = make_nil_vector (lossage_limit); 11756 recent_keys = make_nil_vector (lossage_limit);
11756 staticpro (&recent_keys); 11757 staticpro (&recent_keys);
diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el
index 017d239246a..4541c389d02 100644
--- a/test/src/keyboard-tests.el
+++ b/test/src/keyboard-tests.el
@@ -38,7 +38,7 @@
38 (update-lossage-limit val) 38 (update-lossage-limit val)
39 (should (= val lossage-limit))) 39 (should (= val lossage-limit)))
40 (let ((current-limit lossage-limit)) 40 (let ((current-limit lossage-limit))
41 (should-error (update-lossage-limit 5)) 41 (should-error (update-lossage-limit 0))
42 (should-error (update-lossage-limit "200")) 42 (should-error (update-lossage-limit "200"))
43 (should (= lossage-limit current-limit)))) 43 (should (= lossage-limit current-limit))))
44 44