Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
;; This file:
;;   http://anggtwu.net/elisp/2025-modern-prints.el.html
;;   http://anggtwu.net/elisp/2025-modern-prints.el
;;          (find-angg "elisp/2025-modern-prints.el")
;; Author: Eduardo Ochs <eduardoochs@gmail.com>
;;
;; See: (find-angg "ORG/2025-modern.org")
;;      (find-angg "elisp/2025-modern-advice.el")
;;      (find-angg "elisp/2025-modern-reset.el")
;;      (find-angg "elisp/emacsconf2024.el")
;;
;; If we load
;;      (find-angg "elisp/2025-modern-reset.el")
;;         (load "~/elisp/2025-modern-reset.el")
;; it resets some `cl-print's to the default definitions;
;; If we load this file,
;;      (find-angg "elisp/2025-modern-prints.el")
;;         (load "~/elisp/2025-modern-prints.el")
;; it defines several alternative `cl-print's.



;; «.2a»				(to "2a")
;; «.princ-and-prin1»			(to "princ-and-prin1")
;; «.vector-like-lambdas»		(to "vector-like-lambdas")
;;   «.named-plists»			(to "named-plists")
;; «.vector-like-named»			(to "vector-like-named")
;; «.interpreted-function-orig»		(to "interpreted-function-orig")
;; «.interpreted-function-named»	(to "interpreted-function-named")
;; «.interpreted-function-prin1»	(to "interpreted-function-prin1")
;; «.interpreted-function-old-style»	(to "interpreted-function-old-style")
;; «.advice-adt»			(to "advice-adt")
;; «.advice-orig»			(to "advice-orig")
;; «.advice-named»			(to "advice-named")


;; «2a»  (to ".2a")
;; See: (find-multiwindow-intro "3. High-level words")
;;      (find-multiwindow-intro "3. High-level words" "find-2a")
;;
;; Remember that `M-e' on a hyperlink displays its target
;; in the current window, and `M-2 M-e' on a hyperlink
;; displays its target at the window at the right...
;;
;; In this section we define some variants with `-2a'
;; that display their targets at the window at the right.
;;
;; Tests:               (find-epp    '(23 ab "cd" :ef))
;;        (find-2a nil '(find-epp    '(23 ab "cd" :ef)))
;;                      (find-epp-2a '(23 ab "cd" :ef))
;;                      (find-estring-elisp    "(23 ab \"cd\" :ef)")
;;        (find-2a nil '(find-estring-elisp    "(23 ab \"cd\" :ef)"))
;;                      (find-estring-elisp-2a "(23 ab \"cd\" :ef)")
;;        (find-clprin1-2a '(ab :a "aa" :b 23))
;;        (find-clprin2-2a '(ab :a "aa" :b 23))
;;        (find-clprin1-2a (cl-find-class 'cl-structure-class))
;;        (find-clprin2-2a (cl-find-class 'cl-structure-class))
;;
(defun find-epp-2a (&rest rest)
  (find-2a nil '(apply 'find-epp rest)))

(defmacro defun-2a (f-2a f)
  `(defun ,f-2a (&rest rest) (find-2a nil '(apply ',f rest))))

(defun-2a find-epp-2a           find-epp)
(defun-2a find-estring-elisp-2a find-estring-elisp)
(defun-2a find-clprin1-2a       find-clprin1)
(defun-2a find-clprin1ind-2a    find-clprin1ind)
(defun-2a find-clprin2-2a       find-clprin2)




;; «princ-and-prin1»  (to ".princ-and-prin1")
;; See: (find-elnode "Generic Functions" "cl-defmethod name")
;;      (find-efile "emacs-lisp/cl-print.el" "(object interpreted-function)")
;;      (find-es "emacs" "princ-and-prin1")
;;
;; Most "(cl-defmethod cl-print-object ...)"s use lots of
;; `princ's, `prin1's, and `cl-prin*'s. What is the
;; difference between `princ's and `prin1's?
;;
;; (find-elnode "Output Functions" "Function: princ")
;; (find-elnode "Output Functions" "Function: princ" "doesn’t insert quoting characters")
;; (find-elnode "Output Functions" "Function: prin1")
;; (find-elnode "Output Functions" "Function: prin1" "use quoting characters")
;;
;; Compare:
'(
  (princ "ab" (current-buffer))
  (prin1 "ab" (current-buffer))
  (princ '(23 ab "ab") (current-buffer))
  (prin1 '(23 ab "ab") (current-buffer))
  )



;; «vector-like-lambdas»  (to ".vector-like-lambdas")
;; Some (improvised) terminology:
;; This is an old-style lambda:   (lambda (a b) (+ a b))
;; This is a vector-like lambda:  #[(a b) ((+ a b)) nil]
;;
;; Eev has some functions to convert vector-like lambdas to old-style
;; lambdas. Try:
;;
;;   (defun foo (a b) (+ a b))
;;   (symbol-function 'foo)
;;   (ee-symbol-function 'foo)
;;   (ee-closure-to-lambda (symbol-function 'foo))
;;
;; See: (find-eev "eev-blinks.el" "ee-symbol-function")






;; «named-plists»  (to ".named-plists")
;; This is a plist:           (:keyA 123 :keyB 234)
;; This is a named plist:  (AB :keyA 123 :keyB 234)
;; `find-clprin2' indents named plists in a nice way.
;; Try:
;;   (find-clprin1-2a     '(AB :keyA 123 :keyB 234))
;;   (find-clprin2-2a     '(AB :keyA 123 :keyB 234))


;; «vector-like-named»  (to ".vector-like-named")
;; Sometimes the best way to understand vector-like lambdas is to
;; convert them to named plists. See:
;;   (find-efunction 'ee-closure-to-list)
(defun ee-closure-to-named-plist (c &optional head)
  (let ((list (ee-closure-to-list c)))
    (seq-let [args code consts stackdepth docstring iform] list
      `(,(or head 'interpreted-function)
	:args       ,args
	:code       ,code
	:consts     ,consts
	:stackdepth ,stackdepth
	:docstring  ,docstring
	:iform      ,iform))))

;; Test:
;; (defun foo (a b) "Docstr" (interactive (list 2 3)) a (+ a b))
;; (setq o (symbol-function 'foo))
;; (find-epp-2a     o)
;; (find-clprin1-2a o)
;;
;; (find-epp-2a        (ee-closure-to-lambda o))
;; (find-epp-2a        (ee-closure-to-named-plist o))
;; (find-clprin1-2a    (ee-closure-to-named-plist o))
;; (find-clprin1ind-2a (ee-closure-to-named-plist o))



;; «interpreted-function-orig»  (to ".interpreted-function-orig")
;; (find-angg "elisp/2025-modern-reset.el" "interpreted-function-orig")
;; (load "2025-modern-reset.el")
;;
;; Test:
;; (defun foo (a b) "Docstr" (interactive (list 2 3)) a (+ a b))
;; (setq o (symbol-function 'foo))
;; (find-clprin1-2a o)
;;
;;  -> #f(lambda (a b) :dynbind "Docstr" (interactive (list 2 3)) a (+ a b))



;; «interpreted-function-prin1»  (to ".interpreted-function-prin1")
(cl-defmethod cl-print-object ((object interpreted-function) stream)
  (prin1 object stream))
;;
;; Test:
;; (defun foo (a b) "Docstr" (interactive (list 2 3)) a (+ a b))
;; (setq o (symbol-function 'foo))
;; (find-clprin2-2a o)
;;  -> #[(a b) (a (+ a b)) nil nil "Docstr" (list 2 3)]



;; «interpreted-function-named»  (to ".interpreted-function-named")
(cl-defmethod cl-print-object ((object interpreted-function) stream)
  (prin1 (ee-closure-to-named-plist object) stream))
;;
;; Test:
;; (defun foo (a b) "Docstr" (interactive (list 2 3)) a (+ a b))
;; (setq o (symbol-function 'foo))
;; (find-clprin2-2a o)
;;
;;  -> (interpreted-function
;;      :args (a b)
;;      :code (a (+ a b))
;;      :consts nil
;;      :stackdepth nil
;;      :docstring "Docstr"
;;      :iform (list 2 3))


;; «interpreted-function-old-style»  (to ".interpreted-function-old-style")
(cl-defmethod cl-print-object ((object interpreted-function) stream)
  (prin1 (ee-closure-to-lambda object) stream))
;;
;; Test:
;; (defun foo (a b) "Docstr" (interactive (list 2 3)) a (+ a b))
;; (setq o (symbol-function 'foo))
;; (find-clprin2-2a o)
;;
;;  -> (lambda (a b) "Docstr" (interactive (list 2 3)) a (+ a b))



;; «advice-adt»  (to ".advice-adt")
;; Used in the tests below.
(defun adt-insert (&rest args) (insert (format "\n;;  --> %S" args)))
(defun adt-1 (o) (adt-insert ':1 o) (list 'adt-1 o))
(defun adt-2 (o) (adt-insert ':2 o) (list 'adt-2 o))
(defun adt-3 (o) (adt-insert ':3 o) (list 'adt-3 o))
(advice-add 'adt-2 :before 'adt-1)
(advice-add 'adt-2 :after  'adt-3)
(setq adt-o (symbol-function 'adt-2))


;; «advice-orig»  (to ".advice-orig")
;; (find-angg "elisp/2025-modern-reset.el" "advice-orig")
;; (load "2025-modern-reset.el")
;; (find-clprin2-2a adt-o)
;;  ^ Some fields are unnamed, doesn't indent well
;;
;; #f(advice adt-3
;;           :after #f(advice adt-1
;;                            :before #f(lambda (o)
;;                                       :dynbind (adt-insert ':2 o) (list 'adt-2 o))))


;; «advice-named»  (to ".advice-named")
;; Compare with:
;;   (find-angg "elisp/2025-modern-reset.el" "advice-orig")
(cl-defmethod cl-print-object ((object advice) stream)
  (cl-assert (advice--p object))
  (princ "#f(advice :car " stream)
  (cl-print-object (advice--car object) stream)
  (princ " :how " stream)
  (cl-print-object (advice--how object) stream)
  (princ " :cdr " stream)
  (cl-print-object (advice--cdr object) stream)
  (let ((props (advice--props object)))
    (princ " :props " stream)
    (cl-print-object props stream))
  (princ ")" stream))

;; Test:
;; (load "2025-modern-prints.el")
;; (find-clprin2-2a adt-o)
;;
;;  -> #f(advice
;;        :car adt-3
;;        :how :after
;;        :cdr #f(advice
;;                :car adt-1
;;                :how :before
;;                :cdr (lambda (o) (adt-insert ':2 o) (list 'adt-2 o))
;;                :props nil)
;;        :props nil)




;; Local Variables:
;; coding:  utf-8-unix
;; End: