[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
From: |
Michael Heerdegen |
Subject: |
Re: How to bind isearch-repeat-forward to F3 in a certain mode only? |
Date: |
Fri, 24 Jul 2015 14:53:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Marcin Borkowski <mbork@mbork.pl> writes:
> ,----
> | (my-mode)
> | (make-local-variable 'isearch-mode-map)
> | (define-key isearch-mode-map (kbd "<F3>") #'isearch-repeat-forward)
> `----
>
> but to no avail. Inspecting `isearch-mode-map' implies that it was in
> fact changed globally. Pressing F3 while in isearch, though, starts
> recording a keyboard macro anyway (both in my-mode and outside it).
Your approach seems reasonable. There are two errors in your code
however:
1. (kbd "<F3>") obviously doesn't return the key sequence you want. I
don't use `kbd'; I would just use [f3] instead.
2. Your change is "globally visible" because you missed that in Lisp,
variables reference lists by reference, not by value. Keymaps are lists
in Elisp.
So, in your code, you create a new (local) binding, but that binding
still refers to the same object. Use `copy-keymap' to fix that. So at
the end you would have something like
(setq-local isearch-mode-map (copy-keymap isearch-mode-map))
(define-key isearch-mode-map [f3] #'isearch-repeat-forward)
You can do that in your `my-mode-hook' of course.
Regards,
Michael.
- How to bind isearch-repeat-forward to F3 in a certain mode only?, Marcin Borkowski, 2015/07/23
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?,
Michael Heerdegen <=
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Marcin Borkowski, 2015/07/27
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Michael Heerdegen, 2015/07/27
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Emanuel Berg, 2015/07/27
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Ian Zimmerman, 2015/07/27
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Emanuel Berg, 2015/07/27
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Marcin Borkowski, 2015/07/28
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Yuri Khan, 2015/07/28
- Message not available
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Rusi, 2015/07/28
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Marcin Borkowski, 2015/07/28
- Re: How to bind isearch-repeat-forward to F3 in a certain mode only?, Ian Zimmerman, 2015/07/28