From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: BobD Newsgroups: gmane.emacs.help Subject: Re: Isearch - Incremental search with predefined initial character? Date: Wed, 8 Oct 2014 13:49:12 -0700 (PDT) Message-ID: References: <3732af9c-0454-431c-88c5-975f34971eee@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1412801427 951 80.91.229.3 (8 Oct 2014 20:50:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Oct 2014 20:50:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 08 22:50:21 2014 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 1XbyBf-0004j8-07 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2014 22:50:19 +0200 Original-Received: from localhost ([::1]:38488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbyBe-0000YR-FR for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Oct 2014 16:50:18 -0400 X-Received: by 10.66.221.73 with SMTP id qc9mr7745472pac.23.1412801352997; Wed, 08 Oct 2014 13:49:12 -0700 (PDT) X-Received: by 10.140.41.112 with SMTP id y103mr40768qgy.30.1412801352946; Wed, 08 Oct 2014 13:49:12 -0700 (PDT) Original-Path: usenet.stanford.edu!h18no3415474igc.0!news-out.google.com!q8ni67qal.1!nntp.google.com!dc16no1536505qab.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: <3732af9c-0454-431c-88c5-975f34971eee@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=96.61.77.108; posting-account=9hbhDwoAAABs5yR7ZnWiLXjb_7uCgBXB Original-NNTP-Posting-Host: 96.61.77.108 User-Agent: G2/1.0 Injection-Date: Wed, 08 Oct 2014 20:49:12 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:208068 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:100344 Archived-At: I want a conditional substitute for the normal isearch, depending on which key I use to start the search. Always using the same prefix is OK; I use "{". After fiddling a while, I came up with this, which does what I want. I bind [lwindow] to isearch-forward and isearch-repeat-forward. In the isearch-mode-hook function, I yank a "{" if [lwindow] started the search. ([lwindow] is the left-side Windows key on keyboards made for Windows.) (defvar my-prefix "{" "My Isearch prefix") ;My one-char prefix (defun rjd-prebrace () ;Function for isearch-mode-hook (if (equal (this-command-keys) [lwindow]) ;If invoked by [lwindow] (isearch-yank-string my-prefix) ; yank the prefix ) ) (add-hook 'isearch-mode-hook 'rjd-prebrace) ;Plant function in hook list (global-set-key [lwindow] 'isearch-forward) ;Plant key in maps (Only forward direction) (define-key isearch-mode-map [lwindow] 'isearch-repeat-forward) Thank you very much for your help. Pointing me at (isearch-yank-string ...) made this work. I wish to do this so that I can search for "{abc" without typing the "{" first. Typing something like "\C-s{abc" is exhausting.