[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
how to deal with comment in a new lang mode
From: |
Xah |
Subject: |
how to deal with comment in a new lang mode |
Date: |
Thu, 30 Oct 2008 13:59:50 -0700 (PDT) |
User-agent: |
G2/1.0 |
when writing a new language mode, how can one make comment-dwim work?
i can of course code my own functions dealing with comments, but i
think it is better to use the facilities provided in newcomment.el?
right now i have:
(defun xlsl-comment-dwim (arg)
(interactive "*P")
(let ((comment-start-orig comment-start)
(comment-end-orig comment-end))
(setq comment-start "// ")
(setq comment-end "")
(comment-dwim arg)
(setq comment-start comment-start-orig)
(setq comment-end comment-end-orig)
))
and
(define-key xlsl-mode-map [remap comment-dwim] 'xlsl-comment-dwim)
this works fine when typing the shortcut for comment-dwim on a empty
line to insert comment. But doesnt work as expected when the line is
already a comment. (it does nothing)
any advice apprecated for dealing with comments in a new lang mode.
Thanks.
PS if it matters, i also have my syntax table defined:
(defvar xlsl-mode-syntax-table
(let ((synTable (make-syntax-table)))
(modify-syntax-entry ?\/ ". 12b" synTable)
(modify-syntax-entry ?\n "> b" synTable)
(modify-syntax-entry ?< "()" synTable)
(modify-syntax-entry ?> ")(" synTable)
synTable
)
"Syntax table for `xlsl-mode'."
)
The lsl has “// ...” as comment but not “/* ... */”. I dont want it to
be derived mode of c-mode though atm ...
Xah
∑ http://xahlee.org/
☄
- how to deal with comment in a new lang mode,
Xah <=