From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: flet is obsolete, but... Date: Thu, 11 Oct 2012 16:55:22 +0200 Organization: Sebastien Vauban Message-ID: <80y5jdkqhx.fsf@somewhere.org> References: <804nm2zekk.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1349967617 8939 80.91.229.3 (11 Oct 2012 15:00:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2012 15:00:17 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Thu Oct 11 17:00:24 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 1TMKFM-0004gG-21 for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Oct 2012 17:00:24 +0200 Original-Received: from localhost ([::1]:60648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMKFC-0001Fo-FB for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Oct 2012 11:00:14 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!storethat.news.telefonica.de!telefonica.de!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Injection-Info: mx04.eternal-september.org; posting-host="368fa3c7dc5c1bbe516391bd65bd1ab2"; logging-data="26247"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX19PMn86hDEui4LCDRmBQnIa" User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:R21svckzpN9WBXvPx5vFLLR1xTM= sha1:Ua+wkKeOHFhkSCI8JmYIB22rsNg= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:194844 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.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-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:87177 Archived-At: Hello all, Barry Margolin wrote: > In article <804nm2zekk.fsf-oHC15RC7JGTNLxjTenLetw@public.gmane.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)) Thanks for your answers. It helped a lot, even if the above is still a bit cryptic to me. And, yes, I thought that the replacement was purely a syntaxical exchange of words... Best regards, Seb -- Sebastien Vauban