[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: |
Emanuel Berg |
Subject: |
Re: Bind two commands to one key to toggle between them for the same local keymap. |
Date: |
Fri, 22 Oct 2021 11:32:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Hongyi Zhao wrote:
>>>>>> ("<tab>" . (lamda () (if (company-search-mode)
>>>>>> #'company-search-abort
>>>>>> #'company-search-candidates)))
>>>>>>
>>>>>> What's the problem?
>>>>>
>>>>> Several :)
>>>>
>>> > I'm at the end of my rope
>>>
>>> Without knowing the situation ...
>>>
>>> (require 'company)
>>>
>>> (defun company-search-hz ()
>>> (interactive)
>>> (if (eq major-mode 'company-search-mode)
>>> (company-search-abort)
>>> (company-search-candidates) ))
>>>
>>> (define-key company-mode-map "\t" #'company-search-hz)
>>
>> Thank you for your idea. `company-search-mode' is a minor mode, and
>> according to the notes here [1], I changed your function to the
>> following:
>>
>> (defun hz-company-search ()
>> (interactive)
>> (if (bound-and-true-p company-search-mode)
>> (company-search-abort)
>> (company-search-candidates)))
>>
>> (define-key company-mode-map "\t" #'hz-company-search)
>>
>> Based on my testing, it doesn't work as expected.
>
> I mean, it works differently from the behavior given by the
> following use-packatge configuration:
>
> (use-package company
> :bind
> (:map company-active-map
> ("<tab>" . company-search-candidates)
> ("<f1>" . company-search-abort)
>
> :map company-search-map
> ("<tab>" . company-search-candidates)
> ("<f1>" . company-search-abort))
>
> With the above configuration, "<tab>" and "<f1>" will call
> the corresponding interactive Lisp closure correctly, but
> I have to use two different keys.
company-active-map ... that's yet another one!
Use 'C-h k' to see what happens ...
--
underground experts united
https://dataswamp.org/~incal
- Re: Bind two commands to one key to toggle between them for the same local keymap., (continued)
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap., Emanuel Berg, 2021/10/23
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/23
- Re: Bind two commands to one key to toggle between them for the same local keymap., Emanuel Berg, 2021/10/23
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/23
- Re: Bind two commands to one key to toggle between them for the same local keymap., Emanuel Berg, 2021/10/24
- Re: Bind two commands to one key to toggle between them for the same local keymap., Michael Heerdegen, 2021/10/24
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap.,
Emanuel Berg <=
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap., Emanuel Berg, 2021/10/22
- Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- RE: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Drew Adams, 2021/10/22
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/22
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Michael Heerdegen, 2021/10/23
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/23
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Michael Heerdegen, 2021/10/23
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Hongyi Zhao, 2021/10/23
- Re: [External] : Re: Bind two commands to one key to toggle between them for the same local keymap., Michael Heerdegen, 2021/10/23