all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60102: Move gv-expander of substring to cl-lib
@ 2022-12-15 20:12 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-16  6:56 ` Eli Zaretskii
  2022-12-16  7:22 ` Juri Linkov
  0 siblings, 2 replies; 67+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-15 20:12 UTC (permalink / raw)
  To: 60102

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gv-substring.patch --]
[-- Type: text/patch, Size: 1619 bytes --]

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2023-09-04 20:43 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-15 20:12 bug#60102: Move gv-expander of substring to cl-lib Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-16  6:56 ` Eli Zaretskii
2022-12-16 14:14   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-04 20:00     ` Stefan Kangas
2023-09-04 20:43       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-16  7:22 ` Juri Linkov
2022-12-20 18:42   ` cl-lib warnings (was: bug#60102: Move gv-expander of substring to cl-lib) Stefan Monnier
2022-12-21  8:37     ` cl-lib warnings Juri Linkov
2022-12-21 12:45       ` Eli Zaretskii
2022-12-21 12:57         ` João Távora
2022-12-21 13:47           ` Eli Zaretskii
2022-12-21 14:04             ` João Távora
2022-12-21 14:20               ` Eli Zaretskii
2022-12-21 14:35                 ` João Távora
2022-12-21 14:50                 ` Juanma Barranquero
2022-12-21 14:55                   ` João Távora
2022-12-21 14:57                     ` Juanma Barranquero
2022-12-21 15:08                       ` João Távora
2022-12-26  3:13                         ` Milan Glacier
2022-12-26 15:10                           ` João Távora
2022-12-26 23:48                             ` Milan Glacier
2022-12-27  0:05                               ` João Távora
2022-12-27  3:43                                 ` Tim Cross
2022-12-27 10:16                                   ` Lynn Winebarger
2022-12-27 13:00                                 ` Stefan Kangas
2022-12-21 17:14                   ` Eli Zaretskii
2022-12-21 22:33                     ` Juanma Barranquero
2022-12-22  7:13                       ` Eli Zaretskii
2022-12-22  7:23                         ` Juanma Barranquero
2022-12-22  8:53                           ` Eli Zaretskii
2022-12-22 22:24                         ` Yuan Fu
2022-12-22 23:56                           ` Stefan Monnier
2022-12-23  7:30                           ` Eli Zaretskii
2022-12-23 23:42                             ` Yuan Fu
2022-12-24  0:24                               ` Juanma Barranquero
2022-12-24 14:08                                 ` Stefan Monnier
2022-12-24 14:39                                   ` Juanma Barranquero
2022-12-24 19:13                                     ` Tomas Hlavaty
2022-12-24  0:26                               ` João Távora
2022-12-24 10:33                                 ` Philip Kaludercic
2022-12-24 11:01                                   ` João Távora
2022-12-26  0:11                                     ` cl-loop and plists vs alists Philip Kaludercic
2022-12-26  0:35                                       ` João Távora
2022-12-26 21:06                                         ` Bob Rogers
2022-12-24 22:59                                 ` cl-lib warnings Sean Whitton
2022-12-25  1:21                                   ` Stefan Monnier
2022-12-25  2:39                                     ` package-initialize was " T.V Raman
2022-12-25  4:11                                       ` T.V Raman
2022-12-26  0:01                                       ` Stefan Monnier
2022-12-26  2:18                                         ` T.V Raman
2022-12-25  7:02                                     ` tomas
2022-12-25  9:55                                       ` João Távora
2022-12-25 11:33                                         ` tomas
2022-12-26  4:47                                     ` Sean Whitton
2022-12-24  6:40                               ` Eli Zaretskii
2022-12-24 13:01                                 ` Dmitry Gutov
2023-01-06  5:40                   ` Sean Whitton
2023-01-06  7:34                     ` Eli Zaretskii
2023-01-06 17:58                       ` Sean Whitton
2023-01-06 18:14                         ` Eli Zaretskii
2023-01-06 19:03                           ` Sean Whitton
2023-01-06 19:45                             ` Eli Zaretskii
2022-12-21 14:15             ` Eli Zaretskii
2022-12-21 17:53         ` Stefan Monnier
2022-12-24 22:55           ` Sean Whitton
2022-12-25  7:05             ` tomas
2022-12-25  8:29           ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.