I would like an interactive function that would comment-or-uncomment region using only the one-line comment syntax of the mode.
Currently, in PHP, when I comment out (using either comment-or-uncomment-region
or comment-dwim
)
This
Block of
Code
I get this:
/*
* This
* Block of
* Code
*/
But what I need is this:
// This
// Block of
// Code
I tried to (no, let me rephrase this: I spent nights trying every possible combination) use M-x customize-group RET comment
, specifically the variables comment-multi-line
and comment-style
but to no avail.
Note that when I edit Javascript, js-mode does exactly that. How can I get this behaviour in all modes?
Try this:
(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))
In Emacs 24.3 you can use the form (setq-local comment-start "//")
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With