unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* ignoring comments and/or strings (in source files) by _any_ search function?
@ 2007-06-25 11:18 Peter Tury
  2007-06-25 14:12 ` Peter Tury
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Tury @ 2007-06-25 11:18 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

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')
what:

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
1...

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
r).

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
pass
R to FUN? (I know only macro's `,@' -- is there an equivalent for
functions?)

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...)

Thanks,
P

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-29 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-25 11:18 ignoring comments and/or strings (in source files) by _any_ search function? Peter Tury
2007-06-25 14:12 ` Peter Tury
2007-06-29 14:34   ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).