emacs lisp和c-mode:我什么时候在一个注释区域 [英] emacs lisp and c-mode: when am I in a comment region

查看:118
本文介绍了emacs lisp和c-mode:我什么时候在一个注释区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c / c ++缓冲区中搜索正则表达式,但是我想避免与注释区域匹配的表达式。有没有办法使用c模式来知道一堆文本是否在注释区域内(或点在注释区域内)?

I'd like to search for regular expressions within a c/c++ buffer, but I want to avoid expression matching a comment region. Is there a way using the c mode to know if a bunch of text is within a comment region (or a point is within a comment region)?

推荐答案

通过C / C ++和大多数主要模式,可以使用 syntax-ppss 来计算出来。例如。只有当您不在字符串或评论中时,(null(nth 8(syntax-ppss)))将不为零。

The way to figure that out is with syntax-ppss which works in C/C++ and most major modes. E.g. (null (nth 8 (syntax-ppss))) will be non-nil if and only if you're not within a string-or-comment.

这篇关于emacs lisp和c-mode:我什么时候在一个注释区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆