[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ignoring comments and/or strings (in source files) by _any_ search funct

From: Peter Tury
Subject: ignoring comments and/or strings (in source files) by _any_ search function?
Date: Mon, 25 Jun 2007 11:18:28 -0000
User-agent: G2/1.0


I am working on a simple major mode for a specific programming
language. I found that I need a variant of more and more (now: two
:-)) search functions (e.g. re-search-backward, skip-chars-backward)
what ignore comments and/or strings.

Do you know about a general implementation for this problem? Now I
think it can be solved only with macros (nicely with the loop
facility?), and I'll try to create it, but don't want to reinvent the
wheel (especially because I am new to macros ;-).

The idea is to have a function/macro (let's call it `ignore-comm-str')

1. calls any (search) function with proper parameters (received as
&rest arguments) and then:

2. if resulted (found) point is inside a comment/string, then repeat

Ignoring comments or strings should be driven by parameters (e.g.
ignore-comm-p, ...?). It seems to be logical to require
`font-lock-mode' and proper syntax settings for comments and strings:
then `syntax-ppss' can be used.

I think about something like this:

(defun ignore-comm-str fun str &optional ignore-comm ignore-str &rest

Then it could be called e.g. like
(ignore-comm-str #'re-search-backward "a-nice-re" nil t 100 t) or
(ignore-comm-str #'skip-chars-backward "a-string" t).

I could simply implement this as a function if I would know how to
R to FUN? (I know only macro's `,@' -- is there an equivalent for

Could this be solved with advices somehow? (I don't want generally
"redefine" those search functions: instead I would like to have a
comment/string-ignoring variant of them: an ancestor in OO terms...)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]