2013-12-20 58 views
6

我想要一个交互功能,可以评论或取消注释区域使用只有单行注释模式的语法。Emacs:每行一行注释

目前,PHP,当我注释掉(使用comment-or-uncomment-regioncomment-dwim

This 
Block of 
Code 

我得到这个:

/* 
* This 
* Block of 
* Code 
*/ 

但我需要的是这样的:

// This 
// Block of 
// Code 

我试过(不,让我换句话说:我花了很长时间尝试每一个可能的c组合)使用M-x customize-group RET comment,特别是变量comment-multi-linecomment-style,但无济于事。

需要注意的是,当我编辑的Javascript,JS-模式正是这么做的。我如何在全部模式下得到这种行为?

回答

4

试试这个:

(add-hook 'php-mode-hook 'my-php-mode-hook) 
(defun my-php-mode-hook() 
    (set (make-local-variable 'comment-start) "//") 
    (set (make-local-variable 'comment-padding) " ") 
    (set (make-local-variable 'comment-end) "") 
    (set (make-local-variable 'comment-style) 'indent)) 

在Emacs的24.3您可以使用的形式,而不是(setq-local comment-start "//")

+0

先生,你刚刚度过我的一天; +1用于新的'setq-local'语法。 – yPhil