unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to deal with comment in a new lang mode
@ 2008-10-30 20:59 Xah
  2008-10-31  2:46 ` Kevin Rodgers
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Xah @ 2008-10-30 20:59 UTC (permalink / raw)
  To: help-gnu-emacs

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/^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-11-03 15:02 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-30 20:59 how to deal with comment in a new lang mode Xah
2008-10-31  2:46 ` Kevin Rodgers
2008-10-31 14:10 ` rgb
     [not found] ` <mailman.2542.1225421198.25473.help-gnu-emacs@gnu.org>
2008-10-31 20:04   ` Xah
2008-11-01 12:53     ` Rupert Swarbrick
2008-11-01 13:47     ` Kevin Rodgers
     [not found]     ` <mailman.2630.1225547412.25473.help-gnu-emacs@gnu.org>
2008-11-01 14:41       ` Xah
2008-11-01 15:24         ` Andreas Politz
2008-11-01 20:55           ` Xah
2008-11-01 21:23             ` Andreas Politz
2008-11-01 21:48               ` Xah
2008-11-01 18:59         ` Rupert Swarbrick
2008-11-03 14:08     ` rgb
2008-11-03 14:19     ` rgb
2008-11-03 15:02       ` Seweryn Kokot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).