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

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

Re: Bind two commands to one key to toggle between them for the same loc


From: Michael Heerdegen
Subject: Re: Bind two commands to one key to toggle between them for the same local keymap.
Date: Mon, 25 Oct 2021 17:10:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> [...]
> And figured out the following solution:
>
> ```emacs-lisp
> (use-package company
>   :bind (
>      :map company-active-map
>          ("<tab>" . (lambda ()
>                     (interactive)
>                     (if company-search-mode (company-search-abort)
>                       (company-search-candidates))))
>
>          :map company-search-map
>          ("<tab>" . (lambda ()
>                     (interactive)
>                     (if company-search-mode (company-search-abort)
>                       (company-search-candidates))))
>      )

And it does what you want?

If you are done you can factor out the two identical interactive lambdas
as a named function (using `defun').

Michael.




reply via email to

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