diff options
| author | Alan Mackenzie | 2023-10-28 09:14:54 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2023-10-28 09:14:54 +0000 |
| commit | c0d898596edb1b3dd159a81fbbedb2c4e310ea5b (patch) | |
| tree | 02fe8e0b2777b26334f9d4ca175272e178718029 | |
| parent | 7d92e7ac09ebaa7580eea064b88a93bae2536365 (diff) | |
| download | emacs-feature/named-lambdas.tar.gz emacs-feature/named-lambdas.zip | |
New cl-print-object method for subrs.feature/named-lambdas
This method also prints the defining symbol, when present.
* lisp/emacs-lisp/cl-print.el (cl-print-object/subr): New
method.
| -rw-r--r-- | lisp/emacs-lisp/cl-print.el | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el index 5b7a5b3b92f..19305782ecc 100644 --- a/lisp/emacs-lisp/cl-print.el +++ b/lisp/emacs-lisp/cl-print.el | |||
| @@ -193,11 +193,10 @@ into a button whose action shows the function's disassembly.") | |||
| 193 | (cl-defmethod cl-print-object ((object compiled-function) stream) | 193 | (cl-defmethod cl-print-object ((object compiled-function) stream) |
| 194 | (unless stream (setq stream standard-output)) | 194 | (unless stream (setq stream standard-output)) |
| 195 | (let ((defsym | 195 | (let ((defsym |
| 196 | (cond | 196 | ;; 2023-10-26: Currently `compiled-function' appears not to |
| 197 | ((subrp object) | 197 | ;; include subrs. |
| 198 | (subr-native-defining-symbol object)) | 198 | (and (> (length object) 5) |
| 199 | ((> (length object) 5) | 199 | (aref object 5)))) |
| 200 | (aref object 5))))) | ||
| 201 | (when (and defsym (not (eq defsym t)) (symbolp defsym)) | 200 | (when (and defsym (not (eq defsym t)) (symbolp defsym)) |
| 202 | (princ "{" stream) | 201 | (princ "{" stream) |
| 203 | (;; cl- | 202 | (;; cl- |
| @@ -255,8 +254,17 @@ into a button whose action shows the function's disassembly.") | |||
| 255 | (with-current-buffer stream | 254 | (with-current-buffer stream |
| 256 | (make-text-button button-start (point) | 255 | (make-text-button button-start (point) |
| 257 | :type 'help-byte-code | 256 | :type 'help-byte-code |
| 258 | 'byte-code-function object))))) | 257 | 'byte-code-function object)))))) |
| 259 | (princ ")" stream))) | 258 | (princ ")" stream)) |
| 259 | |||
| 260 | (cl-defmethod cl-print-object ((object subr) stream) | ||
| 261 | (unless stream (setq stream standard-output)) | ||
| 262 | (let ((defsym (subr-native-defining-symbol object))) | ||
| 263 | (when (and defsym (not (eq defsym t)) (symbolp defsym)) | ||
| 264 | (princ "{" stream) | ||
| 265 | (prin1 defsym stream) | ||
| 266 | (princ "} " stream))) | ||
| 267 | (prin1 object stream)) | ||
| 260 | 268 | ||
| 261 | ;; This belongs in oclosure.el, of course, but some load-ordering issues make it | 269 | ;; This belongs in oclosure.el, of course, but some load-ordering issues make it |
| 262 | ;; complicated. | 270 | ;; complicated. |