[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/oclosure 263172dbfb 02/25: lisp/emacs-lisp/oclosure.el: Make it
From: |
Stefan Monnier |
Subject: |
scratch/oclosure 263172dbfb 02/25: lisp/emacs-lisp/oclosure.el: Make it available to cl-generic |
Date: |
Fri, 31 Dec 2021 15:40:55 -0500 (EST) |
branch: scratch/oclosure
commit 263172dbfb929eaa7eb028a60e07011844786ba1
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
lisp/emacs-lisp/oclosure.el: Make it available to cl-generic
* lisp/loadup.el: Load `oclosure`.
* lisp/emacs-lisp/oclosure.el: Don't use `cl-lib` at runtime.
(oclosure--copy): Use `named-let` instead of `cl-mapcar`.
(oclosure--struct-tag, oclosure--struct-specializers,
oclosure--struct-generalizer)
(cl-generic-generalizers): Move cl-generic support to cl-generic.
* lisp/emacs-lisp/cl-generic.el (cl--generic-oclosure-tag)
(cl-generic--oclosure-specializers, cl-generic--oclosure-generalizer)
(cl-generic-generalizers): Move OClosure support from `oclosure.el`.
---
lisp/dired-aux.el | 2 +-
lisp/emacs-lisp/cl-generic.el | 27 +++++++++++++++++++++++++++
lisp/emacs-lisp/oclosure.el | 36 +++++-------------------------------
lisp/loadup.el | 1 +
lisp/xwidget.el | 2 +-
5 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 5301a3a27f..56c7e191e1 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -3089,7 +3089,7 @@ Use \\[dired-hide-all] to (un)hide all directories."
(dired-next-subdir 1 t))))
;;;###autoload
-(defun dired-hide-all (&optional ignored)
+(defun dired-hide-all (&optional _ignored)
"Hide all subdirectories, leaving only their header lines.
If there is already something hidden, make everything visible again.
Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 9de47e4987..152a7a2afa 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -1293,6 +1293,33 @@ Used internally for the (major-mode MODE) context
specializers."
(progn (cl-assert (null modes)) mode)
`(derived-mode ,mode . ,modes))))
+;;; Dispatch on OClosure type
+
+(defun cl--generic-oclosure-tag (name &rest _)
+ `(oclosure-type ,name))
+
+(defun cl-generic--oclosure-specializers (tag &rest _)
+ (and (symbolp tag)
+ (let ((class (cl--find-class tag)))
+ (when (cl-typep class 'oclosure--class)
+ (cl--generic-class-parents class)))))
+
+(cl-generic-define-generalizer cl-generic--oclosure-generalizer
+ 50 #'cl--generic-oclosure-tag
+ #'cl-generic--oclosure-specializers)
+
+(cl-defmethod cl-generic-generalizers :extra "oclosure-struct" (type)
+ "Support for dispatch on types defined by `oclosure-define'."
+ (or
+ (when (symbolp type)
+ ;; Use the "cl--struct-class*" (inlinable) functions/macros rather than
+ ;; the "cl-struct-*" variants which aren't inlined, so that dispatch can
+ ;; take place without requiring cl-lib.
+ (let ((class (cl--find-class type)))
+ (and (cl-typep class 'oclosure--class)
+ (list cl-generic--oclosure-generalizer))))
+ (cl-call-next-method)))
+
;;; Support for unloading.
(cl-defmethod loadhist-unload-element ((x (head cl-defmethod)))
diff --git a/lisp/emacs-lisp/oclosure.el b/lisp/emacs-lisp/oclosure.el
index 22ce26c1f8..524b71a5a4 100644
--- a/lisp/emacs-lisp/oclosure.el
+++ b/lisp/emacs-lisp/oclosure.el
@@ -41,7 +41,7 @@
;;; Code:
-(require 'cl-lib)
+(eval-when-compile (require 'cl-lib))
(eval-when-compile (require 'subr-x)) ;For `named-let'.
(cl-defstruct (oclosure--class
@@ -251,7 +251,10 @@
(let ((env (cadr oclosure)))
`(closure
(,(car env)
- ,@(cl-mapcar (lambda (b v) (cons (car b) v)) (cdr env) args)
+ ,@(named-let loop ((env (cdr env)) (args args))
+ (when args
+ (cons (cons (caar env) (car args))
+ (loop (cdr env) (cdr args)))))
,@(nthcdr (1+ (length args)) env))
,@(nthcdr 2 oclosure)))))
@@ -272,34 +275,5 @@
(eq oclosure--type-sym (caar (cadr oclosure)))
(cdar (cadr oclosure)))))
-;;; Support for cl-generic
-
-(defun oclosure--struct-tag (name &rest _)
- `(oclosure-type ,name))
-
-(defun oclosure--struct-specializers (tag &rest _)
- (and (symbolp tag)
- (let ((class (cl--find-class tag)))
- (when (cl-typep class 'oclosure--class)
- (cl--generic-class-parents class)))))
-
-(cl-generic-define-generalizer oclosure--struct-generalizer
- 50 #'oclosure--struct-tag
- #'oclosure--struct-specializers)
-
-(cl-defmethod cl-generic-generalizers :extra "oclosure-struct" (type)
- "Support for dispatch on types defined by `oclosure-define'."
- (or
- (when (symbolp type)
- ;; Use the "cl--struct-class*" (inlinable) functions/macros rather than
- ;; the "cl-struct-*" variants which aren't inlined, so that dispatch can
- ;; take place without requiring cl-lib.
- (let ((class (cl--find-class type)))
- (and (cl-typep class 'oclosure--class)
- (list oclosure--struct-generalizer))))
- (cl-call-next-method)))
-
-
-
(provide 'oclosure)
;;; oclosure.el ends here
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 71d6a501b9..b5348d1c3f 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -247,6 +247,7 @@
(load "language/cham")
(load "indent")
+(load "emacs-lisp/oclosure") ;Used by cl-generic
(let ((max-specpdl-size (max max-specpdl-size 1800)))
;; A particularly demanding file to load; 1600 does not seem to be enough.
(load "emacs-lisp/cl-generic"))
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index ce9839ebd3..64a1b1bcda 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -1168,7 +1168,7 @@ Press
\\<xwidget-webkit-isearch-mode-map>\\[xwidget-webkit-isearch-exit] to exit
(xwidget-webkit-goto-history xwidget-webkit-history--session id))
(xwidget-webkit-history-reload))
-(defun xwidget-webkit-history-reload (&rest ignored)
+(defun xwidget-webkit-history-reload (&rest _ignored)
"Reload the current history buffer."
(interactive)
(setq tabulated-list-entries nil)
- scratch/oclosure e052bb2770 04/25: * lisp/kmacro.el: Use OClosure instead of messing with internals, (continued)
- scratch/oclosure e052bb2770 04/25: * lisp/kmacro.el: Use OClosure instead of messing with internals, Stefan Monnier, 2021/12/31
- scratch/oclosure ae493f3513 01/25: OClosure: Hybrids between functions and defstructs, Stefan Monnier, 2021/12/31
- scratch/oclosure ae0bfc4f75 05/25: * lisp/loadup.el (oclosure): Load before `nadvice`, Stefan Monnier, 2021/12/31
- scratch/oclosure afa68def26 11/25: cl-print.el: Dispatch on `advice` type, Stefan Monnier, 2021/12/31
- scratch/oclosure fe5457ff75 19/25: oclosure.el (oclosure-lambda): Change calling convention, Stefan Monnier, 2021/12/31
- scratch/oclosure d93b0ad4d4 06/25: (interactive-form, function-docstring): New generic functions, Stefan Monnier, 2021/12/31
- scratch/oclosure a444d85977 08/25: Fix bootstrap problems and various misc issues found along the way, Stefan Monnier, 2021/12/31
- scratch/oclosure f44ee8cd53 17/25: oclosure.el (accessor): New type, Stefan Monnier, 2021/12/31
- scratch/oclosure 55a8e92413 20/25: oclosure.el: Add support for mutable slots, Stefan Monnier, 2021/12/31
- scratch/oclosure bc1d94a0d8 21/25: * lisp/emacs-lisp/oclosure.el (Commentary:): Add a few notes, Stefan Monnier, 2021/12/31
- scratch/oclosure 263172dbfb 02/25: lisp/emacs-lisp/oclosure.el: Make it available to cl-generic,
Stefan Monnier <=
- scratch/oclosure 3119e59252 07/25: lisp/emacs-lisp/oclosure.el: Rename `oclosure-make` to `oclosure-lambda`, Stefan Monnier, 2021/12/31
- scratch/oclosure 9465a7e59e 10/25: nadvice.el: Restore interactive-form handling, Stefan Monnier, 2021/12/31
- scratch/oclosure 3c9d64b602 14/25: cl-macs.el (cl--transform-lambda): Fix last change, Stefan Monnier, 2021/12/31
- scratch/oclosure 01002ebba0 18/25: oclosure.el (oclosure-define): Use `oclosure--copy` to define accessors, Stefan Monnier, 2021/12/31
- scratch/oclosure 20e5cd82ae 13/25: Fix bug#28557, Stefan Monnier, 2021/12/31
- scratch/oclosure 44dbab47f7 23/25: * lisp/emacs-lisp/oclosure.el: Remove obsolete comment, Stefan Monnier, 2021/12/31
- scratch/oclosure 1ace4acd54 22/25: Replace uniquify.el's advice with direct calls, Stefan Monnier, 2021/12/31
- scratch/oclosure 3aa60102b9 24/25: kmacro.el: Unify the lambda and the list representations, Stefan Monnier, 2021/12/31
- scratch/oclosure e9cfab679d 15/25: lisp/emacs-lisp/cl-macs.el: Align with `master`, Stefan Monnier, 2021/12/31
- scratch/oclosure e65e2bd0aa 12/25: * lisp/emacs-lisp/cl-generic.el (cl-generic--oclosure-generalizer): Fix precedence, Stefan Monnier, 2021/12/31