[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: |
Hongyi Zhao |
Subject: |
Re: Bind two commands to one key to toggle between them for the same local keymap. |
Date: |
Fri, 22 Oct 2021 17:15:01 +0800 |
On Fri, Oct 22, 2021 at 4:34 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> 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.
[1]
https://stackoverflow.com/questions/10088168/how-to-check-whether-a-minor-mode-e-g-flymake-mode-is-on
HZ
- 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: 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: 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 <=
- 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: 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: 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: 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