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: Hongyi Zhao
Subject: Re: Bind two commands to one key to toggle between them for the same local keymap.
Date: Fri, 22 Oct 2021 18:02:21 +0800

On Fri, Oct 22, 2021 at 5:55 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > I changed to the following code snippet, but got the same
> > result:
> >
> >   (defun hz-company-search ()
> >     (interactive)
> >     (if company-search-mode
> >     (company-search-abort)
> >       (company-search-candidates)))
> >
> >   (define-key company-active-map "\t" #'hz-company-search)
> >   (define-key company-search-map "\t" #'hz-company-search)
>
> Hm ... shouldn't it be `company-search-abort' in
> `company-search-map'?

The following version was tried but got the same behavior:

  (defun hz-company-search ()
    (interactive)
    (if company-search-abort
    (company-search-abort)
      (company-search-candidates)))

  (define-key company-active-map "\t" #'hz-company-search)
  (define-key company-search-map "\t" #'hz-company-search)


> But if the function is correct it should work if/where these
> maps are active ...

I'm puzzled by it.



reply via email to

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