From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.help Subject: Re: Help setting nadvice for indent-region Date: Sat, 06 Feb 2016 03:31:35 +0000 Message-ID: References: <878u2yof32.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1454729521 8832 80.91.229.3 (6 Feb 2016 03:32:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Feb 2016 03:32:01 +0000 (UTC) To: Help Gnu Emacs mailing list , embe8573@student.uu.se Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 06 04:32:00 2016 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 1aRtbL-0005Pd-3X for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Feb 2016 04:31:59 +0100 Original-Received: from localhost ([::1]:51442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRtbK-0007Xp-C8 for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Feb 2016 22:31:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRtb9-0007Xg-H3 for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 22:31:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRtb8-0006k8-G5 for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 22:31:47 -0500 Original-Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:34065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRtb8-0006k3-8r for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 22:31:46 -0500 Original-Received: by mail-wm0-x22c.google.com with SMTP id 128so93492646wmz.1 for ; Fri, 05 Feb 2016 19:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=IU+zvBmH/6ZQmYQM/z/W1HHz179H+JZHNIpTB4Vn/gw=; b=NNZPwiX6JKaSaQFbwGjWIeh/UEKFOvJ7fZ/DigRAY0RBloSGxOyxD9Kp9m7bCmrYIH Tl9x24XSQ4Cv04ILt4PoGQPVH2qDc4RHKyivfNt08qYiOLYr+K60WCXx65fH+po4WDrb SQf46z01DbYgbHJKb/FzGvqtQqrPvrtg81uhi+jrpAxY9epmx3bwJP+MLoYZD8zQz2cJ F5DvAK3hrhknsPSj81Qy4O375pK6Cw22fIcZWlK1k4u1VHpNfAz2lKzrZsll9/GZlzqj i3/Ir+dscPuRnSXKczNHSjRWkth+kf6LHIS8OdveuvJBh1LPUb5XA4OtBV4otfUhtamX /XLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type; bh=IU+zvBmH/6ZQmYQM/z/W1HHz179H+JZHNIpTB4Vn/gw=; b=XTNCh8yPwzZFy9eAc95gKmfduHou4UYqNIuFhVVgwL9jdCv/QbZ8qxAPJZpjb6rMqt f6bjMuV+UjumT5Nx28zBJOqASiir+AnPSpDiuayhsYbL7TaW1NXVMSeo/JdpNudX/yW+ VylWICqlXY+BYYG5MYTHA1TvVfw0lvp5pKb7xEV7X8/qOf3TgpietWZexkcH4XJ7j6HR 427RXNR9jLkMBxmsY2vsO/iluCqFAu/QkUfnuZkJQCB5MLQP2ELCM1qX7aGAfzKOzGhf 3NVWiHq/NFuPZ3Z4WqEvFna185OdlGj6bhBhtLqWZcdXdqy4hYW3nsd19m6mA+hxDPTi nNlQ== X-Gm-Message-State: AG10YOS7lqJEkhvLtpdkCWv+IMTgxH0O0s6rRcyjeoCzETPFWBm4WOq8h+UMXLnkLd7Zbrpxb1p6nhSkuEi38g== X-Received: by 10.28.61.70 with SMTP id k67mr19852284wma.90.1454729505462; Fri, 05 Feb 2016 19:31:45 -0800 (PST) In-Reply-To: <878u2yof32.fsf@debian.uxu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22c X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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:109031 Archived-At: On Fri, Feb 5, 2016 at 7:30 PM Emanuel Berg wrote: > Advices are always tricky. Instead I'd do something > like this: > > (defun indent-region-dwim () > (interactive) > (if mark-active > (indent-region (mark) (point)) > (indent-region (point-min) (point-max) ))) > > And then rebind shortcuts, or use this method: > > (define-key (current-global-map) [remap w3m-quit] > #'no-confirm-w3m-quit) > Thanks Emanuel. What you suggested was my plan B and that's what I have executed now. I have taken your idea to create a generic "region or whole" function generator. https://github.com/kaushalmodi/.emacs.d/blob/b013406a864de46f0fb479e339b04945f8f01351/setup-files/setup-editing.el#L686-L716 To all, I am still curious to know if it is possible to achieve the same using nadvice. If not, then is it an advice limitation that we cannot override the nature of interactive function arguments? In this case, looks like we cannot call indent-region with nil args even though we have an advice designed to set those args automatically to non-nil values.