help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I'd like to advise a /keybinding/, how do I do it?


From: Omar Polo
Subject: Re: I'd like to advise a /keybinding/, how do I do it?
Date: Wed, 28 Apr 2021 09:08:33 +0200
User-agent: mu4e 1.4.15; emacs 28.0.50

Marcin Borkowski <mbork@mbork.pl> writes:

> 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?

Probably post-command-hook?  I don't know how to read the current
keybinding, but if it's possible then you can run code in the
post-command-hook and check there

HTH



reply via email to

[Prev in Thread] Current Thread [Next in Thread]