all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to bind isearch-repeat-forward to F3 in a certain mode only?
Date: Fri, 24 Jul 2015 14:53:04 +0200	[thread overview]
Message-ID: <87pp3hyaxb.fsf@web.de> (raw)
In-Reply-To: 87zj2mr0t3.fsf@mbork.pl

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.




  reply	other threads:[~2015-07-24 12:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 22:01 How to bind isearch-repeat-forward to F3 in a certain mode only? Marcin Borkowski
2015-07-24 12:53 ` Michael Heerdegen [this message]
2015-07-27 21:13   ` Marcin Borkowski
2015-07-27 21:43     ` Michael Heerdegen
2015-07-27 23:45     ` Emanuel Berg
2015-07-28  0:26       ` Ian Zimmerman
2015-07-28  1:07         ` Emanuel Berg
2015-07-28  8:30         ` Marcin Borkowski
2015-07-28 16:15           ` Yuri Khan
     [not found]         ` <mailman.7513.1438072243.904.help-gnu-emacs@gnu.org>
2015-07-28  8:42           ` Rusi
2015-07-28  8:50             ` Marcin Borkowski
2015-07-28 15:01             ` Ian Zimmerman
2015-07-28 15:28               ` Marcin Borkowski
     [not found]               ` <mailman.7552.1438097346.904.help-gnu-emacs@gnu.org>
2015-07-30  0:23                 ` Hikaru Ichijyo
2015-07-30  1:17                   ` Ian Zimmerman
2015-07-30  3:15                     ` Emanuel Berg
2015-07-30  5:10                       ` Ian Zimmerman
2015-07-30 22:36                         ` Emanuel Berg
     [not found]                   ` <mailman.7637.1438219082.904.help-gnu-emacs@gnu.org>
2015-07-30  1:48                     ` Hikaru Ichijyo
2015-07-30 12:56                     ` HASM
2015-07-30 22:37                       ` Emanuel Berg
     [not found]             ` <mailman.7551.1438095703.904.help-gnu-emacs@gnu.org>
2015-07-28 17:00               ` Rusi
2015-07-28  1:02       ` Marcin Borkowski
     [not found] <mailman.7323.1437688903.904.help-gnu-emacs@gnu.org>
2015-07-23 22:53 ` Javier
2015-07-23 23:09   ` Marcin Borkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pp3hyaxb.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.