[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
I'd like to advise a /keybinding/, how do I do it?
From: |
Marcin Borkowski |
Subject: |
I'd like to advise a /keybinding/, how do I do it? |
Date: |
Wed, 28 Apr 2021 07:25:14 +0200 |
User-agent: |
mu4e 1.1.0; emacs 28.0.50 |
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
- I'd like to advise a /keybinding/, how do I do it?,
Marcin Borkowski <=