我收到了一个关于C Comment in Emacs - Linux Kernel Style的回复,它工作得很好,但是

当emacs注释(comment-dwim)时,它用空格填充第二个* long_function_name_vari和最后一个*/行(在注释之前),而不是像我配置的那样使用制表符。如何避免这种情况?
使用这种风格进行评论有多容易?
/* void main()
* {
* int i;
* int b;
* printf("format string");
* }
*/发布于 2016-01-13 18:55:16
可自定义变量comment-style在newcomment.el中定义,说明...
(extra-line t nil t t
"One comment for all lines, end on a line by itself")..。
这应该会提供想要的结果IIUC。
然而,目前的实现是两个额外的行,到目前为止,开始的换行符还没有文档。请分别提交功能请求。docu-bug报告。
发布于 2016-01-14 09:59:53
嗯,在寻找newcomment.el之后,我可以理解如何调整这种行为。
(defun my-c-comment-dwim (tabify delete-trailing)
(interactive)
(let (beg end)
(if (region-active-p)
(progn
(setq beg (region-beginning)
end (region-end))
(if (comment-only-p beg end)
(uncomment-region beg end)
(progn
(comment-region beg end)
(when (equal comment-style 'extra-line)
(save-excursion
(goto-char end)
(forward-line 2)
(setq end (line-end-position))))
(when tabify
(tabify beg end))
(when delete-trailing
(delete-trailing-whitespace beg end)))))
(comment-indent))))
(global-set-key [remap comment-dwim] (lambda ()
(interactive)
(my-c-comment-dwim t t)))https://stackoverflow.com/questions/34710840
复制相似问题