From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.devel Subject: How to get a fixed search string into the editable area of an isearch. Date: Tue, 31 May 2016 15:13:40 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113e15d675df6c0534282d63 X-Trace: ger.gmane.org 1464722203 3877 80.91.229.3 (31 May 2016 19:16:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 31 May 2016 19:16:43 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 31 21:16:38 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 1b7p9X-0004BD-Lv for ged-emacs-devel@m.gmane.org; Tue, 31 May 2016 21:16:36 +0200 Original-Received: from localhost ([::1]:38048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p9R-0005iN-QG for ged-emacs-devel@m.gmane.org; Tue, 31 May 2016 15:16:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p7D-0004QP-HQ for emacs-devel@gnu.org; Tue, 31 May 2016 15:14:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7p7C-0002FD-6n for emacs-devel@gnu.org; Tue, 31 May 2016 15:14:11 -0400 Original-Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:34291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p7C-0002F7-24 for emacs-devel@gnu.org; Tue, 31 May 2016 15:14:10 -0400 Original-Received: by mail-oi0-x235.google.com with SMTP id e72so34039031oib.1 for ; Tue, 31 May 2016 12:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=N6AMGLBjyvvRNXVeORnlnzvMQa3R7Moae431nophCb4=; b=lF+uVFsrp6n3K4cg/m/3REjYX9TvY6pvHhfZ/q7gNDI9JOjkBxfmC6lGGcQTgd9/bC 5udqzrppVxVfL2Qgw9sVsv4/pQR1zyXhhZolHi8UlK/yOGqPePMkURESuU51mU8c1qfb nVN6HtKNJ70M+fpo39wwqs3skW49/7j8G5V9vRhZBKpxDpZJbu41raJ/Rx4mRHGDDX6P GbpeJ51QVMaj78Ou4HSRnF1w3rYLEqXJ2WyQUkjTncTOk384xSOxgxxlFqAb4NHslCfQ I81yThAqrp9Susn/rZeJiB9gimNo3aUUkX4vH4oPQCgIm7n1FVQvmsvRdxUFWxOL3ryP VHDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=N6AMGLBjyvvRNXVeORnlnzvMQa3R7Moae431nophCb4=; b=QrWyABJDsxWqK5ZvlQf/usbtRUhUVd8sl6l8DnUpErEYUn2Nj2Z9dq5h1BF5xmVVmP Gi4IulJFnSLIXmJQQOue9RFevdKk4iUPOgrozk7CMOMUDcYZezydggKUJAgBLnVKf+Iu GwrgHik8aBA+WV0tFcrGqmDNUPT/pzRe2VALXM0mDBtDc3FyCtyamvlAR5+yJoDsmhnR /6ZhO+BBtXBLZjDx6ZebbHa7gz1lx9YuoE2k2bfKC/mqQo1f40g0H3Wq9SooSJAhB7E1 rxT75AP0hcIpnDYXMdT7WmGcoEilFUtk4bpzFmgzXQUtHy7j18j66qMtwemi5GNDuL7g gVJw== X-Gm-Message-State: ALyK8tK4doA+GnzoIHyDu46L4eP2U2GkQr0TGpDTbqeEckI79q3fYuA1YhidqCLQdGUi6jfiBsP7MBWOyq7GYw== X-Received: by 10.157.17.98 with SMTP id p31mr37042otp.70.1464722049587; Tue, 31 May 2016 12:14:09 -0700 (PDT) Original-Received: by 10.202.205.17 with HTTP; Tue, 31 May 2016 12:13:40 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::235 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:204161 Archived-At: --001a113e15d675df6c0534282d63 Content-Type: text/plain; charset=UTF-8 Hi: 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))) --001a113e15d675df6c0534282d63 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi:

I have a need for a comm= and that starts an isearch with a specific string in the editable area that= I can add and subtract characters from interactively during the search.=C2= =A0 I have things working with the following code except the string does no= t appear in the editable area even though the search is done for the fixed = string.=C2=A0 Can anyone solve this?=C2=A0 I couldn't get any of the is= earch-yank-* commands to do the right thing here either.=C2=A0 Please help.= =C2=A0 Thanks.

It would be much simpler if the use= r-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.=C2=A0 One might think setting isearch-string= would do something similar.

(defun isearch-for-st= ring ()
=C2=A0 "Interactively search forward for next occurr= ence of a fixed string.
Then add characters to further narrow the= search."
=C2=A0 (interactive)
=C2=A0 (let* ((matc= h-str "fixed-string")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(isearch-mode-hook
= =C2=A0(append '((lambda () (interactive) (setq isearch-string = match-str))
= =C2=A0 =C2=A0isearch-mode-hook))))
=C2=A0 =C2=A0 (if (not (equal = match-str (car search-ring)))
(isearch-update-ring match-str nil))
=C2=A0 =C2= =A0 (isearch-forward)))
--001a113e15d675df6c0534282d63--