From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How to bind isearch-repeat-forward to F3 in a certain mode only? Date: Mon, 27 Jul 2015 23:13:55 +0200 Message-ID: <87zj2htid3.fsf@mbork.pl> References: <87zj2mr0t3.fsf@mbork.pl> <87pp3hyaxb.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438031683 19509 80.91.229.3 (27 Jul 2015 21:14:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jul 2015 21:14:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 27 23:14:28 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZJpj9-0001sA-8H for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Jul 2015 23:14:27 +0200 Original-Received: from localhost ([::1]:55561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJpj8-0002QV-Hu for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Jul 2015 17:14:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJpix-0002QK-HR for help-gnu-emacs@gnu.org; Mon, 27 Jul 2015 17:14:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJpiu-0003RK-CE for help-gnu-emacs@gnu.org; Mon, 27 Jul 2015 17:14:15 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:36864) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJpiu-0003RB-57 for help-gnu-emacs@gnu.org; Mon, 27 Jul 2015 17:14:12 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 75A8D8F2003 for ; Mon, 27 Jul 2015 23:14:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 68XtcG4aey0y for ; Mon, 27 Jul 2015 23:14:00 +0200 (CEST) Original-Received: from localhost (unknown [109.232.24.146]) by mail.mojserwer.eu (Postfix) with ESMTPSA id DB6948F2002 for ; Mon, 27 Jul 2015 23:13:59 +0200 (CEST) In-reply-to: <87pp3hyaxb.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106038 Archived-At: On 2015-07-24, at 14:53, Michael Heerdegen wrote: > Marcin Borkowski writes: > >> ,---- >> | (my-mode) >> | (make-local-variable 'isearch-mode-map) >> | (define-key isearch-mode-map (kbd "") #'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: Thanks for your response! > 1. (kbd "") obviously doesn't return the key sequence you want. I > don't use `kbd'; I would just use [f3] instead. Something is strange here. (equal [f3] [f3]) => t (equal [f3] [F3]) => nil (equal (kbd "") [f3]) => t (equal (kbd "") (kbd "")) => nil (equal (kbd "") [F3]) => t (kbd "") => [f3] (kbd "") => [F3] (kbd "") => [S-f3] (kbd "") => [S-F3] (equal [S-f3] [F3]) => nil So, what is [F3] exactly and how it differs from [f3]? > 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. Do I get it right that I should be careful to execute those lines exactly once per each buffer in my-mode? Is there any reason to put in in the hook and not in the command which will create that buffer and enter that mode? > Regards, > > Michael. TIA, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University