From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: override comment-or-uncomment-region gives an error Date: Thu, 30 May 2013 07:54:51 +0200 Message-ID: <51A6E9AB.5000507@easy-emacs.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1369893148 22219 80.91.229.3 (30 May 2013 05:52:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 May 2013 05:52:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 30 07:52:27 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Uhvml-000114-HB for geh-help-gnu-emacs@m.gmane.org; Thu, 30 May 2013 07:52:27 +0200 Original-Received: from localhost ([::1]:52891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uhvml-0001aD-7B for geh-help-gnu-emacs@m.gmane.org; Thu, 30 May 2013 01:52:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhvmX-0001ZD-81 for help-gnu-emacs@gnu.org; Thu, 30 May 2013 01:52:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhvmS-0004Yf-Ik for help-gnu-emacs@gnu.org; Thu, 30 May 2013 01:52:13 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.9]:52677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhvmS-0004YF-9u for help-gnu-emacs@gnu.org; Thu, 30 May 2013 01:52:08 -0400 Original-Received: from [192.168.178.21] (brln-4db9f259.pool.mediaWays.net [77.185.242.89]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MVsSW-1UxEgo00pU-00XBr1; Thu, 30 May 2013 07:52:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 In-Reply-To: X-Provags-ID: V02:K0:FilhBHv1CbvVa2/OSXTQ4+MBvLtXeBFfg7fvyI8lxAr MYiQHMFBnkCeClTS2FvvKEXS5P5abo+UVwD+Ah0wuDirz2TmPZ yRMte0hUCVLkVmXxmViwTfhT/mDdyoQnLv2P9sGbql1yi59nsv Mf9wggfhW98cD8Wy8Ece4XSTMt8rNVB6E+jb69Pa7gLsn/ZEXr 2JhrTV7MqFQKOfMGyHoDqFF/+IbkTRorKY2AzHzRkderbGpqXc CutLrOM0tWqlfIiLBtkY84/AQAGTa98fwhCvTUjnD6CNSnCs+I VCX6KlR0CX70QohXVC0IHTucDN5OR+nXZc6SS3WiEWcMLtjQUi DuyaLooiSvSkBmS+PVsJqB0byiesWLF76EiY2B/aq X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.9 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91158 Archived-At: 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