Subject: Re: bug#44328: 27.1; [PATCH] Add expand-abbrev-maybe condition key binding

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 13 May 2021 13:25:52 +0200

Zhu Zihao <[email-masked]> writes:

> And I define a abbrev "lb" in Elisp mode. then enable minor mode
> my-override-map in Elisp mode. If my cursor is following "lb"(like
> "lb|"), it will expand the abbrev, otherwise it will execute eww.
>
> Now I change the key binding of C-' in global map(change to gnus). the
> behaviour of keybinding in my-override-map will become "Expand abbrev if
> possible otherwise execute gnus" 

Ah, I understand what you mean now -- you want a key that's normally
bound to a different command, but if it's after an abbreviation, it
should expand the abbreviation instead.

Yes, that menu trick does work for that use case, but you could also use
a command like:

(defun my-expand ()
  (interactive)
  (if (abbrev--before-point)
      (expand-abbrev)
    (call-interactively
     (lookup-key (delq my-override-map (current-active-maps))
		 (this-command-keys)))))

In any case, I don't think these sort of "chained" keystrokes are very
common -- I think most users would find them somewhat confusing, so I
don't think adding something like this to Emacs would be appropriate.
So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no