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: Thu, 11 Feb 2016 20:15:37 +0000 Message-ID: References: <87a8ne2k6v.fsf@web.de> <87bn7n15ki.fsf@web.de> <87vb5vys7n.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1455221761 4183 80.91.229.3 (11 Feb 2016 20:16:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Feb 2016 20:16:01 +0000 (UTC) To: Michael Heerdegen , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 11 21:16:01 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 1aTxej-00022C-4h for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Feb 2016 21:16:01 +0100 Original-Received: from localhost ([::1]:53246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTxeh-0002w3-UX for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Feb 2016 15:15:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTxeX-0002vb-AZ for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 15:15:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTxeW-0001jb-BW for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 15:15:49 -0500 Original-Received: from mail-ob0-x22b.google.com ([2607:f8b0:4003:c01::22b]:34666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTxeW-0001j8-3w for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 15:15:48 -0500 Original-Received: by mail-ob0-x22b.google.com with SMTP id wb13so91978361obb.1 for ; Thu, 11 Feb 2016 12:15:48 -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=oVwn/ypknKRIxGWDLF15cfSoVTZNzaPB5Lp39y9ruB4=; b=mlmt+9+ahwxliAw4JvdYD78Uq53RQomVR62IB9xfhzcdNBOTuWMzYYtx3eyv1b4DqD h3uQuUVqJ5fRah1t4VQv+9tgjELkxUKWGx/isox38Xn+St0VI8h3aShX91CqA9jvBwFO QZUAq5bUsQ/BMiLQQzhgLvyODF9xyn/cy1jK8t7qX1F5QQ5bxaf/rTWxggCQIFt5AE+6 LZAzsYxJyJhWLf61C7yC4e7GzYURRSPUbwCTSPcZXlVN9H+1ea0Mrsl4mSmPWoFqVcIi YiwipScw/tIvhkeA6TGq57u3+EHuZAlrxqr9m+cTAbnKrYHfPzEWrgpEZGuqoPAEPiTt H5MA== 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=oVwn/ypknKRIxGWDLF15cfSoVTZNzaPB5Lp39y9ruB4=; b=f913qSIEM4Lbsz8HhRNfSl6VeI342xsuGmgGVn494c8AZOmrbOB4xlQI0wQbyEjKmN BVlT/xVzlGlQNHt8jSj25q2pfrodZKoowssHI8/WXeHVdTQPbdJk+CRf2ofTCLFRX78T 3zpSMNu8gOd6fJHiva+Ch3Y46AY4+4X76aSPeT78yEyUOVc3ADzwK4pqbpfEiUiGfst7 Id0NRiRgseYHL8mNiDu1iWS/1TJFty4N3h49eeoBAMPCUx++3V5VC1dNVOl/Ng561cT7 nh06fU+twe4W6LJqJhztnaJ7NXb2HglgpP7q47B/Z63s4rQJy1cp6lU3q5e7ff5Dkffb WnIw== X-Gm-Message-State: AG10YORZkJN3QltwOAX+cajTKuIbLRJChZFJMcOlDws4TTask6yBGpEQJM86W+qtKN8tee6b/rmFMf4KtYIIUA== X-Received: by 10.182.137.198 with SMTP id qk6mr47455603obb.5.1455221747521; Thu, 11 Feb 2016 12:15:47 -0800 (PST) In-Reply-To: <87vb5vys7n.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c01::22b 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:109114 Archived-At: > I tried it, and can't reproduce what you describe. How did you try it (recipe)? You are right. I am not able to recreate that. I was actually getting confused because of this: (defun modi/advice-region-or-whole (&rest args) "Advice function that applies the ORIG-FN function to the whole buffer if a region is not selected." (interactive (if (use-region-p) ; when region is selected (list (region-beginning) (region-end)) (list (point-min) (point-max)))) (message "Args: %S use-region-p: %S" args (use-region-p)) (when (not (use-region-p)) (message "Executing %s on the whole buffer." (propertize (symbol-name this-command) 'face 'font-lock-function-name-face))) nil) Of course when I did C-M-x, (use-region-p) was nil and so it printed: "Executing eval-defun on the whole buffer." Things became clear after I added this debug statement: (message "Args: %S use-region-p: %S" args (use-region-p)) In any case, I will be going the right way of advising this as Stefan and you advised. Now I only need to figure out how not to print that message when doing eval-defun. > The around advice function should return the value you want the advised function to return. Thank you! So with a let-bound variable 'ret', I can have something like (setq ret (apply orig-fn args)) and return 'ret' at the end of the :around advice function definition. Right?