all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
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 18:59:14 +0400	[thread overview]
Message-ID: <87eh3tsc71.fsf@gmail.com> (raw)
In-Reply-To: <jwvmwihh7lv.fsf-monnier+gmane.emacs.help@gnu.org> (Stefan Monnier's message of "Mon, 27 Jan 2014 08:40:42 -0500")

Stefan Monnier (2014-01-27 17:40 +0400) wrote:

>> (defun macol-read-color (&optional prompt convert-to-RGB allow-empty-name msg)
>>   "Read a color name or RGB triplet.
>> Same as `read-color', but use `macol-foreground-color-at-point'
>> and `macol-background-color-at-point' instead of
>> `foreground-color-at-point' and `background-color-at-point'."
>>   (interactive "i\np\ni\np")
>>   (cl-letf (((symbol-function 'foreground-color-at-point)
>>              (symbol-function 'macol-foreground-color-at-point))
>>             ((symbol-function 'background-color-at-point)
>>              (symbol-function 'macol-background-color-at-point)))
>>     (read-color prompt convert-to-RGB allow-empty-name msg)))
>
> Now, if someone sees a problem in the behavior of
> background-color-at-point, he may try to Edebug
> background-color-at-point and won't understand why it's not called (or
> why it *is* called but the value it returns is the value that the caller
> receives, or ...).
>
> Or someone else may start writing code relying on that new behavior
> without realizing that it won't work in an Emacs that hasn't loaded this
> "macol" package.
>
> Of course, all that can happen as well with my `advice', but at least
> the function's docstring will give you a hint.  You can also more easily
> deactivate this behavior either by re-binding use-my-color-improvement
> to nil while `read-color' is in progress, or by deactivating this
> particular advice.

Thank you very much for the detailed description.  Now I understand the
point and am going to follow your advice about using advices.



  reply	other threads:[~2014-01-27 14:59 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
2014-01-27 13:40         ` Stefan Monnier
2014-01-27 14:59           ` Alex Kost [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh3tsc71.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.