From: Justin Burkett <justin@burkett.cc>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Proposed patch for lookup-key
Date: Thu, 14 Dec 2017 20:31:35 -0500 [thread overview]
Message-ID: <CAF8XuLjGDC7miXesizKCq9iA85n9sD1GWEbHSwPUxr418H5Vig@mail.gmail.com> (raw)
In-Reply-To: <CAF8XuLh3JhL3aiN0ZNp=akiiMhd9-zhKH5tnqZp4gFVx0e+CHw@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 920 bytes --]
Here's a similar patch for `key-binding`
Justin
On Thu, Dec 14, 2017 at 2:44 PM, Justin Burkett <justin@burkett.cc> wrote:
> Hi all,
>
> I'd like to be able to access more information about key bindings of the
> form (DESCRIPTION . DEF) and menu-items. As far as I can tell there's no
> easy way to do this using built-in tools in a robust way (i.e., without
> manually having to write a lookup-key function).
>
> I'm wondering if the attached patch would be acceptable. The idea was to
> add an optional argument to lookup-key to prevent it from stripping this
> information about the key bindings.
>
> In principle, I might also like to do something similar for the
> key-binding function, but the current patch is sufficient for my purposes.
>
> I have assigned copyright to the FSF, but this would be my first commit
> against Emacs. I apologize in advance for overlooking some convention.
>
> Thanks,
> Justin
>
[-- Attachment #1.2: Type: text/html, Size: 1442 bytes --]
[-- Attachment #2: 0001-Allow-key-binding-to-return-full-menu-item-entries.patch --]
[-- Type: application/octet-stream, Size: 2908 bytes --]
From d37b9b698d78f7bc830aff9ed0cbef6f7f015c38 Mon Sep 17 00:00:00 2001
From: Justin Burkett <justin@burkett.cc>
Date: Thu, 14 Dec 2017 20:26:47 -0500
Subject: [PATCH] Allow key-binding to return full menu-item entries
* src/keyboard.c (parse_menu_item): Adjust call to Fkey_binding
* src/keymap.c (Fcommand_remapping): Adjust call to Fkey_binding
(Fkey_binding): Add menus arg
---
src/keyboard.c | 2 +-
src/keymap.c | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index 10ead0c1ab..c6f235fb8b 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7897,7 +7897,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
if (CONSP (keyhint) && !NILP (XCAR (keyhint)))
{
keys = XCAR (keyhint);
- tem = Fkey_binding (keys, Qnil, Qnil, Qnil);
+ tem = Fkey_binding (keys, Qnil, Qnil, Qnil, Qnil);
/* We have a suggested key. Is it bound to the command? */
if (NILP (tem)
diff --git a/src/keymap.c b/src/keymap.c
index 6fac478cda..1d53f8f8b6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1188,7 +1188,7 @@ remapping in all currently active keymaps. */)
ASET (command_remapping_vector, 1, command);
if (NILP (keymaps))
- command = Fkey_binding (command_remapping_vector, Qnil, Qt, position);
+ command = Fkey_binding (command_remapping_vector, Qnil, Qt, position, Qnil);
else
command = Flookup_key (Fcons (Qkeymap, keymaps),
command_remapping_vector, Qnil, Qnil);
@@ -1610,7 +1610,7 @@ like in the respective argument of `key-binding'. */)
/* GC is possible in this function if it autoloads a keymap. */
-DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 4, 0,
+DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 5, 0,
doc: /* Return the binding for command KEY in current keymaps.
KEY is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
@@ -1635,8 +1635,12 @@ position as returned by `event-start' and `event-end', and the lookup
occurs in the keymaps associated with it instead of KEY. It can also
be a number or marker, in which case the keymap properties at the
specified buffer position instead of point are used.
+
+A non-nil value for MENUS makes `key-binding` return full menu-items
+instead of just the associated definition.
*/)
- (Lisp_Object key, Lisp_Object accept_default, Lisp_Object no_remap, Lisp_Object position)
+ (Lisp_Object key, Lisp_Object accept_default, Lisp_Object no_remap,
+ Lisp_Object position, Lisp_Object menus)
{
Lisp_Object value;
@@ -1662,7 +1666,7 @@ specified buffer position instead of point are used.
}
value = Flookup_key (Fcons (Qkeymap, Fcurrent_active_maps (Qt, position)),
- key, accept_default, Qnil);
+ key, accept_default, menus);
if (NILP (value) || INTEGERP (value))
return Qnil;
--
2.15.1
next prev parent reply other threads:[~2017-12-15 1:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 19:44 Proposed patch for lookup-key Justin Burkett
2017-12-14 21:07 ` Robert Weiner
2017-12-14 21:25 ` Justin Burkett
2017-12-15 1:31 ` Justin Burkett [this message]
2017-12-15 2:57 ` Stefan Monnier
2017-12-15 14:55 ` Justin Burkett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAF8XuLjGDC7miXesizKCq9iA85n9sD1GWEbHSwPUxr418H5Vig@mail.gmail.com \
--to=justin@burkett.cc \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.