From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Iterating/Finding all Comment- and String-Regions Date: Fri, 18 Dec 2009 08:00:31 -0800 Message-ID: <5CAA4A13C00E4A97B1728518CBE09BDA@us.oracle.com> References: <2d31ae05-8ff5-4225-8cc2-57e95e1ebea0@d21g2000yqn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1261152374 8240 80.91.229.12 (18 Dec 2009 16:06:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Dec 2009 16:06:14 +0000 (UTC) To: "=?iso-8859-1?Q?'Nordl=F6w'?=" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 18 17:06:07 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NLfL3-0003E2-0E for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Dec 2009 17:05:57 +0100 Original-Received: from localhost ([127.0.0.1]:54761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLfL2-0007GH-VR for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Dec 2009 11:05:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NLfGI-00043k-TM for help-gnu-emacs@gnu.org; Fri, 18 Dec 2009 11:01:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NLfGE-0003vm-By for help-gnu-emacs@gnu.org; Fri, 18 Dec 2009 11:01:02 -0500 Original-Received: from [199.232.76.173] (port=60426 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLfGD-0003vQ-R4 for help-gnu-emacs@gnu.org; Fri, 18 Dec 2009 11:00:57 -0500 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:57311) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NLfGD-0001Hy-CB for help-gnu-emacs@gnu.org; Fri, 18 Dec 2009 11:00:57 -0500 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet12.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id nBIG0qr0015730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Dec 2009 16:00:54 GMT Original-Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id nBIFofOB019296; Fri, 18 Dec 2009 16:01:20 GMT Original-Received: from abhmt007.oracle.com by acsmt353.oracle.com with ESMTP id 1110732521261152033; Fri, 18 Dec 2009 08:00:33 -0800 Original-Received: from dradamslap1 (/141.144.161.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 18 Dec 2009 08:00:32 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <2d31ae05-8ff5-4225-8cc2-57e95e1ebea0@d21g2000yqn.googlegroups.com> Thread-Index: Acp/HwxE09LWtIM0ThGEovtjdLhDXAA2Ypog X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Auth-Type: Internal IP X-Source-IP: acsinet15.oracle.com [141.146.126.227] X-CT-RefId: str=0001.0A090204.4B2BA737.001F:SCFMA922111,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70734 Archived-At: > 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