From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexander Shukaev Newsgroups: gmane.emacs.devel Subject: Isearch: add variable to control search match group Date: Tue, 25 Aug 2015 01:55:12 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1440460535 29417 80.91.229.3 (24 Aug 2015 23:55:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Aug 2015 23:55:35 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 25 01:55:30 2015 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 1ZU1aL-00066g-Iz for ged-emacs-devel@m.gmane.org; Tue, 25 Aug 2015 01:55:29 +0200 Original-Received: from localhost ([::1]:57267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU1aK-0007CD-SU for ged-emacs-devel@m.gmane.org; Mon, 24 Aug 2015 19:55:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU1a6-0007C4-Bi for emacs-devel@gnu.org; Mon, 24 Aug 2015 19:55:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZU1a5-0006ga-CN for emacs-devel@gnu.org; Mon, 24 Aug 2015 19:55:14 -0400 Original-Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]:33369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZU1a5-0006gV-5W for emacs-devel@gnu.org; Mon, 24 Aug 2015 19:55:13 -0400 Original-Received: by lalv9 with SMTP id v9so87581190lal.0 for ; Mon, 24 Aug 2015 16:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=iVRrEB88WlEZTy4zYXgSjpMMfSkmOX+iqFufxX8b2iI=; b=MO2xdk9wzM/FC+pPR9JfI41G47UYwkKclGxxQdMpVEh5gDYVHKjsD4ryAOAnFusBFk RKR7GcqpcmdjHuQRLLj0F1nahwP0w1Ti+G7ExpwenbH14TzsprMWsa3F0hdUfYcPgauy AkLyfrXaEYEdy3XWrfOzel6xJtpac6ew4nydJTCyTHFIr7f1FwzFRa/uipNrYPtj4fX9 Yaeo5fnbsNlV7+zCVFJyjR50i6D3oR8KRXc4xlc6KbxUxR28U5xDCb8wBwNT66blzaad r4T2S9B73BnPJA3FdIBVKJo/ddMebW9kreGYrjroJGUHgvqVKuOOiYUkqy7BM+GELT13 Snsg== X-Received: by 10.112.159.226 with SMTP id xf2mr22164842lbb.74.1440460512230; Mon, 24 Aug 2015 16:55:12 -0700 (PDT) Original-Received: by 10.112.34.17 with HTTP; Mon, 24 Aug 2015 16:55:12 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:189137 Archived-At: Hello, would it be reasonable to add (defcustom isearch-regexp-group 0 "Number used to match concrete group in search pattern." :group 'isearch :type 'number) and substitute all the calls to `(match-beginning 0)' and `(match-end 0)' with `(match-beginning (or isearch-regexp-group 0))' and `(match-end (or isearch-regexp-group 0))' accordingly in 'isearch.el'? For instance, I develop my own search module on top of Isearch currently, and I really have problem with the fact that the choice of group 0 is hard-coded in Isearch. Let me give you a simple example, where this makes things stiff. Note, though, that the following example (and the corresponding change above) are meant for programmatic use of Isearch in the first place (rather than interactive one). Imagine that my search module wants to search for \(^\|\s-+?\)(;;)\($\|\s-+?\) and I am actually only interested in the "(;;)" part since I also want to highlight it (with both, current match highlighting and all matches lazy highlighting). Then, clearly, "\(^\|\s-+?\)" and "\($\|\s-+?\)" are just anchors. Also, note that I deliberately chosen non-word constituent to prevent any speculations on the usage of "\<" and "\>" for this example. Now, since Emacs does not have Vim-like "\zs" and "\ze" to control beginning and end of match respectively on the one hand, and does not have something like (hypothetical, but very welcome too) "\sb", which would essentially stand for "space boundary" (i.e. do for spaces what "\<" and "\>" do for words) on the other hand (in which case I would simply transform the original search RE into \(^\|\sb\)(;;)\($\|\sb\) and be done with it), I have no choice, but to use something like this \(^\|\s-+?\)\(?1:(;;)\)\($\|\s-+?\) and then extract exactly the 1st group from it. Unfortunately, Isearch internally does not support that at all. Will it be possible to follow my suggestion and/or maybe somebody has better ideas? Regards, Alexander