Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Comments on newcomment.el especially comment-insert-comment-function()

17 views
Skip to first unread message

Nordlöw

unread,
Oct 20, 2008, 8:32:48 AM10/20/08
to
Hey there!

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)

Nordlöw

unread,
Oct 20, 2008, 8:44:41 AM10/20/08
to

Is there a more flexible way of changing the behaviour of comment-
dwim() in specific modes in specfic code contexts?

/Nordlöw

0 new messages