From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60102: Move gv-expander of substring to cl-lib Date: Thu, 15 Dec 2022 15:12:06 -0500 Message-ID: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17825"; mail-complaints-to="usenet@ciao.gmane.io" To: 60102@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 15 21:13:31 2022 Return-path: Envelope-to: geb-bug-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 1p5ubg-0004Jy-7J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Dec 2022 21:13:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5ubJ-0005ok-Qk; Thu, 15 Dec 2022 15:13:05 -0500 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 1p5ubH-0005oP-03 for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 15:13:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5ubG-0006Ri-DQ for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 15:13:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5ubG-0003AE-8j for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 15:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Dec 2022 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60102 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167113514312147 (code B ref -1); Thu, 15 Dec 2022 20:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Dec 2022 20:12:23 +0000 Original-Received: from localhost ([127.0.0.1]:44679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5uad-00039r-2K for submit@debbugs.gnu.org; Thu, 15 Dec 2022 15:12:23 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:36222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5uaa-00039l-Lo for submit@debbugs.gnu.org; Thu, 15 Dec 2022 15:12:21 -0500 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 1p5uaa-0005kx-E6 for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 15:12:20 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5uaY-0006Ni-EY for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 15:12:20 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 122191007D8 for ; Thu, 15 Dec 2022 15:12:16 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6E907100100 for ; Thu, 15 Dec 2022 15:12:14 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1671135134; bh=IhIQXbTen4BYmtzQEXCS9c6MyDpRAGOiU1D0E3haWiQ=; h=From:To:Subject:Date:From; b=Hu1xJTE5tP7L1bfBQTVhM4453hkXbamjSCrOqnAJ1j/zQkcfUDMu417f1dwkzXyDA GWKva4e5p4H8d03LaJr2HR6o/ko/Wgv8R9i+2fQjQ2KdeDqod3MRGZEOhutxZhWlb/ YDwau/i+O4bXJfaPljadaXJ5OVpZao081orpXkXW1RrHPKPaTjbJcf5fpQPaSH9awn ozv9Ux+etkFWn0KoCR9RI2kw9mq/AMcE0U2bQt4vvfaA5W05ii864tk10Y6dmiRcH/ qTSLUsW21QJpo6FgNT4wy+sKYt3CKoWq3gYuAVZSafYydDXvLjj0bPmKZ4M76k3Io2 VNWyg4lP4ahxA== Original-Received: from alfajor (unknown [45.44.229.252]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5B2D2120205 for ; Thu, 15 Dec 2022 15:12:14 -0500 (EST) Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251147 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Tags: patch The `gv-expander` of `substring` uses the `cl--set-substring` function that's defined only in `cl-lib`, so currently, you can compile (setf (substring ...) ...) without requiring `cl-lib` but at run time it will tend to signal a `void-function` error. We could autoload `cl--set-substring`, but I think a better choice is to move this `gv-expander` to `cl-lib.el`. There are 2 other place definitions in `gv.el` which similarly rely on helper functions defined in `cl-lib` (namely `buffer-substring` and `frame-visible-p`) which we could move as well, but since we marked those as obsolete anyway I think we can "let them die" where they are, with their quirks left alone. If you feel otherwise, I can update the patch to move them to `cl-lib.el` as well. Stefan In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnux32, GTK+ Version 3.24.35, cairo version 1.16.0) of 2022-12-09 built on alfajor Repository revision: b134e7e6abf18286d38e1b589f0fdae523cf1e73 Repository branch: work Windowing system distributor 'The X.Org Foundation', version 11.0.12101003 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign' PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=gv-substring.patch diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index b83b44974d3..ceb5c21baf1 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -170,6 +170,17 @@ cl--set-substring val (and (< end (length str)) (substring str end)))) +(gv-define-expander substring + (lambda (do place from &optional to) + (gv-letplace (getter setter) place + (macroexp-let2* nil ((start from) (end to)) + (funcall do `(substring ,getter ,start ,end) + (lambda (v) + (macroexp-let2 nil v v + `(progn + ,(funcall setter `(cl--set-substring + ,getter ,start ,end ,v)) + ,v)))))))) ;;; Blocks and exits. diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el index 11251d7a963..29cfca9cb62 100644 --- a/lisp/emacs-lisp/gv.el +++ b/lisp/emacs-lisp/gv.el @@ -815,17 +815,5 @@ eq ((eq ,getter ,val) ,(funcall setter `(not ,val)))))))))) (make-obsolete-generalized-variable 'eq nil "29.1") -(gv-define-expander substring - (lambda (do place from &optional to) - (gv-letplace (getter setter) place - (macroexp-let2* nil ((start from) (end to)) - (funcall do `(substring ,getter ,start ,end) - (lambda (v) - (macroexp-let2 nil v v - `(progn - ,(funcall setter `(cl--set-substring - ,getter ,start ,end ,v)) - ,v)))))))) - (provide 'gv) ;;; gv.el ends here --=-=-=--