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

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

[nongnu] elpa/macrostep 31a23eb 085/110: Toggle separate-buffer expansio


From: ELPA Syncer
Subject: [nongnu] elpa/macrostep 31a23eb 085/110: Toggle separate-buffer expansion with prefix (#8)
Date: Sat, 7 Aug 2021 09:18:08 -0400 (EDT)

branch: elpa/macrostep
commit 31a23ebd0d85a9746e7bf35b1ca4c37764092767
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>

    Toggle separate-buffer expansion with prefix (#8)
---
 macrostep.el | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/macrostep.el b/macrostep.el
index 8536a07..779e4a5 100644
--- a/macrostep.el
+++ b/macrostep.el
@@ -462,14 +462,19 @@ quit and return to normal editing.
 
 ;;; Interactive functions
 ;;;###autoload
-(defun macrostep-expand ()
+(defun macrostep-expand (toggle-separate-buffer)
   "Expand the Elisp macro form following point by one step.
 
 Enters `macrostep-mode' if it is not already active, making the
 buffer temporarily read-only. If macrostep-mode is active and the
 form following point is not a macro form, search forward in the
-buffer and expand the next macro form found, if any."
-  (interactive)
+buffer and expand the next macro form found, if any.
+
+With a prefix argument, the expansion is displayed in a separate
+buffer instead of inline in the current buffer.  Setting
+`macrostep-expand-in-separate-buffer' to non-nil swaps these two
+behaviors."
+  (interactive "P")
   (cl-destructuring-bind (start . end)
       (funcall macrostep-sexp-bounds-function)
     (goto-char start)
@@ -481,20 +486,23 @@ buffer and expand the next macro form found, if any."
 
       ;; Create a dedicated macro-expansion buffer and copy the text to
       ;; be expanded into it, if required
-      (when (and macrostep-expand-in-separate-buffer
-                 (not macrostep-expansion-buffer))
-        (let ((mode major-mode)
-              (buffer
-               (get-buffer-create (generate-new-buffer-name "*macro 
expansion*"))))
-          (set-buffer buffer)
-          (funcall mode)
-          (setq macrostep-expansion-buffer t)
-          (setq macrostep-outer-environment env)
-          (save-excursion
-            (setq start (point))
-            (insert text)
-            (setq end (point-marker)))
-          (pop-to-buffer buffer)))
+      (let ((separate-buffer-p
+             (if toggle-separate-buffer
+                 (not macrostep-expand-in-separate-buffer)
+               macrostep-expand-in-separate-buffer)))
+        (when (and separate-buffer-p (not macrostep-expansion-buffer))
+          (let ((mode major-mode)
+                (buffer
+                 (get-buffer-create (generate-new-buffer-name "*macro 
expansion*"))))
+            (set-buffer buffer)
+            (funcall mode)
+            (setq macrostep-expansion-buffer t)
+            (setq macrostep-outer-environment env)
+            (save-excursion
+              (setq start (point))
+              (insert text)
+              (setq end (point-marker)))
+            (pop-to-buffer buffer))))
 
       (unless macrostep-mode (macrostep-mode t))
       (let ((existing-overlay (macrostep-overlay-at-point))



reply via email to

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