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 00:00:12 +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 1454716837 25666 80.91.229.3 (6 Feb 2016 00:00:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Feb 2016 00:00:37 +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 01:00:36 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 1aRqIl-0000Uk-Vb for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Feb 2016 01:00:36 +0100 Original-Received: from localhost ([::1]:50943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqIl-0005s9-AV for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Feb 2016 19:00:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqIZ-0005rz-U2 for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 19:00:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRqIZ-0004po-1q for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 19:00:23 -0500 Original-Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:36094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqIY-0004pd-Qa for help-gnu-emacs@gnu.org; Fri, 05 Feb 2016 19:00:22 -0500 Original-Received: by mail-ob0-x22a.google.com with SMTP id ba1so102924487obb.3 for ; Fri, 05 Feb 2016 16:00:22 -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=/8jl266epopYNvZZfNn1LyqhVb00oAjr2svPaKR7jGg=; b=dGGWFV92aRQ4XzH+o4XvjzOVcR/C/ZUQ/QHI2qJiNdd7w+Ni6GtQJD4sBXn85TIyR9 kk1B2riCZteA1dQ7pWDUjm+Omj3wP/+ZdvcrHI+16RHcegyMjl6CHKGb08vF+g81vrW7 b8OLzg2xtae6xKDDorTCnUn1MHjhtW5rb+I9V83rIeF0RWZC5H9c0IPaNXlDhjltJ2yP dsQ5WburTMR3kOMX4fSHAiqqbJKHvROfjZgxQPhMalqRjtXZ0qTnyTzy+2exzAyaioIr pdSVCm8ssdfzZYwAYycys6IF9QU0lTMxjj8WYOQR1UpzMV8YXYP6LCd0QdrjhVzFxxnX htCw== 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=/8jl266epopYNvZZfNn1LyqhVb00oAjr2svPaKR7jGg=; b=cYNlUezCSfUqJDZ3BlKnczB2lnSiafTLI91uO3z4wV6rRsA8vXH63eGSXrhJ8kxH8I Ow5no1ExVj8HjYFK3y+mlQuhBse66n66tlxhtNBqQ8A9cI+j1uGT2G6kFoq8XQKVnGY1 PzImWoHhtPuBii+U6B0+MkxM35KnFUUVJHHfd96wufHw2d1JzENBswg4jwhXWbTvALkx MWmBf8AtQvYtHkhPsWB1hnnI17I1iVJxMCKb0XRle/68OLILkVU9H39p4GrmMafIQVrN zYOABcCwg7Xefrulp0k1uZ9e9m6POPiOBJelC/mXz8t8VD6Tmmqpo5yVbtqN1v2ABKw5 Fb8w== X-Gm-Message-State: AG10YOR4t2onlGYqbOLr+5yAOc01iezFqmQSUgSpuagQh20MRpBGrZo71krU2GDUfphcCHDRM8k2w/BWgEPasg== X-Received: by 10.60.57.134 with SMTP id i6mr14406338oeq.11.1454716822228; Fri, 05 Feb 2016 16:00:22 -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: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:109027 Archived-At: Neat, I hit a brick-wall there. Advising interactive gives: "advice--normalize: Advice impossible: interactive is a special form" On Fri, Feb 5, 2016 at 6:58 PM Kaushal Modi wrote: > 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 >> >