From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: override comment-or-uncomment-region gives an error
Date: Thu, 30 May 2013 07:54:51 +0200 [thread overview]
Message-ID: <51A6E9AB.5000507@easy-emacs.de> (raw)
In-Reply-To: <CAEjRLuRSmbeBUCTWjbpkNHqnRZ=GtZxyYWh6SiNOuVfCpbRGzg@mail.gmail.com>
Am 30.05.2013 04:05, schrieb ishi soichi:
> I am trying to override the existing function,
> comment-or-uncommnent-region like
>
> (defun comment-or-uncomment-region ()
> (interactive)
> (cond ((equal major-mode 'web-mode)
> (web-mode-comment-or-uncomment))
> (t
> (comment-or-uncomment-region))))
>
> When using web-mode, the commenting function is different. So I need
> something like this.
>
> It works for web-mode case, but it raises an error for any other modes,
>
> cond: Lisp nesting exceeds `max-lisp-eval-depth'
>
> Does anyone see why?
>
> soichi
>
Defadvice is an an option. Personally, I'd redefine
comment-or-uncomment-region like that
(defun comment-or-uncomment-region (beg end &optional arg)
"Call `comment-region', unless the region only consists of comments,
in which case call `uncomment-region'. If a prefix arg is given, it
is passed on to the respective function."
(interactive "*r\nP")
(comment-normalize-vars)
(cond ((equal major-mode 'web-mode)
MY_NEEDED_FUNCALL
(t
(funcall (if (comment-only-p beg end)
'uncomment-region 'comment-region)
beg end arg))
;;;;;;
Redefining seems preferable WRT debugging/edebug
Andreas
next prev parent reply other threads:[~2013-05-30 5:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 2:05 override comment-or-uncomment-region gives an error ishi soichi
2013-05-30 2:47 ` Drew Adams
2013-05-30 3:21 ` ishi soichi
2013-05-30 5:54 ` Andreas Röhler [this message]
2013-05-30 14:50 ` Stefan Monnier
2013-06-04 3:04 ` ishi soichi
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51A6E9AB.5000507@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--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.
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).