|
From: | Stefan Monnier |
Subject: | Re: Help setting nadvice for indent-region |
Date: | Thu, 11 Feb 2016 09:02:42 -0500 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> (defun modi/region-or-whole-advice (orig &rest _) > (interactive) > (if (use-region-p) > (funcall orig (region-beginning) (region-end)) > (funcall orig (point-min) (point-max)))) > (dolist (fn modi/region-or-whole-fns) > (advice-add fn :around #'modi/region-or-whole-advice)) This will affect all calls to these functions and is hence sure to cause some breakage somewhere. You want something more like: (defun modi/region-or-whole-advice (&rest _) (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) nil) (dolist (fn modi/region-or-whole-fns) (advice-add fn :before #'modi/region-or-whole-advice)) So you only modify the interactive spec (i.e. change the *command*'s behavior) without changing the *function*'s behavior. -- Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |