From: martin rudalics <rudalics@gmx.at>
Cc: help-gnu-emacs@gnu.org
Subject: identifiing strings and comments in program source files (to skip them over)
Date: Wed, 26 Apr 2006 08:38:52 +0200 [thread overview]
Message-ID: <444F157C.8080409@gmx.at> (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.
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.
next reply other threads:[~2006-04-26 6:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-26 6:38 martin rudalics [this message]
[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
-- 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
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=444F157C.8080409@gmx.at \
--to=rudalics@gmx.at \
--cc=help-gnu-emacs@gnu.org \
/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.