Starting with Emacs 21, a module called 'newcomment , which has different comment styles (see the variable 'comment-styles . 'comment-styles close to what you want:
(setq comment-style 'multi-line)
(Note: you should probably make this setting in the 'c-mode-hook ).
However, none of the settings makes the comments look like what you want.
The easiest way I've seen to get what you want is to add this 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) ?\ ))))))
The current settings for comment-style always the prefix of the comment line "*" (if not all "/ *").
If you don't have Emacs 21, I suppose you could just download newcomment.el from the repository. I don't know if it works in previous versions of Emacs, but it might be worth it if Emacs improved the solution.
My hack breaks the 'uncomment-region . The correct fix would be to change the 'comment-padright . This will require a little more research so as not to disturb other things. The aforementioned hacked mode changes the behavior in 'c-mode (adjust the condition to your liking).
Trey jackson
source share