From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: Question about cl-flet and cl-letf Date: Sun, 29 Oct 2023 07:19:40 +0100 Message-ID: References: <87pm11aw56.fsf@web.de> <87msw2gu99.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="oJbP6Iy3hT3RThD2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8254"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 29 07:20:34 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qwzA1-0001tx-Uc for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 29 Oct 2023 07:20:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwz9L-0007Zl-4g; Sun, 29 Oct 2023 02:19:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwz9J-0007Z6-8g for help-gnu-emacs@gnu.org; Sun, 29 Oct 2023 02:19:49 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwz9G-0004Sa-Qr for help-gnu-emacs@gnu.org; Sun, 29 Oct 2023 02:19:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+iymAPRnyNFQmtOez41s7DFNt4qd8J4yRKz6ucTWQZQ=; b=E/DbCALRwOq4BNReqDrwNZEZDd eCFLqGKfcbc6PPgq0n4bcQg6cm05NbYqxO7mzDOPC6jX+kIg0EaZrq2IH+GNI/RwQt9uw4piJkfnH RTDXY1HF3uJWcbwbxZIDqLN4OMgMVDma2LqXpVtkboMx6TOMTjjwP5ANh7icAXqxCYKsFONOX9DFR yg3nNQkf9AWG5wZdWiV+T4Z5J/2vWaKqnPzZXM3QwtdiqXxLRt3jnnOtdtQLp5V0+bAvrGn22S46c R6sh5WeUVW+ZkZjgafXr7aRRzWYMc7ue3fMQ/N8PFtUeERGzZIrzDS1Gw/t3pmkHWi68VhrZZIdS7 tZlDV0Hg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1qwz9A-00038z-S5 for help-gnu-emacs@gnu.org; Sun, 29 Oct 2023 07:19:42 +0100 Content-Disposition: inline In-Reply-To: <87msw2gu99.fsf@web.de> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145412 Archived-At: --oJbP6Iy3hT3RThD2 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Oct 29, 2023 at 02:14:10AM +0200, Michael Heerdegen wrote: > Arash Esbati writes: >=20 > > Michael Heerdegen writes: > > > > > No - they very different. `cl-flet' creates lexical bindings. Your > > > `cl-letf' call OTOH temporarily changes the function binding of the > > > symbol `y-or-n-p' - which more or less gives you dynamical binding. > > > > Thanks for your response. I basically want to temporarily make > > `y-or-n-p' act like `always'; and from what I read in the docstrings, > > both version should work, but `cl-flet' does not. Are the bindings > > relevant in this case? >=20 > Yes. Please read about scoping rules: >=20 > (info "(elisp) Variable Scoping") >=20 > the analogue rules apply for function bindings. >=20 > When the call of `y-or-n-p' does not occur textually inside the > `cl-flet' form, it will not be affected by a lexical function binding. It can be confusing. Look at it this way: y-or-no-p is most probably not called directly in your (while ...) construct (which is a special form) but from some functions called from there. So it's not in your lexical environment, but on somewhere else's. So a dynamic binding does the trick. Cheers --=20 t --oJbP6Iy3hT3RThD2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZT35dAAKCRAFyCz1etHa RrZaAJ9gf7Xiwzhpos1//IK7O6y48jaIgwCbBAQ6UlEaZMXlkYja7flLfdkyv9I= =Lebc -----END PGP SIGNATURE----- --oJbP6Iy3hT3RThD2--