From: Marcin Borkowski <mbork@mbork.pl>
To: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: I'd like to advise a /keybinding/, how do I do it?
Date: Wed, 28 Apr 2021 07:25:14 +0200 [thread overview]
Message-ID: <87lf930ymd.fsf@mbork.pl> (raw)
Hello everyone,
what I'd like to do is to "advise a keybinding", IOW, advise whatever
command a given key is bound to. How do I get the name of the command
given a key, and taking into account the current major mode, minor modes
etc.?
I tried to look at the source code of `describe-key-briefly', but it is
pretty dense, and maybe there's a better way than diving into that
rabbit hole.
The rationale is that I'm thinking about writing a minor mode which
could prevent a "finishing" action until the buffer is ready.
A "finishing" action is often bound to C-c C-c (sending an email and
commiting something to Git come to mind), so I'd like to advise whatever
C-c C-c calls to check the buffer for occurrences of a string like TODO.
Of course, a more robust way would be to have a list of various major
modes and their "finishing" commands, but I think the idea with just
looking up C-c C-c is cute (even if not very robust), and I was
wondering if it can be done in a simple way, even as a toy.
Any ideas?
--
Marcin Borkowski
http://mbork.pl
next reply other threads:[~2021-04-28 5:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 5:25 Marcin Borkowski [this message]
2021-04-28 7:08 ` I'd like to advise a /keybinding/, how do I do it? Omar Polo
2021-04-28 9:21 ` Philip Kaludercic
2021-04-28 11:44 ` Eli Zaretskii
2021-04-28 14:33 ` Stefan Monnier
2021-04-29 0:29 ` Bob Newell
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lf930ymd.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).