emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/beardbolt b60a9e3a84 117/323: Fix errors with emacs <25


From: ELPA Syncer
Subject: [elpa] externals/beardbolt b60a9e3a84 117/323: Fix errors with emacs <25 with elisp disass
Date: Thu, 9 Mar 2023 10:58:22 -0500 (EST)

branch: externals/beardbolt
commit b60a9e3a84e0d3420551660af5808d7668cc33d7
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>

    Fix errors with emacs <25 with elisp disass
---
 README.org |  2 ++
 rmsbolt.el | 41 ++++++++++++++++++++++-------------------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/README.org b/README.org
index f8c93183f5..37bb6b4bb0 100644
--- a/README.org
+++ b/README.org
@@ -136,6 +136,8 @@ copied into it's own directory, making it much harder to 
view non-toy examples.
 
 No support for source->asm matching, filtering, or automatic recompile.
 
+Emacs 26 or the ~cl-print~ package are required.
+
 [[https://i.imgur.com/uYrQ7En.gif][https://i.imgur.com/uYrQ7En.gif]]
 
 ** Common Lisp
diff --git a/rmsbolt.el b/rmsbolt.el
index 2b54eb0139..d24a196086 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -66,6 +66,7 @@
 (require 'map)
 (require 'cc-defs)
 (require 'compile)
+(require 'disass)
 
 (require 'rmsbolt-java)
 
@@ -618,25 +619,27 @@ This should be an object of type `rmsbolt-lang', normally 
set by the major mode"
 (defun rmsbolt--disassemble-file (filename out-buffer)
   "Disassemble an elisp FILENAME into elisp bytecode in OUT-BUFFER.
 Lifted from 
https://emacs.stackexchange.com/questions/35936/disassembly-of-a-bytecode-file";
-  (byte-compile-file filename)
-  ;; .el -> .elc
-  (setq filename (concat filename "c"))
-  (with-temp-buffer
-    (insert-file-contents filename)
-    (let ((inbuf (current-buffer)))
-      (goto-char (point-min))
-      (with-current-buffer out-buffer
-        (erase-buffer)
-        (condition-case ()
-            (cl-loop with cl-print-compiled = 'disassemble
-                     for expr = (read inbuf)
-                     do (pcase expr
-                          (`(byte-code ,(pred stringp) ,(pred vectorp) ,(pred 
natnump))
-                           (princ "TOP-LEVEL byte code:\n" (current-buffer))
-                           (disassemble-1 expr 0))
-                          (_ (cl-prin1 expr (current-buffer))))
-                     do (terpri (current-buffer)))
-          (end-of-file nil))))))
+  (if (not (require 'cl-print nil 'noerror))
+      (error "Package cl-print or Emacs 26+ are required for the Emacs 
disassembler")
+    (byte-compile-file filename)
+    ;; .el -> .elc
+    (setq filename (concat filename "c"))
+    (with-temp-buffer
+      (insert-file-contents filename)
+      (let ((inbuf (current-buffer)))
+        (goto-char (point-min))
+        (with-current-buffer out-buffer
+          (erase-buffer)
+          (condition-case ()
+              (cl-loop with cl-print-compiled = 'disassemble
+                       for expr = (read inbuf)
+                       do (pcase expr
+                            (`(byte-code ,(pred stringp) ,(pred vectorp) 
,(pred natnump))
+                             (princ "TOP-LEVEL byte code:\n" (current-buffer))
+                             (disassemble-1 expr 0))
+                            (_ (cl-prin1 expr (current-buffer))))
+                       do (terpri (current-buffer)))
+            (end-of-file nil)))))))
 
 ;;;;; Filter Functions
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]