all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* identifiing strings and comments in program source files (to skip them over)
@ 2006-04-26  6:38 martin rudalics
  0 siblings, 0 replies; 7+ messages in thread
From: martin rudalics @ 2006-04-26  6:38 UTC (permalink / raw)
  Cc: help-gnu-emacs

 > Hi,
 >
 > isn't it a good idea to use the face property (get-text-property (point)
 > 'face) to decide if the point is after a string or comment?
 >
 > I have a mode what uses font-lock-mode and highlights everything nicely.

Font-lock support modes like jit-lock try to avoid assigning faces to
parts of a buffer that are not displayed.  Hence, a default Emacs
usually does not highlight everything nicely.

 > I
 > think I could use this (= the face set by font-lock-mode) for identifiing
 > if e.g. a search stopped in a string or comment. (I know font-lock-mode
 > must be enabled for this.) This way I could omit reparsing the buffer (with
 > parse-partial-sexp) e.g. in a function what searches something "real" (=
 > strings and comments should be skipped).
 >
 > What do you think: can a robust solution be built using this approach?

Not really.  Fontification is synchronized with redisplay.  Determining
whether a search stopped in a string or comment, on the other hand,
should work independently of whether redisplay happened.  In particular,
contextual fontification - the thing you see happening when you insert a
single double-quote in an elisp buffer - occurs by default not earlier
than .5 seconds after you inserted the double-quote - so your search
would have to wait until that has been done.  Deferred fontification and
syntax-table properties get things more complicated even.

You could explicitly fontify the area you want to search through, but
this might require fontifying the entire buffer and thus would not
provide any advantage: After all font-lock would have to reparse the
entire buffer for this purpose.  To check whether searching stopped in a
comment or string you could parse from `beginning-of-defun' or something
similar instead - `syntax-ppss' does that.

^ permalink raw reply	[flat|nested] 7+ messages in thread
* identifiing strings and comments in program source files (to skip them over)
@ 2006-04-25 21:14 Peter Tury
  2006-04-26  3:53 ` Thien-Thi Nguyen
  2006-04-26  6:01 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Tury @ 2006-04-25 21:14 UTC (permalink / raw)


Hi,

isn't it a good idea to use the face property (get-text-property (point)
'face) to decide if the point is after a string or comment?

I have a mode what uses font-lock-mode and highlights everything nicely. I
think I could use this (= the face set by font-lock-mode) for identifiing
if e.g. a search stopped in a string or comment. (I know font-lock-mode
must be enabled for this.) This way I could omit reparsing the buffer (with
parse-partial-sexp) e.g. in a function what searches something "real" (=
strings and comments should be skipped).

What do you think: can a robust solution be built using this approach?

Thanks,
P

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

end of thread, other threads:[~2006-04-26 19:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.964.1146057880.9609.help-gnu-emacs@gnu.org>
2006-04-26 19:05 ` identifiing strings and comments in program source files (to skip them over) Peter Tury
2006-04-26  6:38 martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2006-04-25 21:14 Peter Tury
2006-04-26  3:53 ` Thien-Thi Nguyen
2006-04-26  8:04   ` Peter Tury
2006-04-26  6:01 ` Stefan Monnier
2006-04-26  8:06   ` Peter Tury

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.