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: Tue, 26 Oct 2021 09:49:40 +0800

On Tue, Oct 26, 2021 at 2:03 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > (company-set-selection company--search-old-selection t)
> > (setq company-selection-changed company--search-old-changed))
>
> You have to do that manually?

This is the code provided in the company-mode package:

https://github.com/company-mode/company-mode/blob/811beeade86669e20da35efed5b00de6a5e305ab/company.el#L2343

> >          :map company-search-map
> >          ("<tab>" . (lambda ()
> >                     (interactive)
> >                     (if company-search-mode (company-search-abort)
> >                       (company-search-candidates))))
>
> Yeah, but that looks weird ...

As I've told, it really represents the expected behavior.

> the map is like 1/3 a mode.
> You have to check for the major-mode now in its own map?

I'm really puzzled by your comments and the following code snippet.

> I wrote one major mode ...
>
> There it looks like this only.
>
> (defvar fpscalc-mode-map
>   (let ((the-map (make-keymap)))
>     (define-key the-map "\t" 'newline-and-indent)
>     the-map)
>   "`fpscalc-mode' keymap.")
>
> Okay not quite 1/3 ...
>
> https://dataswamp.org/~incal/fps/fpscalc.el
>
> https://dataswamp.org/~incal/fps/fpscalc.png <-- cool B)
>
> --
> underground experts united
> https://dataswamp.org/~incal
>
>



reply via email to

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