From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31792: 27.0.50; Regression in #'labels, recent versions Date: Wed, 13 Jun 2018 23:24:50 -0400 Message-ID: <87muvyvym5.fsf@gmail.com> References: <5b1f.0188.5dc11.f21c@parhasard.net> <878t7kzyqs.fsf@gmail.com> <87k1r3y5m2.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1528946591 10059 195.159.176.226 (14 Jun 2018 03:23:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 14 Jun 2018 03:23:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Aidan Kehoe , 31792@debbugs.gnu.org, Alan Mackenzie To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 14 05:23:06 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fTIqn-0002SF-Nj for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jun 2018 05:23:05 +0200 Original-Received: from localhost ([::1]:37959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTIst-0001YW-Ac for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jun 2018 23:25:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTIsl-0001UY-Rv for bug-gnu-emacs@gnu.org; Wed, 13 Jun 2018 23:25:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTIsg-0007nY-PN for bug-gnu-emacs@gnu.org; Wed, 13 Jun 2018 23:25:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTIsg-0007nS-IB for bug-gnu-emacs@gnu.org; Wed, 13 Jun 2018 23:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fTIsg-0002kp-C5 for bug-gnu-emacs@gnu.org; Wed, 13 Jun 2018 23:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jun 2018 03:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31792 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 31792-submit@debbugs.gnu.org id=B31792.152894670110577 (code B ref 31792); Thu, 14 Jun 2018 03:25:02 +0000 Original-Received: (at 31792) by debbugs.gnu.org; 14 Jun 2018 03:25:01 +0000 Original-Received: from localhost ([127.0.0.1]:47133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fTIse-0002kX-VR for submit@debbugs.gnu.org; Wed, 13 Jun 2018 23:25:01 -0400 Original-Received: from mail-it0-f54.google.com ([209.85.214.54]:34783) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fTIsd-0002kK-9f for 31792@debbugs.gnu.org; Wed, 13 Jun 2018 23:24:59 -0400 Original-Received: by mail-it0-f54.google.com with SMTP id y127-v6so1218431itd.1 for <31792@debbugs.gnu.org>; Wed, 13 Jun 2018 20:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=3yQ9FrQWEnBCUw0ODA++6wcNHjKAsDjijVDnLGihh6M=; b=M4uG1hWaKrWBfC4RusnvOHIproab/AKkiQup5Cb8COt7RNlIveVHFovyDLAJosd2LO Jv05/B6FPZmAfGQ8PWdZ9hyFbY+epurtz5bcl0DdOCnEnssPLmu5Uq1GGb1gVAKabibQ M/rsBEvulsCdsGzbBjAFlDlB+MppnBxV7M2av8kwfoZcctJk0RHkkceDPZDbIfjhuCl7 qbpH8nkKYxGlKa+vY4groPkKCQfNvvb0KZ39lfZG/vVNjuxUIcVXeMWFciV5O5qdx3be q66+keaAm5ufyacuOiKXYv+oR4UHNCKVhN3X3UdV4FaS+YjKxrHB6NI20nzM4EXVLK0O SB+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=3yQ9FrQWEnBCUw0ODA++6wcNHjKAsDjijVDnLGihh6M=; b=UlBMRxTgSwn9aCo6/l21KjZG0rzKD94lf9/NEI7hyai/UcsdYoa/5GAeRPB+gZZXZJ Gjfun6EXI1Jz74/uSrHo90kI2j2cI+3uNNHXY6kOxhHO97XQPRiIElL8Qqcw1hQVNZ0K 4TlrIzKa5VsOvZTABtw56mmWGJYTCHmpHfsk4jrhB+ibSRkdHmOz8tDyFhGxtdZQ6ahb Zx1WooCdvJpcHcepj5BtZjGQEZNhbC8D8afaOGe6F7zBRqABCH35tCIo0r9+c+K+m/xV GrEBKa5jymH0uhXr4MkZWt8VX9TqxVlPtPCYmeFqKvu3NdQTSHHBdtMazOrgGc78eZCJ 8mgw== X-Gm-Message-State: APt69E2xiCfYfaaUHuMmyIoWl7fi0YS8FUKdDJgEnX9KrPJscTBmub4C K7FVTvj/UoLh7AKW1TQ4jAA= X-Google-Smtp-Source: ADUXVKIUy2qffryr02OwMmx/i7kKxMiXAiw1BfDkkr2ujqXMUZar7vHHTZZOymqSqXSCp4eWOWju0g== X-Received: by 2002:a24:2e58:: with SMTP id i85-v6mr685683ita.114.1528946693781; Wed, 13 Jun 2018 20:24:53 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id c102-v6sm526296itd.3.2018.06.13.20.24.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 20:24:52 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Wed, 13 Jun 2018 09:16:01 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147394 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > Looks good, but please add a comment before the call to macroexpand-all > reminding that lexical-let installs a macroexpander for `function` that > ends up calling cl--labels-convert. Ok, I extended the docstrings of cl-labels and cl-flet a bit and added a test too. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=0001-Fix-fun-handling-inside-labels-Bug-31792.patch Content-Description: patch >From c344010e7e2922a75769926896d585d367bbc5a8 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 12 Jun 2018 18:41:46 -0400 Subject: [PATCH] Fix #'fun handling inside `labels' (Bug#31792) * lisp/emacs-lisp/cl.el (labels): Apply the equivalent of the cl-labels change from 2015-01-16 "* lisp/emacs-lisp/cl-macs.el: Fix last change". * lisp/emacs-lisp/cl-macs.el (cl-flet, cl-labels): Improve docstring, link to relevant manual page. * test/lisp/emacs-lisp/cl-tests.el (labels-function-quoting): New test. --- lisp/emacs-lisp/cl-macs.el | 16 ++++++++++++---- lisp/emacs-lisp/cl.el | 7 +++++-- test/lisp/emacs-lisp/cl-tests.el | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 test/lisp/emacs-lisp/cl-tests.el diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 9c47ceae18..e80efecac9 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1964,13 +1964,17 @@ cl--labels-convert ;;;###autoload (defmacro cl-flet (bindings &rest body) "Make local function definitions. -Like `cl-labels' but the definitions are not recursive. +Bind the function cells of symbols within FORM. Each binding can take the form (FUNC EXP) where FUNC is the function name, and EXP is an expression that returns the function value to which it should be bound, or it can take the more common form \(FUNC ARGLIST BODY...) which is a shorthand for (FUNC (lambda ARGLIST BODY)). +The bindings only take effect within FORM, not BODY, so you can't +write recursive function definitions. Use `cl-labels' for that. +See info node `(cl) Function Bindings' for details. + \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" (declare (indent 1) (debug ((&rest (cl-defun)) cl-declarations body))) (let ((binds ()) (newenv macroexpand-all-environment)) @@ -2012,9 +2016,13 @@ cl-flet* ;;;###autoload (defmacro cl-labels (bindings &rest body) - "Make temporary function bindings. -The bindings can be recursive and the scoping is lexical, but capturing them -in closures will only work if `lexical-binding' is in use. + "Make local function definitions. +Bind the function cells of symbols within FORM. Each binding can +take the form (FUNC ARGLIST BODY...) where FUNC is the function +name, ARGLIST its arguments, and BODY the forms of the function +body. The bindings can be referenced from any BODY, as well as +FORM, so you can write recursive and mutually recursive function +definitions. See info node `(cl) Function Bindings' for details. \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" (declare (indent 1) (debug cl-flet)) diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index d53c8e0bbc..f6643158d2 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -466,9 +466,12 @@ labels (push var sets) (push (cons (car binding) `(lambda (&rest cl-labels-args) - (cl-list* 'funcall ',var - cl-labels-args))) + (if (eq (car cl-labels-args) cl--labels-magic) + (list cl--labels-magic ',var) + (cl-list* 'funcall ',var cl-labels-args)))) newenv))) + ;; `lexical-let' adds `cl--function-convert' (which calls + ;; `cl--labels-convert') as a macroexpander for `function'. (macroexpand-all `(lexical-let ,vars (setq ,@sets) ,@body) newenv))) ;; Generalized variables are provided by gv.el, but some details are diff --git a/test/lisp/emacs-lisp/cl-tests.el b/test/lisp/emacs-lisp/cl-tests.el new file mode 100644 index 0000000000..b673822cd9 --- /dev/null +++ b/test/lisp/emacs-lisp/cl-tests.el @@ -0,0 +1,35 @@ +;;; cl-tests.el --- tests for emacs-lisp/cl.el -*- lexical-binding:t -*- + +;; Copyright (C) 2018 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see `https://www.gnu.org/licenses/'. + +;;; Commentary: + +;;; Code: + +(require 'cl) +(require 'ert) + + + +(ert-deftest labels-function-quoting () + "Test that #'foo does the right thing in `labels'." ; Bug#31792. + (should (eq (funcall (labels ((foo () t)) + #'foo)) + t))) + +;;; cl-tests.el ends here -- 2.11.0 --=-=-=--