From: John Mastro <john.b.mastro@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
Kaushal Modi <kaushal.modi@gmail.com>
Subject: Re: Help setting nadvice for indent-region
Date: Sun, 7 Feb 2016 10:51:29 -0800 [thread overview]
Message-ID: <CAOj2CQSm6om5nJm+Tf2p1-E93CMdOM4ghxOon8RVZ5Cai4f9jA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY3Pw4NEa_3=pp5kQTbTTzd6B_qN=CxhSO+juMoPar6OhQ@mail.gmail.com>
Kaushal Modi <kaushal.modi@gmail.com> wrote:
> For the sake of completeness, this is how I actually needed to implement
> this advice in my config:
> https://github.com/kaushalmodi/.emacs.d/blob/1f9daf3587863de8561fc34e0bafda80be389dbf/setup-files/setup-editing.el#L686-L731
>
> I am open to comments and criticism.
>
> Thanks!
My preference is for something a bit simpler, which avoids the use of
macros. Macros can be awesome, but IMO they don't contribute much here.
The downside to my solution is that it doesn't print the "Executed... on
the whole buffer" message, since the advice function never sees the
symbol that names the adviced function. It has access to ‘orig’, of
course, but that may be something that wouldn't print well (e.g. a
compiled Lisp function). However, I don't see that as critical.
(defvar modi/region-or-whole-fns '(indent-region eval-region))
(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))
--
john
next prev parent reply other threads:[~2016-02-07 18:51 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 23:49 Help setting nadvice for indent-region Kaushal Modi
2016-02-05 23:58 ` Kaushal Modi
2016-02-06 0:00 ` Kaushal Modi
2016-02-06 0:30 ` Emanuel Berg
2016-02-06 3:31 ` Kaushal Modi
2016-02-06 10:43 ` Michael Heerdegen
2016-02-07 3:12 ` Kaushal Modi
2016-02-07 17:46 ` Kaushal Modi
2016-02-07 18:51 ` John Mastro [this message]
2016-02-08 0:03 ` Emanuel Berg
2016-02-08 4:22 ` Kaushal Modi
2016-02-08 17:05 ` Eli Zaretskii
2016-02-08 17:27 ` Kaushal Modi
2016-02-09 3:07 ` Emanuel Berg
2016-02-08 20:03 ` John Mastro
2016-02-08 23:13 ` Emanuel Berg
2016-02-11 14:02 ` Stefan Monnier
2016-02-11 17:36 ` Kaushal Modi
2016-02-11 18:10 ` Michael Heerdegen
2016-02-11 18:47 ` Kaushal Modi
2016-02-11 18:56 ` Kaushal Modi
2016-02-11 19:14 ` Michael Heerdegen
2016-02-11 20:15 ` Kaushal Modi
2016-02-11 20:38 ` Kaushal Modi
2016-02-12 14:09 ` Michael Heerdegen
2016-02-12 14:21 ` Michael Heerdegen
2016-02-12 16:02 ` Kaushal Modi
2016-02-12 19:04 ` Michael Heerdegen
2016-02-12 13:57 ` Michael Heerdegen
2016-02-11 19:03 ` Michael Heerdegen
2016-02-07 23:48 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOj2CQSm6om5nJm+Tf2p1-E93CMdOM4ghxOon8RVZ5Cai4f9jA@mail.gmail.com \
--to=john.b.mastro@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=kaushal.modi@gmail.com \
--cc=michael_heerdegen@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).