[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: override comment-or-uncomment-region gives an error
From: |
Andreas Röhler |
Subject: |
Re: override comment-or-uncomment-region gives an error |
Date: |
Thu, 30 May 2013 07:54:51 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
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