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 18:47:00 +0000 Message-ID: References: <87a8ne2k6v.fsf@web.de> <87bn7n15ki.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 1455216452 14407 80.91.229.3 (11 Feb 2016 18:47:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Feb 2016 18:47:32 +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 19:47:32 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 1aTwH5-00057R-9p for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Feb 2016 19:47:31 +0100 Original-Received: from localhost ([::1]:52635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTwH1-0003Pg-De for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Feb 2016 13:47:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTwGm-0003Og-0w for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 13:47:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTwGk-0005DZ-T5 for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 13:47:11 -0500 Original-Received: from mail-ob0-x232.google.com ([2607:f8b0:4003:c01::232]:33461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTwGk-0005DP-MJ for help-gnu-emacs@gnu.org; Thu, 11 Feb 2016 13:47:10 -0500 Original-Received: by mail-ob0-x232.google.com with SMTP id is5so86894005obc.0 for ; Thu, 11 Feb 2016 10:47:10 -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=3yCyjTM7OR/npTY9hfSq8wGcFyvHYkrENprNylFD9xY=; b=q9MG+WFawvN99WTJ0tq+OZGy1OeMx7vZ6NVGaB5ftXtkhdfBKDJKt+TYKJrIAGyzyd fT5VAmS4Ja4k+m4nkyTv/K5vki+f8REv9j7wX1mLTQomZhtUateCjsHr6N9NShWhO0pZ tzqK4jBOMWGMwZ0O/xikOnyZbL0R91a7YWgjgTWQcFR2SX7oek6rxOHYoq6cK20CbZIk W49GL5GAm0/rHIzfQ41uTD08VNuisxomxcS6n7YLeazUumA5UmtDLMi/Dgzbo3RIPaOf mqGtWGb93jpoj6mioeIAY3cpXHMjyVcj56SgIvY7T1IM+kofKb1XtcTaokMPKcME/RGO an+g== 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=3yCyjTM7OR/npTY9hfSq8wGcFyvHYkrENprNylFD9xY=; b=m3SB75KQE62WpJMAhhRS8bK6H3Cer3DB5Z3FkVyYafcPi6niQNmEpmd71eXfA5m/iz m5TiEmqcaYmRNvznoWbsJc4x2/tVo+hoxEfTRGM0GFvdH2Br+vCfyjsR++rNBvBxl0iQ JMFrCj725wy7BCfvXd7BReNKXjr7Nk2pqMh9SoqvAUcU3ieGrvuF4XsL8JKGP51GCvLK 64iV1KepimacBU7bj2Qf6mG+fxsttnaaAdGgBIX4Nw/V/LL/sKGBwGexeVaifg+TUhKa jYfMqsgoAGwjw3nF8aixiyApDXE0w3D8L+7x2mNaYTPmtzchFF0VrJHTjwe0pI1nh37K PGzQ== X-Gm-Message-State: AG10YOSHVj2DQjsuZo1rn5ui5GdUH6yenuXPJM0EsYiy/QLUVcTI2ctCQqXTl3+vNK2oZkD4d2ALLJm5zdvvHw== X-Received: by 10.60.135.98 with SMTP id pr2mr48752365oeb.65.1455216430102; Thu, 11 Feb 2016 10:47:10 -0800 (PST) In-Reply-To: <87bn7n15ki.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::232 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:109108 Archived-At: On Thu, Feb 11, 2016 at 1:10 PM Michael Heerdegen wrote: > > > I have just one concern.. that this will not work for advising > > functions like eval-defun. > > What exactly did you try to do? - `eval-defun' has only one argument > that is not related to the region, so the advises that were discussed > yet are not applicable here. In what way do you want to change the > behavior of `eval-defun'? > > Sorry, let me rephrase that. I meant to say that using Stefan's suggested method to advise eval-region also affected eval-defun. Without a region selected, if I did C-M-x with the point in a defun, this advice begin applied to eval-region would cause the whole buffer to be evaluated (not just that defun as I would expect C-M-x to do). That would adversely affect instrumenting edebug too (C-u C-M-x). > But in general, what Stefan pointed out was important: changing the > semantics of the functions is not a good idea. > > I agree but I did not find an alternative solution by which, - I apply the advice to eval-region when called interactively. - But not when it is called by a wrapper fn like eval-defun that presets the args for eval-region. I am open to adopt a cleaner, canonical solution. > > Be careful: this changes the return value of the advised function to the > value returned by `when' -- this is not `defadvice'! > > Point taken, I will fix that. > And BTW, (just a hint) you also don't need to `setq' the ARGS variable > (of course you can), just do > > (apply orig-fun (calculate-new-args-somehow-here-using-the args)) > > Agreed. As I need to set the let-bound variable msg's value too, based on (region-active-p), I decided to have just one (if ..) form and modify args and msg in there as appropriate. I really appreciate this feedback.