开发者

Syntactic Information of an Emacs Buffer

I'm currently implementing Clustered Query-Replace in Emacs. 开发者_C百科Clustering should be sensitive to

  1. case,
  2. symbol and word context and
  3. whether hit is plain code, inside a comment or part of a string literal

The first two points are easy to make efficient. The last point requires an efficient way to extract all the mode-syntax-specific (syntax-table) comment- and string-regions of an Emacs buffer. I know of syntax-ppss but I want a faster way to get all regions. Is there a built-in function for that or do I have to manually search for each string and comment beginning-end pair. I don't want to depend on font-lock because that is too slow for my application.

Any ideas?


I think that 'skip-syntax-forward' does what you want.


If you have the CEDET tool suite available, you could use the lexical analyze that comes with the Semantic tool to do this work. All supported modes have a lexer, but these lexers usually ignore comments. Creating new lexical analyzers that just handle comments and strings isn't hard, and there is an example that does this for handling tag documentation in semantic-doc-snarf-comment-for-tag.

Whats nice about the lexical analyzer is it gives you a list of lexical tokens which you can filter through in a simple way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜