From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: "Drew Adams" <drew.adams@oracle.com>
Newsgroups: gmane.emacs.devel
Subject: RE: Structural regular expressions
Date: Sun, 12 Sep 2010 14:31:44 -0700
Message-ID: <535CCEC0CA104038A0B76A3BFE45B042@us.oracle.com>
References: <loom.20100907T212314-566@post.gmane.org>
	<AANLkTimYvE0aqrG-OQxuY6BTca7ngzrfQUa62mOxyV=+@mail.gmail.com>
	<loom.20100907T222143-475@post.gmane.org>
	<87sk1lt4uf.fsf@gmail.com> <jwvsk1kaav2.fsf-monnier+emacs@gnu.org>
	<pvhphbi0wq0d.fsf@gmx.li> <jwvlj7c9ura.fsf-monnier+emacs@gnu.org>
	<46875.130.55.118.19.1284065220.squirrel@webmail.lanl.gov>
	<AANLkTimUS7zL77TGiWoEdS+=nuww=TSABKMZuSiYPaCc@mail.gmail.com>
	<E1Ou5lY-0006Jj-MB@fencepost.gnu.org>
	<AANLkTi=dv8n40x-rTtz@mail.gmail.com>
	<loom.20100910T221237-941@post.gmane.org>
	<E1OuSKz-0004vv-Gp@fencepost.gnu.org>
	<jwvd3sjxekd.fsf-monnier+emacs@gnu.org>
	<AANLkTinyJbCULKZTWWV6_f3LtWdt-5FNjTD9PKP=0q3q@mail.gmail.com>
	<92D416E7775B4AEEA436B2D52124D533@us.oracle.com>
	<AANLkTimMskQhDC-YpJXA4kbotaVhwGs-hZJG8B_RsVV1@mail.gmail.com>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: dough.gmane.org 1284327150 26797 80.91.229.12 (12 Sep 2010 21:32:30 GMT)
X-Complaints-To: usenet@dough.gmane.org
NNTP-Posting-Date: Sun, 12 Sep 2010 21:32:30 +0000 (UTC)
Cc: 'Tom' <levelhalom@gmail.com>, emacs-devel@gnu.org,
	'Stefan Monnier' <monnier@iro.umontreal.ca>, rms@gnu.org
To: "'Lennart Borgman'" <lennart.borgman@gmail.com>
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 12 23:32:28 2010
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by lo.gmane.org with esmtp (Exim 4.69)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1Ouu9w-00070i-03
	for ged-emacs-devel@m.gmane.org; Sun, 12 Sep 2010 23:32:24 +0200
Original-Received: from localhost ([127.0.0.1]:53453 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1Ouu9v-0002nr-B2
	for ged-emacs-devel@m.gmane.org; Sun, 12 Sep 2010 17:32:23 -0400
Original-Received: from [140.186.70.92] (port=60494 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Ouu9p-0002nl-Aw
	for emacs-devel@gnu.org; Sun, 12 Sep 2010 17:32:18 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69)
	(envelope-from <drew.adams@oracle.com>) id 1Ouu9n-0002OL-Qa
	for emacs-devel@gnu.org; Sun, 12 Sep 2010 17:32:17 -0400
Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:63492)
	by eggs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <drew.adams@oracle.com>)
	id 1Ouu9m-0002O8-Gp; Sun, 12 Sep 2010 17:32:14 -0400
Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227])
	by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id
	o8CLWBNs025237
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Sun, 12 Sep 2010 21:32:12 GMT
Original-Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153])
	by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id
	o8CL7L90027367; Sun, 12 Sep 2010 21:32:10 GMT
Original-Received: from abhmt014.oracle.com by acsmt353.oracle.com
	with ESMTP id 598160301284327110; Sun, 12 Sep 2010 14:31:50 -0700
Original-Received: from dradamslap1 (/10.159.222.122)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Sun, 12 Sep 2010 14:31:49 -0700
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <AANLkTimMskQhDC-YpJXA4kbotaVhwGs-hZJG8B_RsVV1@mail.gmail.com>
Thread-Index: ActSnGtfSnK6uBTYSCalaD2pC+wGygAGJgdA
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.devel:130025
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/130025>

> It does not look to me like it I can search for org nodes containing
> both word a and word b with the progressive completion in Icicles. Can I?

I have no idea whether you can.  If you think something does not work as
documented, you can file an Icicles bug using `M-x icicle-send-bug-report',
being sure to provide a concrete recipe, preferably starting from `emacs -Q'.

But whenever input completion is available in Org mode you should be able to use
Icicles progressive completion.  (I do not use Org mode, myself.  I am convinced
that it is a Very Good Thing (TM), but I do not have any particular use for it.)

And as for search, yes, you can use progressive completion during Icicles
search.  You could, for example, (1) use a context regexp that defines the
search space to be the Org nodes (strings), and then (2) type your first word
`a', `S-SPC', and your second word `b', to narrow the search space to those Org
nodes that contain both words `a' and `b' (in either order).

It is up to you to come up with the regexp needed to do #1.  If for some reason
Org nodes cannot be selected using just a regexp (dunno), then you will need to
define a function that parses the buffer(s) and creates an alist of Org nodes
(buffer substrings and their positions).

How so?  You can use function `icicle-search' to define your own search command.
If you need something other than a regexp to parse your text into the set of
search contexts (e.g. Org nodes), then pass a parsing function as the second arg
to `icicle-search', `SCAN-FN-OR-REGEXP'.  The function needs to fill variable
`icicle-candidates-alist': Each alist entry has a search-context string as car
and the string end's buffer position as cdr.

For an example of a function that serves as arg `SCAN-FN-OR-REGEXP' see
`icicle-search-char-property-scan'.  It parses a buffer into the strings that
are determined by a text or overlay property (e.g. `face') with a given value
(e.g. `font-lock-string-face').

These are the `icicle-search' args (from the doc string):

---
(icicle-search BEG END SCAN-FN-OR-REGEXP REQUIRE-MATCH
               &optional WHERE &rest ARGS)

BEG is the beginning of the region to search; END is the end.
SCAN-FN-OR-REGEXP: Regexp or function that determines the set of
  initial candidates (match zones).  If a function, it is passed, as
  arguments, the buffer to search, the beginning and end of the search
  region in that buffer, and ARGS.
REQUIRE-MATCH is passed to `completing-read'.
Optional arg WHERE is a list of bookmarks, buffers, or files to be
  searched.  If nil, then search only the current buffer or region.
  (To search bookmarks you must also use library `bookmark+.el').
ARGS are arguments that are passed to function SCAN-FN-OR-REGEXP.

Note that if SCAN-FN-OR-REGEXP is a regexp string, then function
`icicle-search-regexp-scan' is used to determine the set of match
zones.  You can limit hits to regexp matches that also satisfy a
predicate, by using `(PREDICATE)' as ARGS: PREDICATE is then passed to
`icicle-search-regexp-scan' as its PREDICATE argument.
---

So if you have a simple regexp that selects the Org nodes, then just use command
`icicle-search' interactively (`C-c `'): type that regexp followed by `RET',
then `a S-SPC b'.  If the regexp is complex and you don't want to type it
interactively, then define a search command `foo' like this:

(defun foo ()
  (interactive)
  (icicle-search nil nil org-regexp t))

(defconst org-regexp "HAIRY-ORG-NODE-IDENTIFYING-REGEXP")

If you do not have such a regexp - e.g. Org-node parsing is too complex for a
regexp, then define a search command `foo' like this:

(defun foo ()
  (interactive)
  (icicle-search nil nil 'org-parser t))

(defun org-parser (buffer beg end)
  "Fill `icicle-candidates-alist' with Org nodes and their positions."
  ... ; Parsing magic
  (setq icicle-candidates-alist ...))