在GNU Emacs中,有一种很好的方法可以在C模式下更改comment-region命令
/* This is a comment which extends */ /* over more than one line in C. */
至
/* This is a comment which extends over more than one line in C. */
? 我试过了
(setq comment-multi-line t)
但这没有用。 在Emacs手册中有一个关于多行注释的部分 ,但它没有提到任何内容。
从Emacs 21开始,有一个名为'newcomment
的模块,它有不同的注释样式(参见变量'comment-styles
。这个设置接近你想要的:
(setq comment-style 'multi-line)
(注意:您应该在'c-mode-hook
进行设置)。
但是,没有任何设置使评论看起来像您想要的。
我看到得到你想要的最简单的方法是添加这个hack:
(defadvice comment-region-internal (before comment-region-internal-hack-ccs activate) "override 4th argument to be just spaces" (when (eq major-mode 'c-mode) ; some condition here (let ((arg (ad-get-arg 4))) (when arg (ad-set-arg 4 (make-string (length arg) ? ))))))
comment-style
的当前设置始终在注释行前面加上“*”(如果不是整个“/ *”)。
如果你没有Emacs 21,我想你可以直接从存储库下载newcomment.el
。 我不知道它是否在早期版本的Emacs中按原样运行,但它可能值得一试,尽管升级Emacs将是一个更好的解决方案。
我的黑客打破了'uncomment-region
。 一个正确的解决方法是改变'comment-padright
。 这需要更多的研究,以免打破其他事情。 上述hack只会改变'c-mode
行为(根据自己的喜好调整条件)。
我可以找到内置的评论支持,如果你将comment-style
设置为multi-line
,这将产生以下结果:
/* This is a comment which extends * over more than one line in C. */
如果距离不够近,请查看newcomment.el
并根据需要定义自己的注释函数。
以上就是c/c++开发分享C模式下的Emacs注释区域相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/545606.html