Add convenience wrapper for regexp disassembly

* lisp/emacs-lisp/disass.el (re-disassemble): New.
* etc/NEWS: Describe the new function instead of the internal
`re--describe-compiled`.
This commit is contained in:
Mattias Engdegård 2023-10-13 15:21:26 +02:00
parent 5a32e5ce48
commit 77daafbb36
2 changed files with 18 additions and 1 deletions

View file

@ -301,6 +301,23 @@ OBJ should be a call to BYTE-CODE generated by the byte compiler."
(insert "\n")))))
nil)
(defun re-disassemble (regexp &optional case-table)
"Describe the compiled form of REGEXP in a separate window.
If CASE-TABLE is non-nil, use it as translation table for case-folding.
This function is mainly intended for maintenance of Emacs itself
and may change at any time. It requires Emacs to be built with
`--enable-checking'."
(interactive "XRegexp (Lisp expression): ")
(let ((desc (with-temp-buffer
(when case-table
(set-case-table case-table))
(let ((case-fold-search (and case-table t)))
(re--describe-compiled regexp)))))
(with-output-to-temp-buffer "*Regexp-disassemble*"
(with-current-buffer standard-output
(insert desc)))))
(provide 'disass)
;;; disass.el ends here