aboutsummaryrefslogtreecommitdiffstats
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorStefan Monnier2014-11-09 21:58:52 -0500
committerStefan Monnier2014-11-09 21:58:52 -0500
commiteca1ea96559e04e18a62a61208d501c557dd4cab (patch)
treebc1b7bb276957c445917c7a70dbfe604710545ff /src/keyboard.c
parent155d93fff87a516197d29edbd02af9a10517bd61 (diff)
downloademacs-eca1ea96559e04e18a62a61208d501c557dd4cab.tar.gz
emacs-eca1ea96559e04e18a62a61208d501c557dd4cab.zip
* lisp/help.el (view-lossage): Include the actual commands run.
* src/keyboard.c (command_loop_1): Record this-command in recent-keys. (Frecent_keys): Rewrite. and add optional `include-cmds' arg.
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 24f47bfedc9..060784cf0af 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1534,6 +1534,13 @@ command_loop_1 (void)
1534 1534
1535 /* Execute the command. */ 1535 /* Execute the command. */
1536 1536
1537 {
1538 total_keys += total_keys < NUM_RECENT_KEYS;
1539 ASET (recent_keys, recent_keys_index,
1540 Fcons (Qnil, cmd));
1541 if (++recent_keys_index >= NUM_RECENT_KEYS)
1542 recent_keys_index = 0;
1543 }
1537 Vthis_command = cmd; 1544 Vthis_command = cmd;
1538 Vreal_this_command = cmd; 1545 Vreal_this_command = cmd;
1539 safe_run_hooks (Qpre_command_hook); 1546 safe_run_hooks (Qpre_command_hook);
@@ -10048,23 +10055,34 @@ If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */)
10048 ? Qt : Qnil); 10055 ? Qt : Qnil);
10049} 10056}
10050 10057
10051DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 0, 0, 10058DEFUN ("recent-keys", Frecent_keys, Srecent_keys, 0, 1, 0,
10052 doc: /* Return vector of last 300 events, not counting those from keyboard macros. */) 10059 doc: /* Return vector of last few events, not counting those from keyboard macros.
10053 (void) 10060If INCLUDE-CMDS is non-nil, include the commands that were run,
10061represented as events of the form (nil . COMMAND). */)
10062 (Lisp_Object include_cmds)
10054{ 10063{
10055 Lisp_Object *keys = XVECTOR (recent_keys)->contents; 10064 bool cmds = !NILP (include_cmds);
10056 Lisp_Object val;
10057 10065
10058 if (total_keys < NUM_RECENT_KEYS) 10066 if (!total_keys
10059 return Fvector (total_keys, keys); 10067 || (cmds && total_keys < NUM_RECENT_KEYS))
10068 return Fvector (total_keys,
10069 XVECTOR (recent_keys)->contents);
10060 else 10070 else
10061 { 10071 {
10062 val = Fvector (NUM_RECENT_KEYS, keys); 10072 Lisp_Object es = Qnil;
10063 vcopy (val, 0, keys + recent_keys_index, 10073 int i = (total_keys < NUM_RECENT_KEYS
10064 NUM_RECENT_KEYS - recent_keys_index); 10074 ? 0 : recent_keys_index);
10065 vcopy (val, NUM_RECENT_KEYS - recent_keys_index, 10075 eassert (recent_keys_index < NUM_RECENT_KEYS);
10066 keys, recent_keys_index); 10076 do
10067 return val; 10077 {
10078 Lisp_Object e = AREF (recent_keys, i);
10079 if (cmds || !CONSP (e) || !NILP (XCAR (e)))
10080 es = Fcons (e, es);
10081 if (++i >= NUM_RECENT_KEYS)
10082 i = 0;
10083 } while (i != recent_keys_index);
10084 es = Fnreverse (es);
10085 return Fvconcat (1, &es);
10068 } 10086 }
10069} 10087}
10070 10088