From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: flet is obsolete, but... Date: Wed, 10 Oct 2012 10:31:18 -0400 Organization: A noiseless patient Spider Message-ID: References: <804nm2zekk.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 X-Trace: ger.gmane.org 1349879717 12906 80.91.229.3 (10 Oct 2012 14:35:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Oct 2012 14:35:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 10 16:35:22 2012 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 1TLxNZ-0005An-SJ for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 16:35:21 +0200 Original-Received: from localhost ([::1]:35150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLxNT-0001N6-HZ for geh-help-gnu-emacs@m.gmane.org; Wed, 10 Oct 2012 10:35:15 -0400 Original-Received: by 10.180.73.134 with SMTP id l6mr1656259wiv.1.1349879479450; Wed, 10 Oct 2012 07:31:19 -0700 (PDT) Original-Path: usenet.stanford.edu!l8no34359761qao.0!news-out.google.com!q11ni134259492wiw.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!feeder.ecngs.de!ecngs!feeder2.ecngs.de!78.46.240.70.MISMATCH!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Injection-Info: barmar.motzarella.org; posting-host="78fb7125a45724f15e21604c94a7d968"; logging-data="9139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rRge4vVz57PX9tg50ZlBS" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:yqvV3HRFyWKobap55Ttt4+BhGYQ= Original-Xref: usenet.stanford.edu gnu.emacs.help:194821 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:87154 Archived-At: In article <804nm2zekk.fsf@somewhere.org>, "Sebastien Vauban" wrote: > Hello, > > `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'. > > But doing so in the following code: > > --8<---------------cut here---------------start------------->8--- > (defun my/revert-buffer () > "Unconditionally revert current buffer." > (interactive) > (flet ((yes-or-no-p (msg) t)) > (revert-buffer))) > --8<---------------cut here---------------end--------------->8--- > > does not lead to the right things: > > - use cl-flet, and the code doesn't behave as it should (i.e., it does ask for > a confirmation, before reverting)' cl-flet does lexical binding, not dynamic. > > - use cl-letf, and you've got an error: > cl-letf: `let' bindings can have only one value-form: yes-or-no-p, (msg), t > > What should I do? Sounds like you didn't write your cl-letf correctly. Did you read its documentation? It's not a drop-in replacement for flet, since it's more general than this (it's used to temporarily assign to any place that can be set with setf). (letf (((symbol-function 'yes-or-no-p) #'(lambda (msg) t))) (revert-buffer)) -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***