all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: 'Nordlöw' <per.nordlow@gmail.com>, help-gnu-emacs@gnu.org
Subject: RE: Iterating/Finding all Comment- and String-Regions
Date: Fri, 18 Dec 2009 08:00:31 -0800	[thread overview]
Message-ID: <5CAA4A13C00E4A97B1728518CBE09BDA@us.oracle.com> (raw)
In-Reply-To: <2d31ae05-8ff5-4225-8cc2-57e95e1ebea0@d21g2000yqn.googlegroups.com>

> How can I find iterate over all the comment- and string-regions (BEG
> END) in a buffer using the mode-specific syntax?

Consider taking advantage of font-locking. Look for text property `face' with
the particular face(s) you want - e.g. `font-lock-comment-face',
`font-lock-string-face', or `font-lock-doc-face'. This approach lets font-lock
do the work of parsing the mode-specific syntax. All you need to do is gather up
and treat the pieces of text that have the text property you want.

Since you use Icicles, take a look, Per, at function
`icicle-search-char-property-scan'. It does just that: iterates over the
occurrences of a given character property (i.e. a text or overlay property),
such as `face', that have a given value, such as `font-lock-comment-face'. Each
occurrence is a region such as you described.

It is used by the Icicles commands (`icicle-search-text-property',
`icicle-search-overlay-property', and `icicle-search-char-property') that let
you search for (regexp) matches among such occurrences only. It is the function
that builds the list of such occurrences as a set of completions, which are then
filtered interactively by your minibuffer input.
http://www.emacswiki.org/emacs/Icicles_-_Other_Search_Commands#toc2#SearchingTex
tProperties





  parent reply	other threads:[~2009-12-18 16:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-17 12:51 Iterating/Finding all Comment- and String-Regions Nordlöw
2009-12-18 15:05 ` Andreas Röhler
2009-12-18 16:00 ` Drew Adams [this message]
2009-12-18 16:02 ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5CAA4A13C00E4A97B1728518CBE09BDA@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=per.nordlow@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.