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: Fri, 05 Feb 2016 23:58:14 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1454716723 23874 80.91.229.3 (5 Feb 2016 23:58:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Feb 2016 23:58:43 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 06 00:58:42 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 1aRqGu-00067a-NX for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Feb 2016 00:58:40 +0100 Original-Received: from localhost ([::1]:50930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqGq-0004mU-SW for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Feb 2016 18:58:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqGf-0004mP-SO for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:58:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRqGe-0004IY-QZ for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:58:25 -0500 Original-Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:35660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqGe-0004IU-JF for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 18:58:24 -0500 Original-Received: by mail-oi0-x22c.google.com with SMTP id s2so51607720oie.2 for ; Fri, 05 Feb 2016 15:58:24 -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=CwCoSGPBqVH6XeNgwF8bnaY9tOINtsNTm7sNdncMRtM=; b=aS1JT81/t168n3CueZDuze7qoIcA3kKf64Gv6ZXEVpoDymjuefQ78gz0hMQWokTsVe 509mt6ldt1J5O0FkPZZPk0KSQx2Z9g9PjYURsiJVhBCgch+hPUEobPj591SBzYxyusBo T2UgaNtMMr9rQfYXwsvSEAZFbaWvpobEdL4xduxzSzBVyUWOgNotHAGNq4p6qcwITC7s GQSQQOsWIxBQC4NmDbwi5u+qN0SdVEOF/JHj+vZhnDZ+juglQh2OBiD3ZckEX49X/ne1 qEYQllpNXYAM+OumAtHfnRl2Q5hMM0A2lIw5aQbLRlaHpEIxva3EjCQ5+ci+hN4Tzx5V NhOQ== 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=CwCoSGPBqVH6XeNgwF8bnaY9tOINtsNTm7sNdncMRtM=; b=C1twgzBK7XLGUimhkiWm/dDwZR4CqQg0XPlnuBK0hcqOqMpf+6TVgFQEfSSVTh26oo ZqqldnralgJSOm6wtWQXIKcrwq162LcumT3ImbMu6j6ScX1aFIIzNluMeiW9Kecxlou6 2qe7ShsoegIX/DKLpdOAcPM/q38W3ovB//TOzUDNtb45plKvWepTlHIV+AOs0c7WD/qK YsDx98sr2yi1+ykyU/TQsGySK7uwzoKle6MzoV1Cgam5R+iHoF4QTWSq0sV95ZPjsUEg ygAvXAlPxBWvvdepzdCytluvxS5c/Kw6jIbpVSp9EVBjgLsYxu45TYbocSnSQTnh0JOq J7Cw== X-Gm-Message-State: AG10YORzj2RYnMtpvd2v6vp6o1dfbTqFIY7QfA2gjksMwTqY2SvM+syjmktur/80L214Pasu96f+4W4WsXkKSw== X-Received: by 10.202.75.13 with SMTP id y13mr10224523oia.116.1454716703882; Fri, 05 Feb 2016 15:58:23 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::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:109026 Archived-At: Aha.. looks like the check_mark in callint.c is raising the error even before the advice sets the args as the call_interactively's 'r' case is activated. That's because indent-region has (interactive "r\nP"). So looks like I'll need to advice the whole interactive? What would be a better solution? On Fri, Feb 5, 2016 at 6:49 PM Kaushal Modi wrote: > Hi, > > I'd like to advice indent-region so that if a region is not select, it > indents between (point-min) and (point-max). > > So I have this: > > ===== > > (defun adv/indent-region (args) > (when (not mark-active) > (setq args (list (point-min) (point-max)))) > args) > (advice-add 'indent-region :filter-args #'adv/indent-region) > > ===== > > This usually works, unless I have just launched a fresh buffer in which > there is no mark set. > > If I do M-: (mark) in that buffer, I get nil. > In that case, if I call M-x indent-region (with no region selected), I get > this error backtrace: > > Debugger entered--Lisp error: (error "The mark is not set now, so there is > no region") > call-interactively(indent-region nil nil) > command-execute(indent-region) > > If it looks like the error is triggered by call-interactively even before > the advice gets to do its thing. > > How can I resolve this using nadvice? > > Thanks. > > Kaushal Modi >