[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep 4ea178a 045/110: Simplify overlay collapsing
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep 4ea178a 045/110: Simplify overlay collapsing |
Date: |
Sat, 7 Aug 2021 09:17:59 -0400 (EDT) |
branch: elpa/macrostep
commit 4ea178aa57fa643a919a1f8d216bcd022b8c054f
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Simplify overlay collapsing
Instead of treating source text and macro-expansion text differently
when collapsing an overlay, simply save the original text as a string
and restore using `insert`. This makes it easier to provide a generic
interface for other languages.
---
macrostep.el | 68 +++++++++++++++++++++++++++---------------------------------
1 file changed, 31 insertions(+), 37 deletions(-)
diff --git a/macrostep.el b/macrostep.el
index afb63de..12b02e4 100644
--- a/macrostep.el
+++ b/macrostep.el
@@ -401,6 +401,9 @@ buffer and expand the next macro form found, if any."
(interactive)
(let ((sexp (macrostep--macro-form-near-point))
(macrostep-environment (funcall
macrostep-environment-at-point-function))
+ (text (buffer-substring
+ ;; FIXME: make generic (non-sexp languages?)
+ (point) (scan-sexps (point) 1)))
(buffer-major-mode major-mode))
;; Create a dedicated macro-expansion buffer and copy the text to
@@ -413,11 +416,7 @@ buffer and expand the next macro form found, if any."
(funcall buffer-major-mode)
(setq macrostep-expansion-buffer t)
(setq macrostep-outer-environment macrostep-environment)
- (save-excursion
- ;; FIXME: make generic
- (let ((print-level nil)
- (print-length nil))
- (print sexp (current-buffer))))
+ (save-excursion (insert text))
(pop-to-buffer buffer)))
(let* ((inhibit-read-only t)
@@ -425,22 +424,17 @@ buffer and expand the next macro form found, if any."
(existing-ol (macrostep-overlay-at-point))
(macrostep-gensym-depth macrostep-gensym-depth)
(macrostep-gensyms-this-level nil)
- text priority verbatim)
+ priority)
(unless macrostep-mode (macrostep-mode t))
- (if existing-ol ; expanding an expansion
- (setq text sexp
- verbatim nil
- priority (1+ (overlay-get existing-ol 'priority))
-
- macrostep-gensym-depth
- (overlay-get existing-ol 'macrostep-gensym-depth))
- ;; expanding buffer text
- (setq text (buffer-substring
- ;; FIXME: make generic (non-sexp languages?)
- (point) (scan-sexps (point) 1))
- verbatim t
- priority 1
- macrostep-gensym-depth -1))
+ (if existing-ol
+ ;; Expanding part of a previous macro-expansion
+ (progn
+ (setq priority (1+ (overlay-get existing-ol 'priority)))
+ (setq macrostep-gensym-depth
+ (overlay-get existing-ol 'macrostep-gensym-depth)))
+ ;; Expanding source buffer text
+ (setq priority 1)
+ (setq macrostep-gensym-depth -1))
(with-silent-modifications
(atomic-change-group
@@ -459,7 +453,6 @@ buffer and expand the next macro form found, if any."
(overlay-put new-ol 'priority priority)
(overlay-put new-ol 'macrostep-original-text text)
(overlay-put new-ol 'macrostep-gensym-depth macrostep-gensym-depth)
- (overlay-put new-ol 'macrostep-verbatim verbatim)
(push new-ol macrostep-overlays)))))))
(defun macrostep-collapse ()
@@ -675,10 +668,9 @@ Also removes the overlay from `macrostep-overlays'."
(unless no-restore-p
(macrostep-collapse-overlays-in
(overlay-start overlay) (overlay-end overlay))
- (let ((text (overlay-get overlay 'macrostep-original-text))
- (verbatim (overlay-get overlay 'macrostep-verbatim)))
+ (let ((text (overlay-get overlay 'macrostep-original-text)))
(goto-char (overlay-start overlay))
- (macrostep-replace-sexp-at-point text verbatim)))
+ (macrostep-replace-sexp-at-point text t)))
;; Remove overlay from the list and delete it
(setq macrostep-overlays
(delq overlay macrostep-overlays))
@@ -897,19 +889,21 @@ expansion will not be fontified. See also
(+ (or (syntax word)
(syntax symbol)))))
limit t)
- (let ((paren-begin (match-beginning 1)) (paren-end (match-end 1))
- (symbol-begin (match-beginning 2)) (symbol-end (match-end 2)))
- (save-excursion
- (goto-char (match-beginning 0))
- (let ((sexp (slime-sexp-at-point)))
- (when (macrostep-slime-macro-form-p sexp)
- ;; Hack to make `macrostep-next-macro' etc. work.
- ;; TODO: Re-consider how macro forms are marked in
- ;; expanded text.
- (put-text-property paren-begin paren-end
- 'macrostep-expanded-text sexp)
- (put-text-property symbol-begin symbol-end
- 'font-lock-face
'macrostep-macro-face)))))))))
+ (unless (let ((case-fold-search t))
+ (string-match (match-string 2) "lambda"))
+ (let ((paren-begin (match-beginning 1)) (paren-end (match-end 1))
+ (symbol-begin (match-beginning 2)) (symbol-end (match-end 2)))
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (let ((sexp (slime-sexp-at-point)))
+ (when (macrostep-slime-macro-form-p sexp)
+ ;; Hack to make `macrostep-next-macro' etc. work.
+ ;; TODO: Re-consider how macro forms are marked in
+ ;; expanded text.
+ (put-text-property paren-begin paren-end
+ 'macrostep-expanded-text sexp)
+ (put-text-property symbol-begin symbol-end
+ 'font-lock-face
'macrostep-macro-face))))))))))
(defun macrostep-slime-macro-form-p (form)
(slime-eval
- [nongnu] elpa/macrostep cb2019e 017/110: acknowledgements in docs, (continued)
- [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
- [nongnu] elpa/macrostep 51d5b6a 036/110: Fix a bug with printing the first element of a list., ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 07e14e2 032/110: Test for macrostep-environment-at-point, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep c93c2d6 053/110: Language-agnostic macro-form boundaries, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep e3e5c12 034/110: Merge branch 'expand-macrolet', ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 4ea178a 045/110: Simplify overlay collapsing,
ELPA Syncer <=
- [nongnu] elpa/macrostep 2519692 038/110: Restore narrowing, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep c748996 057/110: Tweak macrostep-slime-macro-form-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 3757ec4 033/110: Extend macrostep-environment while printing macrolet body forms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a478a3a 054/110: Bind inhibit-read-only instead of buffer-read-only, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 8d72b62 044/110: Fix indentation in new macrostep-pp function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 8950313 037/110: Bump version number and changelog for 0.8, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 5680278 056/110: Gross hack to macrostep--slime-propertize-macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 31e1dc2 060/110: Detect Elisp macro forms by advising `macroexpand`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep c61b836 062/110: Use SB-WALKER:WALK-FORM to collect macro forms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 39e809a 064/110: swank-macrostep: call PROVIDE at the end, ELPA Syncer, 2021/08/07