From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: How to shadow a function temporarily? (flet and cl-flet) Date: Mon, 27 Jan 2014 18:59:14 +0400 Message-ID: <87eh3tsc71.fsf@gmail.com> References: <87k3dm4yv4.fsf@gmail.com> <8761p64kcj.fsf@gmail.com> <87iot6rmpq.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1390834780 6395 80.91.229.3 (27 Jan 2014 14:59:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jan 2014 14:59:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 27 15:59:47 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W7nf9-00069P-Jo for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Jan 2014 15:59:47 +0100 Original-Received: from localhost ([::1]:60012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7nf8-00051B-Q5 for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Jan 2014 09:59:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7nep-0004wb-Sg for help-gnu-emacs@gnu.org; Mon, 27 Jan 2014 09:59:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7neh-0001a3-FB for help-gnu-emacs@gnu.org; Mon, 27 Jan 2014 09:59:27 -0500 Original-Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:33811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7neh-0001Zs-7f for help-gnu-emacs@gnu.org; Mon, 27 Jan 2014 09:59:19 -0500 Original-Received: by mail-lb0-f179.google.com with SMTP id l4so4594421lbv.10 for ; Mon, 27 Jan 2014 06:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=1RRa9BkHGR24vueoc5KcBODrCdjJ/nQizJJX6s096l4=; b=qGmS3xT1i//bKKMhIRmh11W0I64zwN3R1wfINVCns9tUztmtLyFrL5CtYkUWCmGbZT ZzSK2N7yI+KcE5WTTNJFs9te7aJHbEkKHv86KnRbKxlMbVk/FaBrbcuvESPU19TVnrjX vdh2lr9TzC+LNOQdoh/9V1qu3sV6TqhYfo6FsuNw8GpeLJs+dQQEciXcI/YoD4kVeoZv h7phXYyLNcUyE5akzCkw8zr7zruAmLx2YX0gYFSmRh7BmGqHmR3peqHFZ9phUj6E2F5e AHEe4Z6ThLER5WkIoUKvcSXw4DVe2O6dlH9u7DLxel9PN+jKsPrtxtFi+U0tSrr2RFdt h26g== X-Received: by 10.152.28.200 with SMTP id d8mr57437lah.59.1390834757014; Mon, 27 Jan 2014 06:59:17 -0800 (PST) Original-Received: from leviafan (128-70-204-126.broadband.corbina.ru. [128.70.204.126]) by mx.google.com with ESMTPSA id e6sm12534287lbs.3.2014.01.27.06.59.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jan 2014 06:59:16 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Mon, 27 Jan 2014 08:40:42 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::233 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95694 Archived-At: 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.