As far as I can tell, this is a working implementation of the wishlist item http://bugs.conkeror.org/issue66.
There is now a variable "extended_command_display_whereis" (false by
default), which if true causes call_interactively, if called from M-x,
to display any keybindings that exist for that command.
Because I was originally working in commands.js, I also made a slight
cleanup to execute-extended-command.
Share and enjoy!
Ivy
--
If I Am Ever A Heroine...
25. I will never travel back into the past in order to prevent the
current situation. It *never* works.
From 3f48f76744a81a447ff2f9488cdb456a546879a9 Mon Sep 17 00:00:00 2001
From: Ivy Foster <[EMAIL PROTECTED]>
Date: Thu, 4 Dec 2008 00:23:15 -0600
Subject: [PATCH] Commands called by M-x optionally display keys
- If the variable `extended_command_display_whereis' is true,
(false by default) the interactive command doesn't result in
a minibuffer message, and the command is bound to a key or keys,
display the keybinding(s) on the minibuffer.
- Also, slight cleanup of one command in commands.js
---
modules/commands.js | 8 ++++----
modules/interactive.js | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/modules/commands.js b/modules/commands.js
index 75ae1c5..17ffb95 100644
--- a/modules/commands.js
+++ b/modules/commands.js
@@ -119,6 +119,7 @@ function meta_x (window, prefix, command, browser_object)
prefix_argument: prefix,
browser_object: browser_object}, command);
}
+
interactive("execute-extended-command",
"Execute a Conkeror command specified in the minibuffer.",
function (I) {
@@ -133,10 +134,9 @@ interactive("execute-extended-command",
else
prompt += " "+prefix;
}
- meta_x(I.window, I.P,
- (yield I.minibuffer.read_command(
- $prompt = "M-x" + prompt)),
- boc);
+ var cmd = (yield I.minibuffer.read_command(
+ $prompt = "M-x" + prompt));
+ meta_x(I.window, prefix, cmd, boc);
});
/// built in commands
diff --git a/modules/interactive.js b/modules/interactive.js
index d10b797..7bcd716 100644
--- a/modules/interactive.js
+++ b/modules/interactive.js
@@ -7,6 +7,7 @@
**/
require("utils.js");
+require("help.js");
var interactive_commands = new string_hashmap();
@@ -70,6 +71,9 @@ function handle_interactive_error(window, e) {
}
}
+define_variable("extended_command_display_whereis", false,
+ "Specifies whether `execute-extended-command' should display the key the command is bound to.");
+
function call_interactively(I, command)
{
var handler;
@@ -139,9 +143,19 @@ function call_interactively(I, command)
{
handle_interactive_error(window, e);
}
+ if (I.key_sequence == null)
+ if (I.minibuffer.current_message == null)
+ if (extended_command_display_whereis == true)
+ {
+ var list = find_command_in_keymap(I.buffer, command);
+ if (list.length != 0)
+ {
+ var msg = command + " is on " + list.join(", ");
+ I.buffer.window.minibuffer.message(msg);
+ }
+ }
}
-
function alternates () {
let alts = Array.prototype.slice.call(arguments, 0);
return function (I) {
--
1.6.0.4
pgpRnxHcWBn9L.pgp
Description: PGP signature
_______________________________________________ Conkeror mailing list [email protected] https://www.mozdev.org/mailman/listinfo/conkeror
