From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: How to get a fixed search string into the editable area of an isearch. Date: Sun, 05 Jun 2016 00:46:49 +0300 Organization: LINKOV.NET Message-ID: <871t4cd58e.fsf@mail.linkov.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1465078155 20461 80.91.229.3 (4 Jun 2016 22:09:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Jun 2016 22:09:15 +0000 (UTC) Cc: emacs-devel To: Robert Weiner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 05 00:09:06 2016 Return-path: Envelope-to: ged-emacs-devel@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 1b9Jkg-0002xV-A4 for ged-emacs-devel@m.gmane.org; Sun, 05 Jun 2016 00:09:06 +0200 Original-Received: from localhost ([::1]:34340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9Jkf-0002cU-MW for ged-emacs-devel@m.gmane.org; Sat, 04 Jun 2016 18:09:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9JkZ-0002Xn-Ug for emacs-devel@gnu.org; Sat, 04 Jun 2016 18:09:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9JkW-0004hI-LR for emacs-devel@gnu.org; Sat, 04 Jun 2016 18:08:59 -0400 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:50947 helo=homiemail-a20.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9JkW-0004hC-FY for emacs-devel@gnu.org; Sat, 04 Jun 2016 18:08:56 -0400 Original-Received: from homiemail-a20.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTP id 20BF17EC064; Sat, 4 Jun 2016 15:08:51 -0700 (PDT) Original-Received: from localhost.linkov.net (82.131.11.136.cable.starman.ee [82.131.11.136]) (Authenticated sender: jurta@jurta.org) by homiemail-a20.g.dreamhost.com (Postfix) with ESMTPA id 44E2A7EC060; Sat, 4 Jun 2016 15:08:50 -0700 (PDT) In-Reply-To: (Robert Weiner's message of "Tue, 31 May 2016 15:13:40 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 69.163.253.7 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:204198 Archived-At: > I have a need for a command that starts an isearch with a specific string > in the editable area that I can add and subtract characters from > interactively during the search. I have things working with the following > code except the string does not appear in the editable area even though the > search is done for the fixed string. Can anyone solve this? I couldn't > get any of the isearch-yank-* commands to do the right thing here either. > Please help. Thanks. > > It would be much simpler if the user-level isearch commands like > isearch-forward could take a string/regexp as an argument and then jump > into the middle of a search as if the characters had been typed > interactively. One might think setting isearch-string would do something > similar. > > (defun isearch-for-string () > "Interactively search forward for next occurrence of a fixed string. > Then add characters to further narrow the search." > (interactive) > (let* ((match-str "fixed-string") > (isearch-mode-hook > (append '((lambda () (interactive) (setq isearch-string match-str)) > isearch-mode-hook)))) > (if (not (equal match-str (car search-ring))) > (isearch-update-ring match-str nil)) > (isearch-forward))) Maybe this is what you need? (defun isearch-for-string () (interactive) (isearch-forward nil 1) (isearch-yank-string "test"))