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: Mon, 08 Feb 2016 04:22:55 +0000 Message-ID: References: <87a8ne2k6v.fsf@web.de> <87si145aru.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 1454905402 2523 80.91.229.3 (8 Feb 2016 04:23:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Feb 2016 04:23:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 08 05:23:22 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 1aSdM9-0003qd-8F for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Feb 2016 05:23:21 +0100 Original-Received: from localhost ([::1]:41023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSdM8-0005rX-DO for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Feb 2016 23:23:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSdLw-0005rH-OZ for help-gnu-emacs@gnu.org; Sun, 07 Feb 2016 23:23:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSdLv-0000sB-4R for help-gnu-emacs@gnu.org; Sun, 07 Feb 2016 23:23:08 -0500 Original-Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:34197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSdLu-0000s2-Ti for help-gnu-emacs@gnu.org; Sun, 07 Feb 2016 23:23:07 -0500 Original-Received: by mail-ob0-x22a.google.com with SMTP id wb13so139631655obb.1 for ; Sun, 07 Feb 2016 20:23:05 -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=GBYe+itXxmHBSR9gNDtW2h5clfvQxsfXmrTMM55Hao4=; b=TmCOed1CHZ9W4gTgB7E7pRrlYHMoaYxbvMbxTrBm+Y+RcfCohA6ODyydsFt4catrhC VVg/g8xllbb6ZL0keH4BY/joBK5kQeJAlT/fIh9gaHPzpewE+5L4KdD+l30gsU/ehnLM nsDDOd41DuQ5jex464RpXirZ9c2trXi1kiBBysDGpjncW3K2gUKLNJIJw1/6n7XWnTjJ N+IPSm7z691MdZDnzo4+DNCgzNQmwZXfq2ouotTTVLvzn8YkRCiaNV2/pxnyaHEa0TOz Z+BbeFaXoG/3bSx3hRAJ++ToKiAdeYasFSghc6qdbhnB9ZGqovMAcLIcHiEa8JoHHVts Er7g== 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=GBYe+itXxmHBSR9gNDtW2h5clfvQxsfXmrTMM55Hao4=; b=QAgvcV82xweXe14iDPAQuVfZIjOm63VpuBy7RQQ6ITWCjlSpxIcYGR7sfsf0laxPcG jWfxdVetJe8nbTicDu1s3ZAF21lsTv4H9Sl+wVPh3SbxZ/Yo60MOT4uRgtOjk2I9Oovy yz88/AgybYnEYbg1uE3Qy9CrTnMsPk1mJqoiDk/BgqmKmFTheEhRtpKUjdvsVKZsvKaD 3xPLcGUxVWaLcfW1Dt1gCxEfQPv6nnpoQZXM/Hx7n6RiPyCHB36swiXS/yqFK/OpDf0Y /2AzBwh/7usn9SZ2moX2g8xecczElEJsXUgntX6IeBr0Q5RkJkmslKb3Qdl49hOp+Qgb yGcw== X-Gm-Message-State: AG10YOQRmqoTJ1HZO4bDocAClF4ZHV/bK5RqSisD9iLi/vhMYX4k76zSX0yRAy49jQZa9OA+92mav2VtPkxI/Q== X-Received: by 10.60.60.3 with SMTP id d3mr21959553oer.24.1454905385121; Sun, 07 Feb 2016 20:23:05 -0800 (PST) In-Reply-To: <87si145aru.fsf@debian.uxu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c01::22a 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:109043 Archived-At: On Sun, Feb 7, 2016 at 7:03 PM Emanuel Berg wrote: > Anyway, another interesting difference, where I'm not > sure what is the best way, is > > `mark-active', then (mark) and (point) > > vs. > > (use-region-p), then (region-beginning) and (region-help) > > What does "the book" say on this? That's a good question. At times, I use mark-active and at times, (use-region-p). In this particular case, I used mark-active because (mark) being nil was what bit me in my first version of advising indent-region. I believe, using either would be fine here. > That file is 871 lines. Surely all that isn't how you > solved this particular problem and that alone. I am sorry, I did not follow that. The link I pasted was to a particular commit in my config, highlighting only 46 lines pertaining to this advice definition. On a PC, clicking that link should show you that highlighted section of 46 lines in a browser like Chrome/Firefox. > So why not yank it into a Gnus message buffer and fire > it away here as well? I simply find it convenient to read code on github with monospace fonts and syntax highlighting. I use a wonderful package called git-link to quickly get permalinks to my code snippets on github. >> John Mastro > My preference is for something a bit simpler, which avoids the use of > macros. Macros can be awesome, but IMO they don't contribute much here. I like the message telling me exactly what happened i.e. I indented the whole buffer or I eval'ed the whole buffer. But I can understand that that does not give much value. My initial purpose to use macro here was to learn how to use a macro. I like to grow my config with new styles and snippets of elisp. Just one important thing I'd like to point out in my code is the necessity to modify the orig-fn args ONLY when args is nil. This is to protect from corrupting the args when the advised fn is called by a wrapper fn. E.g. we do not want to override all 4 args to eval-region (set by eval-defun) with just 2 args when eval-region is being called by eval-defun. Finally, thank you all for taking time to go through my code and providing your feedback. Kaushal