Subject: bug#30309: Surprising behaviour of insert-kbd-macro

From: Robert Pluim <[email-masked]>
Date: Tue, 16 Apr 2019 09:47:34 +0200

>>>>> On Mon, 15 Apr 2019 20:23:19 -0400, Noam Postavsky <[email-masked]> said:

    Noam> Robert Pluim <[email-masked]> writes:
    >> That would work as well. Something like this (utterly untested
    >> beyond 'insert-kbd-macro'):

    >> DEFUN ("where-is-internal", Fwhere_is_internal,
    >> Swhere_is_internal, 1, 5, 0, doc: /* Return list of keys that
    >> invoke DEFINITION.  +If DEFINITION is nil, return nil.

    >> + if (NILP (definition)) + return Qnil; +

    Noam> Hmm, on the one hand no keys invoke 'nil', so returning nil
    Noam> in that situation is already covered by the current
    Noam> docstring (and doing something else could be considered a
    Noam> plain bug).  On the other hand, I see it returns keys for
    Noam> which (define-key global-map KEY nil) was called, which is
    Noam> potentially useful.  I don't know if anything uses that, but
    Noam> I hesitate to remove the capability.

I donʼt know either, so best leave it alone.

    Noam> By the way, I noticed the diff below also fixes this bug,
    Noam> although I don't quite understand why.

That results in

    (setq last-kbd-macro
       nil)
    (global-set-key [S-down-mouse-1] 'last-kbd-macro)
    (global-set-key [horizontal-scroll-bar drag-mouse-1] 'last-kbd-macro)
    (global-set-key [horizontal-scroll-bar mouse-1] 'last-kbd-macro)
    (global-set-key [vertical-scroll-bar drag-mouse-1] 'last-kbd-macro)
    (global-set-key [vertical-scroll-bar mouse-1] 'last-kbd-macro)

which I guess is better, but not perfect.

Robert