help-gnu-emacs
[Top][All Lists]
Advanced

[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 03:31:35 +0000

On Fri, Feb 5, 2016 at 7:30 PM Emanuel Berg <embe8573@student.uu.se> wrote:

> Advices are always tricky. Instead I'd do something
> like this:
>
>     (defun indent-region-dwim ()
>       (interactive)
>       (if mark-active
>           (indent-region (mark) (point))
>         (indent-region (point-min) (point-max) )))
>
> And then rebind shortcuts, or use this method:
>
>     (define-key (current-global-map) [remap w3m-quit]
> #'no-confirm-w3m-quit)
>

Thanks Emanuel.

What you suggested was my plan B and that's what I have executed now. I
have taken your idea to create a generic "region or whole" function
generator.

https://github.com/kaushalmodi/.emacs.d/blob/b013406a864de46f0fb479e339b04945f8f01351/setup-files/setup-editing.el#L686-L716


To all, I am still curious to know if it is possible to achieve the same
using nadvice. If not, then is it an advice limitation that we cannot
override the nature of interactive function arguments? In this case, looks
like we cannot call indent-region with nil args even though we have an
advice designed to set those args automatically to non-nil values.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]