[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help setting nadvice for indent-region
From: |
Kaushal Modi |
Subject: |
Re: Help setting nadvice for indent-region |
Date: |
Sat, 06 Feb 2016 00:00:12 +0000 |
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 <kaushal.modi@gmail.com> 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 <kaushal.modi@gmail.com>
> 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
>>
>
- Help setting nadvice for indent-region, Kaushal Modi, 2016/02/05
- Re: Help setting nadvice for indent-region, Kaushal Modi, 2016/02/05
- Re: Help setting nadvice for indent-region, Michael Heerdegen, 2016/02/06
- Re: Help setting nadvice for indent-region, Kaushal Modi, 2016/02/06
- Re: Help setting nadvice for indent-region, Kaushal Modi, 2016/02/07
- Re: Help setting nadvice for indent-region, John Mastro, 2016/02/07
- Re: Help setting nadvice for indent-region, Emanuel Berg, 2016/02/07
- Re: Help setting nadvice for indent-region, Kaushal Modi, 2016/02/07
- Re: Help setting nadvice for indent-region, Eli Zaretskii, 2016/02/08
- Re: Help setting nadvice for indent-region, Kaushal Modi, 2016/02/08