[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep 2dd3447 004/110: Fix bug with output of macros t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep 2dd3447 004/110: Fix bug with output of macros that expand to a string (e.g. `rx') |
Date: |
Sat, 7 Aug 2021 09:17:51 -0400 (EDT) |
branch: elpa/macrostep
commit 2dd344787519e3dc5fd130be06357ab0b3cdc9b0
Author: Jonathan Oddie <j.j.oddie@gmail.com>
Commit: Jonathan Oddie <j.j.oddie@gmail.com>
Fix bug with output of macros that expand to a string (e.g. `rx')
---
macrostep.el | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/macrostep.el b/macrostep.el
index 716a5c9..13b1c97 100644
--- a/macrostep.el
+++ b/macrostep.el
@@ -425,7 +425,9 @@ Also moves point to the beginning of the returned
s-expression."
As a minor optimization, does not restore the original source
text if NO-RESTORE-P is non-nil. This is safe to do when
collapsing all the sub-expansions of an outer overlay, since the
-outer overlay will restore the original source itself."
+outer overlay will restore the original source itself.
+
+Also removes the overlay from `macrostep-overlays'."
(when (and (overlay-start overlay)
(eq (overlay-buffer overlay) (current-buffer)))
;; If we're cleaning up we don't need to bother restoring text
@@ -435,7 +437,7 @@ outer overlay will restore the original source itself."
(overlay-start overlay) (overlay-end overlay))
(let ((text (overlay-get overlay 'macrostep-original-text)))
(goto-char (overlay-start overlay))
- (macrostep-replace-sexp-at-point text)))
+ (macrostep-replace-sexp-at-point text (stringp text))))
;; Remove overlay from the list and delete it
(setq macrostep-overlays
(delq overlay macrostep-overlays))
@@ -451,21 +453,28 @@ Will not collapse overlays that begin at START and end at
END."
(overlay-get ol 'macrostep-original-text))
(macrostep-collapse-overlay ol t))))
-(defun macrostep-replace-sexp-at-point (sexp)
- "Replace the form following point with SEXP."
+(defun macrostep-replace-sexp-at-point (sexp &optional original)
+ "Replace the form following point with SEXP.
+
+If ORIGINAL is non-nil, SEXP is assumed to be a string
+representing the original source text, and inserted verbatim as a
+replacement for the form following point. Otherwise, if ORIGINAL
+is nil, SEXP is treated as the macro expansion of the source,
+inserted using `macrostep-print-sexp' and pretty-printed using
+`pp-buffer'."
(let ((print-quoted t))
(save-excursion
;; Insert new text first so that existing overlays don't
;; evaporate
- (if (stringp sexp)
- (insert sexp) ; insert original source text
+ (if original
+ (insert sexp) ; insert original source text
(macrostep-print-sexp sexp))
;; Delete the old form and remove any sub-form overlays in it
(let ((start (point)) (end (scan-sexps (point) 1)))
(macrostep-collapse-overlays-in start end)
(delete-region start end)))
- (unless (stringp sexp) ; inserting macro expansion
+ (unless original ; inserting macro expansion
;; point is now before the expanded form; pretty-print it
(narrow-to-region (point) (scan-sexps (point) 1))
(save-excursion
- [nongnu] elpa/macrostep 29fd924 107/110: Move overlay face to a different overlay, (continued)
- [nongnu] elpa/macrostep 29fd924 107/110: Move overlay face to a different overlay, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep d459ded 024/110: bump version number, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 96e0c02 041/110: WIP: Add generic interface for other languages, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e9a95f4 049/110: Fix `macrostep--macro-form-info`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e35b61d 047/110: Add compiler-macro support for SLIME, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 3766ffb 043/110: Hack to propertize macros in SLIME expansions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 522226f 050/110: Improve `macrostep-slime-macro-form-p`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 059dda6 066/110: Also hook into slime-repl-mode, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e582ca7 078/110: Fix trivial bug printing a single non-list form, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 84e5bfa 086/110: Make tests pass again, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2dd3447 004/110: Fix bug with output of macros that expand to a string (e.g. `rx'),
ELPA Syncer <=
- [nongnu] elpa/macrostep 6c4afbe 002/110: Got rid of `macrostep-change-group'. Updated some documentation., ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e2bf1aa 005/110: Change :reverse-video to :inverse-video for e24, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 993a79f 010/110: bump version number, add changelog, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 9cd6742 016/110: Try to be smarter about maintaining buffer state, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep cb2019e 017/110: acknowledgements in docs, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 5c62a4c 021/110: Merge remote-tracking branch 'georgek/backquotes', ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep f026495 025/110: Fix comment typos, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 77c0c1a 023/110: update readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep b04f8db 026/110: Basic support for expanding macros bound by `macrolet', ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 7acce07 028/110: Require `cl-macs` at runtime, ELPA Syncer, 2021/08/07