unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks
       [not found] ` <20230411150046.C8002C13916@vcs2.savannah.gnu.org>
@ 2023-04-11 16:40   ` Stefan Monnier
  2023-04-11 17:57     ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2023-04-11 16:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Tassilo Horn

>  ;; Or as a substitute for `other-window'.
> +(defun my-switchy-window-set-or-unset-key ()
> +  (if switchy-window-minor-mode
> +      (keymap-global-set "<remap> <other-window>"
> +                         #'switchy-window)
> +    (keymap-global-unset "<remap> <other-window>")))
> +
>  (add-hook 'switchy-window-minor-mode-hook
> -          (lambda ()
> -            (if switchy-window-minor-mode
> -                (keymap-global-set "<remap> <other-window>"
> -                                   #'switchy-window)
> -              (keymap-global-unset "<remap> <other-window>"))))
> +          #'my-switchy-window-set-or-unset-key)
>  ```

Why not just

    (keymap-set switchy-window-minor-mode-map
                "<remap> <other-window>" #'switchy-window)

?


        Stefan




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks
  2023-04-11 16:40   ` [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks Stefan Monnier
@ 2023-04-11 17:57     ` Tassilo Horn
  2023-04-11 18:38       ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Tassilo Horn @ 2023-04-11 17:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

Hi Stefan,

>>  ;; Or as a substitute for `other-window'.
>> +(defun my-switchy-window-set-or-unset-key ()
>> +  (if switchy-window-minor-mode
>> +      (keymap-global-set "<remap> <other-window>"
>> +                         #'switchy-window)
>> +    (keymap-global-unset "<remap> <other-window>")))
>> +
>>  (add-hook 'switchy-window-minor-mode-hook
>> -          (lambda ()
>> -            (if switchy-window-minor-mode
>> -                (keymap-global-set "<remap> <other-window>"
>> -                                   #'switchy-window)
>> -              (keymap-global-unset "<remap> <other-window>"))))
>> +          #'my-switchy-window-set-or-unset-key)
>>  ```
>
> Why not just
>
>     (keymap-set switchy-window-minor-mode-map
>                 "<remap> <other-window>" #'switchy-window)
>
> ?

That's what I've tried first but it didn't work, i.e., C-x o was still
other-window. I've now tried it again, this time successfully.

I guess I fooled myself during testing, e.g., I've renamed the mode and
map from switchy-window-mode(-map) to switchy-window-minor-mode(-map) at
some point and probably tried remapping with the old name or something
like that.

I'll fix the snippets.

Thanks a lot,
Tassilo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks
  2023-04-11 17:57     ` Tassilo Horn
@ 2023-04-11 18:38       ` Eli Zaretskii
  2023-04-11 18:59         ` Tassilo Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-04-11 18:38 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: monnier, emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Tue, 11 Apr 2023 19:57:04 +0200
> 
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 
> > Why not just
> >
> >     (keymap-set switchy-window-minor-mode-map
> >                 "<remap> <other-window>" #'switchy-window)
> >
> > ?
> 
> That's what I've tried first but it didn't work, i.e., C-x o was still
> other-window. I've now tried it again, this time successfully.

keymap-set is new in Emacs 29, no?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks
  2023-04-11 18:38       ` Eli Zaretskii
@ 2023-04-11 18:59         ` Tassilo Horn
  0 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2023-04-11 18:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

11.04.2023 20:37:34 Eli Zaretskii <eliz@gnu.org>:

>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>
>>> Why not just
>>>
>>>     (keymap-set switchy-window-minor-mode-map
>>>                 "<remap> <other-window>" #'switchy-window)
>>>
>>> ?
>>
>> That's what I've tried first but it didn't work, i.e., C-x o was still
>> other-window. I've now tried it again, this time successfully.
>  keymap-set is new in Emacs 29, no?

Yes, and it's provided by the compat package which switchy-window requires so should work fine even with older emacs versions.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-11 18:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <168122524652.26571.12717876454918406453@vcs2.savannah.gnu.org>
     [not found] ` <20230411150046.C8002C13916@vcs2.savannah.gnu.org>
2023-04-11 16:40   ` [elpa] externals/switchy-window 682bcec0a6: Release 1.2: no code changes but don't suggest adding lambdas to hooks Stefan Monnier
2023-04-11 17:57     ` Tassilo Horn
2023-04-11 18:38       ` Eli Zaretskii
2023-04-11 18:59         ` Tassilo Horn

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).