From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: how to deal with comment in a new lang mode
Date: Thu, 30 Oct 2008 20:46:27 -0600 [thread overview]
Message-ID: <gedrhq$q2v$1@ger.gmane.org> (raw)
In-Reply-To: <def05b7c-6b78-416c-a5a6-2593516b4cba@r36g2000prf.googlegroups.com>
Xah wrote:
> 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.
I can't address your question, but I can suggest a minor simplification
of your current implementation:
(defun xlsl-comment-dwim (arg)
(interactive "*P")
(let ((comment-start "// ")
(comment-end ""))
(comment-dwim arg)))
This is also has the advantage of restoring the original binding of
the comment-start and comment-end variables, even if comment-dwim
signals an error.
Hope that helps,
--
Kevin Rodgers
Denver, Colorado, USA
next prev parent reply other threads:[~2008-10-31 2:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-30 20:59 how to deal with comment in a new lang mode Xah
2008-10-31 2:46 ` Kevin Rodgers [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='gedrhq$q2v$1@ger.gmane.org' \
--to=kevin.d.rodgers@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.