[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 77daafbb365 3/3: Add convenience wrapper for regexp disassembly
From: |
Mattias Engdegård |
Subject: |
master 77daafbb365 3/3: Add convenience wrapper for regexp disassembly |
Date: |
Fri, 13 Oct 2023 09:38:54 -0400 (EDT) |
branch: master
commit 77daafbb3657d301f864b969cdfe8da17ab5a62d
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
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`.
---
etc/NEWS | 2 +-
lisp/emacs-lisp/disass.el | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/etc/NEWS b/etc/NEWS
index 0e93faebb84..0f9b5f98ebf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index 73777d7e701..d9295686e9f 100644
--- a/lisp/emacs-lisp/disass.el
+++ b/lisp/emacs-lisp/disass.el
@@ -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