[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Structural regular expressions
From: |
Drew Adams |
Subject: |
RE: Structural regular expressions |
Date: |
Sun, 12 Sep 2010 14:31:44 -0700 |
> 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 ...))
- Re: Structural regular expressions, (continued)
- RE: Structural regular expressions, Drew Adams, 2010/09/11
- Re: Structural regular expressions, Richard Stallman, 2010/09/11
- Re: Structural regular expressions, Stefan Monnier, 2010/09/12
- Re: Structural regular expressions, Lennart Borgman, 2010/09/12
- RE: Structural regular expressions, Drew Adams, 2010/09/12
- Re: Structural regular expressions, Lennart Borgman, 2010/09/12
- RE: Structural regular expressions,
Drew Adams <=
- Re: Structural regular expressions, Tom, 2010/09/09
- Re: Structural regular expressions, Lennart Borgman, 2010/09/09
- Re: Structural regular expressions, Tom, 2010/09/09
- Re: Structural regular expressions, Lennart Borgman, 2010/09/09
- Re: Structural regular expressions, Tom, 2010/09/09
- Re: Structural regular expressions, Lennart Borgman, 2010/09/09
- Re: Structural regular expressions, Daniel Colascione, 2010/09/09
RE: Structural regular expressions, Drew Adams, 2010/09/07