From: Alex Kost <alezost@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to shadow a function temporarily? (flet and cl-flet)
Date: Mon, 27 Jan 2014 09:57:21 +0400 [thread overview]
Message-ID: <87iot6rmpq.fsf@gmail.com> (raw)
In-Reply-To: <jwv8uu2jt7q.fsf-monnier+gmane.emacs.help@gnu.org> (Stefan Monnier's message of "Sun, 26 Jan 2014 17:08:00 -0500")
[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]
Stefan Monnier (2014-01-27 02:08 +0400) wrote:
> IIUC foreground-color-at-point and background-color-at-point don't
> suffer from the same problem as + when byte-compiled, so the above
> should work.
>
> But I'd recommend you use advice, which is cleaner (e.g. C-h f will
> make it clear that something's messing with the function):
>
> (defvar use-my-color-improvement nil)
>
> (defadvice foreground-color-at-point (around my-improvement activate)
> (if use-my-color-improvement
> (setq ad-return-value (my-foreground-color-at-point))
> ad-do-it))
>
> (defadvice background-color-at-point (around my-improvement activate)
> (if use-my-color-improvement
> (setq ad-return-value (my-background-color-at-point))
> ad-do-it))
>
> ...
> ...(let ((use-my-color-improvement t))
> (read-color prompt convert-to-RGB allow-empty-name msg))
> ...
>
> If that's for code within Emacs rather than a separate package, you'll
> want to use the new advice-add instead of defadvice, of course.
Thank you for the suggestion, but is it a normal practice to use advices
for packages? I use several advices in my own emacs config, but as a
user of an emacs package, I don't want to see that it advises some
functions.
I prefer the following (thanks to Barry Margolin):
[-- Attachment #2: Type: application/emacs-lisp, Size: 640 bytes --]
next prev parent reply other threads:[~2014-01-27 5:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-26 14:11 How to shadow a function temporarily? (flet and cl-flet) Alex Kost
2014-01-26 14:50 ` Stefan Monnier
2014-01-26 19:24 ` Alex Kost
2014-01-26 22:08 ` Stefan Monnier
2014-01-27 5:57 ` Alex Kost [this message]
2014-01-27 13:40 ` Stefan Monnier
2014-01-27 14:59 ` Alex Kost
2014-01-26 19:03 ` Marcin Borkowski
2014-01-26 19:31 ` Alex Kost
[not found] <mailman.12843.1390745495.10748.help-gnu-emacs@gnu.org>
2014-01-26 16:22 ` Emanuel Berg
2014-01-26 19:25 ` Alex Kost
2014-01-26 18:32 ` Emanuel Berg
2014-01-26 19:38 ` Alex Kost
2014-01-26 19:36 ` Barry Margolin
2014-01-26 19:45 ` Michael Heerdegen
2014-01-26 22:07 ` Alex Kost
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=87iot6rmpq.fsf@gmail.com \
--to=alezost@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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).