master: sb-manual: USE-PAX automatically if PAX is already loaded

melisgl via Sbcl-commits <[email protected]> Mon, 29 Jun 2026 12:19:56 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  98d37dc3e3ac015e4e28747dbce279f137d78a6c (commit)
      from  55fe2df553beeebeaee4a5b18519e29f4de7b542 (commit)

- Log -----------------------------------------------------------------
commit 98d37dc3e3ac015e4e28747dbce279f137d78a6c
Author: Gabor Melis <[email protected]>
Date:   Mon Jun 8 17:40:52 2026 +0200

    sb-manual: USE-PAX automatically if PAX is already loaded
    
    ... when sb-manual is loaded.
    
    SWITCH-TO-PAX was renamed to USE-PAX.
---
 contrib/sb-manual/docstring.lisp     |  6 +++---
 contrib/sb-manual/late.lisp          |  5 +++++
 contrib/sb-manual/make-pax-docs.lisp |  9 +++++----
 contrib/sb-manual/markdown.lisp      |  4 ++--
 contrib/sb-manual/pax.lisp           | 23 ++++++++++++-----------
 contrib/sb-manual/sb-manual.asd      |  3 ++-
 contrib/sb-manual/texinfo.lisp       |  2 +-
 7 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/contrib/sb-manual/docstring.lisp b/contrib/sb-manual/docstring.lisp
index 72daee9fd..5ad06fb6d 100644
--- a/contrib/sb-manual/docstring.lisp
+++ b/contrib/sb-manual/docstring.lisp
@@ -69,7 +69,7 @@
 ;;; To avoid conflicting with PAX's heuristics, DOCSTRING-PACKAGE
 ;;; always returns a non-NIL package. We use a reimplementation of
 ;;; DREF-EXT:DEFINITION-PROPERTY for DREF-EXT:DOCSTRING*, which we
-;;; feed to DOCSTRING-PACKAGE-OVERRIDES-TO-PAX in SWITCH-TO-PAX.
+;;; feed to DOCSTRING-PACKAGE-OVERRIDES-TO-PAX in USE-PAX.
 
 ;;; These map the SYMBOL-PACKAGE of a definition's XREF-NAME to the
 ;;; docstring package.
@@ -103,9 +103,9 @@
     ((trace macro) "SB-DEBUG")))
 
 ;;; For when this file is recompiled in interactive development after
-;;; SWITCH-TO-PAX
+;;; a later, explicit call to USE-PAX
 (eval-when (:load-toplevel :execute)
-  (when *use-pax*
+  (when *using-pax*
     (convert-docstring-package-overrides-to-pax)))
 
 (defun docstring-package (xref)
diff --git a/contrib/sb-manual/late.lisp b/contrib/sb-manual/late.lisp
new file mode 100644
index 000000000..868060777
--- /dev/null
+++ b/contrib/sb-manual/late.lisp
@@ -0,0 +1,5 @@
+(in-package :sb-manual)
+
+(eval-when (:load-toplevel :execute)
+  (when (find-package '#:mgl-pax)
+    (use-pax)))
diff --git a/contrib/sb-manual/make-pax-docs.lisp b/contrib/sb-manual/make-pax-docs.lisp
index bc15ce955..e4ba12a60 100644
--- a/contrib/sb-manual/make-pax-docs.lisp
+++ b/contrib/sb-manual/make-pax-docs.lisp
@@ -1,9 +1,11 @@
 ;;;; Generate the SBCL manual in various formats in doc/manual/ with PAX
 
-;;; This file is to be LOADed.
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (require :mgl-pax/full)
+  (require :sb-manual))
 
-(require :sb-manual)
-(require :mgl-pax/full)
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (sb-manual::use-pax))
 
 (in-package :sb-manual)
 
@@ -44,7 +46,6 @@
 \\makeatother")
 
 (defun make-pax-docs (&optional git-forge-uri)
-  (switch-to-pax)
   (let ((*git-forge-uri* (or (and (plusp (length git-forge-uri))
                                   git-forge-uri)
                              "https://github.com/sbcl/sbcl"))
diff --git a/contrib/sb-manual/markdown.lisp b/contrib/sb-manual/markdown.lisp
index 0779d6c90..34ae013a7 100644
--- a/contrib/sb-manual/markdown.lisp
+++ b/contrib/sb-manual/markdown.lisp
@@ -453,13 +453,13 @@
 
 (defun section-name-p (symbol)
   (when (boundp symbol)
-    (if *use-pax*
+    (if *using-pax*
         (typep (symbol-value symbol) (dummy 'section))
         (let ((value (symbol-value symbol)))
           (and (listp value)
                (eq (first value) 'defsection))))))
 
-(when (and (not *use-pax*)
+(when (and (not *using-pax*)
            *downcase-uppercase-code*)
   (defsection @test-section ())
   (unwind-protect
diff --git a/contrib/sb-manual/pax.lisp b/contrib/sb-manual/pax.lisp
index 6b5425492..d7408632a 100644
--- a/contrib/sb-manual/pax.lisp
+++ b/contrib/sb-manual/pax.lisp
@@ -1,7 +1,7 @@
 ;;;; PAX stubs
 ;;;;
 ;;;; Contribs cannot depend on external libraries, so we fake as much
-;;;; of PAX and DRef as necessary. SWITCH-TO-PAX switches to the real
+;;;; of PAX and DRef as necessary. USE-PAX switches to the real
 ;;;; implementation.
 ;;;;
 ;;;; If PAX is not loaded, the dummy DEFSECTION below still gives us
@@ -15,25 +15,25 @@
 (in-package :sb-manual)
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (defvar *use-pax* nil)
+  (defvar *using-pax* nil)
   ;; A list of (LOCAL-SYMBOL PACKAGE) elements. Originally,
   ;; LOCAL-SYMBOL has home package SB-MANUAL. For example, the element
   ;; (SECTION :PAX) causes PAX:SECTION to be SHADOWING-IMPORTed in
-  ;; SWITCH-TO-PAX.
+  ;; USE-PAX.
   (defvar *dummies* ()))
 
 (defmacro defun-dummy ((name package) lambda-list &body body)
   `(eval-when (:compile-toplevel :load-toplevel :execute)
      (pushnew '(,name ,package) *dummies* :test #'equal)
      (declaim (notinline ,name))
-     (unless *use-pax*
+     (unless *using-pax*
        (defun ,name ,lambda-list ,@body))))
 
 (defmacro defmacro-dummy ((name package) lambda-list &body body)
-  (unless *use-pax*
+  (unless *using-pax*
     `(eval-when (:compile-toplevel :load-toplevel :execute)
        (pushnew '(,name ,package) *dummies* :test #'equal)
-       (unless *use-pax*
+       (unless *using-pax*
          (defmacro ,name ,lambda-list ,@body)))))
 
 (defparameter *extra-dummies*
@@ -52,9 +52,9 @@
 (defvar *definition-to-docstring-package*)
 (defvar *package-to-docstring-package*)
 
-(defun switch-to-pax ()
-  (unless *use-pax*
-    (require 'mgl-pax)
+(defun use-pax ()
+  (unless *using-pax*
+    (assert (find-package '#:mgl-pax))
     ;; Replace dummies with the real symbols.
     (loop for (name package) in (append *dummies* *extra-dummies*)
           do (let ((new-symbol (read-from-string
@@ -86,7 +86,7 @@
                   source-location)))))
     (convert-docstring-package-overrides-to-pax)
     ;; FIXME: register doc?
-    (setq *use-pax* t)))
+    (setq *using-pax* t)))
 
 ;;; Convert *DEFINITION-TO-DOCSTRING-PACKAGE* to
 ;;; DREF:DEFINITION-PROPERTIES and *PACKAGE-TO-DOCSTRING-PACKAGE* to
@@ -94,7 +94,8 @@
 (defun convert-docstring-package-overrides-to-pax ()
   (loop for ((name locative) package) in *definition-to-docstring-package*
         do (eval-format
-            "(setf (dref-ext:definition-property (dref:dref '~S '~S) 'docstring)
+            "(setf (dref-ext:definition-property (dref:xref '~S '~S)~
+                                                 'docstring)
                    (list nil (find-package ~S)))"
             name (subst-extras locative) package))
   (setq *definition-to-docstring-package*
diff --git a/contrib/sb-manual/sb-manual.asd b/contrib/sb-manual/sb-manual.asd
index 4a99db4a5..6690f63a8 100644
--- a/contrib/sb-manual/sb-manual.asd
+++ b/contrib/sb-manual/sb-manual.asd
@@ -39,4 +39,5 @@
                              (:file "sb-rotate-byte")
                              (:file "sb-simd")
                              (:file "sb-simple-streams")
-                             (:file "deprecation")))))
+                             (:file "deprecation")))
+               (:file "late")))
diff --git a/contrib/sb-manual/texinfo.lisp b/contrib/sb-manual/texinfo.lisp
index fa362184d..0b782cf87 100644
--- a/contrib/sb-manual/texinfo.lisp
+++ b/contrib/sb-manual/texinfo.lisp
@@ -1,7 +1,7 @@
 (in-package :sb-manual)
 
 ;;; We don't DEFINE-DUMMY DREF:ARGLIST and DREF:DOCSTRING because we
-;;; don't want SWITCH-TO-PAX affect Texinfo output, which it would
+;;; don't want USE-PAX to affect Texinfo output, which it would
 ;;; because DREF:ARGLIST differs from the {incom,re}prehensible
 ;;; LAMBDA-LIST*.
 (defun %arglist (xref)

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL