I have written a context-sensitive variant of comment-insert(). It
handles C/C++ multi-line Doxygen comments for the cases given below.
But the fallback case has stopped working. I have looked into
newcomment.el and I discovered that comment-insert-comment-function()
is called also inside comment-indent() which explains the problem. But
according to the doc for comment-dwim() this function should only be
called when the line is empty. Is this a bug?
Thanks in advance,
Nordlöw
CODE FOLLOWS:
(defun c-insert-general-multiline-comment ()
"Insert Multi-line Comment for structures used in C/C++."
(interactive)
(if (or (looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<enum\\_>"))
(looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<typedef" "\
\s-+" "\\_<enum\\_>"))
(looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<struct\
\_>"))
(looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<typedef\
\_>" "\\s-+" "struct\\_>"))
(looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<typedef\
\_>" "\\s-+" "class\\_>"))
(looking-at (concat "\\(?:\\s-*\n\\)*\\s-*" "\\_<template\
\_>"))
)
(let ((descr (read-string "Brief Description: ")))
(delete-blank-lines)
(end-of-line) (forward-char)
(c-insert-general-doxygen-stub descr)
)))
(setq comment-insert-comment-function 'c-insert-general-multiline-
comment)
Is there a more flexible way of changing the behaviour of comment-
dwim() in specific modes in specfic code contexts?
/Nordlöw