Commit 77daafbb authored by Mattias Engdegård's avatar Mattias Engdegård
Browse files

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`.
parent 5a32e5ce
Pipeline #26743 failed with stages
in 120 minutes and 48 seconds
......@@ -1018,7 +1018,7 @@ Use 'define-minor-mode' and 'define-globalized-minor-mode' instead.
* Lisp Changes in Emacs 30.1
** New function 're--describe-compiled' to see the innards of a regexp.
** New function 're-disassemble' to see the innards of a regexp.
If you compiled with '--enable-checking', you can use this to help debug
either your regexp performance problems or the regexp engine.
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment