[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/macrostep 2bdc946 082/110: Remove dynamic binding of `macr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/macrostep 2bdc946 082/110: Remove dynamic binding of `macrostep-environment'. |
Date: |
Sat, 7 Aug 2021 09:18:07 -0400 (EDT) |
branch: elpa/macrostep
commit 2bdc946e96a9de6662e91c145fb342a96b91b62f
Author: joddie <jonxfield@gmail.com>
Commit: joddie <jonxfield@gmail.com>
Remove dynamic binding of `macrostep-environment'.
To simplify the generic interface, the local macro-expansion environment
should now be passed as a function argument wherever it is needed.
---
macrostep-test.el | 9 +++++----
macrostep.el | 49 ++++++++++++++++++++++++-------------------------
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/macrostep-test.el b/macrostep-test.el
index 1ae9692..1863b61 100644
--- a/macrostep-test.el
+++ b/macrostep-test.el
@@ -71,9 +71,9 @@
(ert-deftest macrostep-expand-and-collapse ()
(dolist (expander
(list
- #'identity
- (lambda (sexp) `(progn ,sexp ,sexp))
- (lambda (sexp) `(long
+ (lambda (sexp _env) sexp)
+ (lambda (sexp _env) `(progn ,sexp ,sexp))
+ (lambda (sexp _env) `(long
(complicated
(expansion of ,sexp () ())
(with trailing forms))))))
@@ -253,7 +253,8 @@
'(macrolet ((some-macro (&rest forms) (cons 'progn forms)))
(some-macro with (arguments))
(intervening body forms)
- (some-macro with (more) (arguments))))
+ (some-macro with (more) (arguments)))
+ nil)
(cl-flet ((search (text)
(macrostep-goto text t)
;; Leave point on the head of the form
diff --git a/macrostep.el b/macrostep.el
index f8a87c1..fb97c85 100644
--- a/macrostep.el
+++ b/macrostep.el
@@ -216,9 +216,6 @@
"Saved value of buffer-read-only upon entering macrostep mode.")
(make-variable-buffer-local 'macrostep-saved-read-only)
-(defvar macrostep-environment nil
- "Local macro-expansion environment, including macros declared by
`cl-macrolet'.")
-
(defvar macrostep-expansion-buffer nil
"Non-nil if the current buffer is a macro-expansion buffer.")
(make-variable-buffer-local 'macrostep-expansion-buffer)
@@ -368,11 +365,13 @@ The default value, `macrostep-expand-1', is specific to
Emacs Lisp.")
#'macrostep-pp
"Function to pretty-print macro expansions.
-It will be called with one argument, the macro expansion returned
-from `macrostep-expand-1-function', and should insert a
-pretty-printed representation at point in the current buffer,
-leaving point just after the inserted representation, without
-altering any other text in the current buffer.
+It will be called with two arguments, FORM and ENVIRONMENT, the
+return values of `macrostep-sexp-at-point-function' and
+`macrostep-environment-at-point-function' respectively. It
+should insert a pretty-printed representation at point in the
+current buffer, leaving point just after the inserted
+representation, without altering any other text in the current
+buffer.
The default value, `macrostep-pp', is specific to Emacs Lisp.")
@@ -477,9 +476,8 @@ buffer and expand the next macro form found, if any."
(let* ((sexp (funcall macrostep-sexp-at-point-function))
(end (copy-marker end))
(text (buffer-substring start end))
- (macrostep-environment
- (funcall macrostep-environment-at-point-function))
- (expansion (funcall macrostep-expand-1-function sexp)))
+ (env (funcall macrostep-environment-at-point-function))
+ (expansion (funcall macrostep-expand-1-function sexp env)))
;; Create a dedicated macro-expansion buffer and copy the text to
;; be expanded into it, if required
@@ -491,7 +489,7 @@ buffer and expand the next macro form found, if any."
(set-buffer buffer)
(funcall mode)
(setq macrostep-expansion-buffer t)
- (setq macrostep-outer-environment macrostep-environment)
+ (setq macrostep-outer-environment env)
(save-excursion
(setq start (point))
(insert text)
@@ -517,7 +515,7 @@ buffer and expand the next macro form found, if any."
(let ((inhibit-read-only t))
(save-excursion
;; Insert expansion
- (funcall macrostep-print-function expansion)
+ (funcall macrostep-print-function expansion env)
;; Delete the original form
(macrostep-collapse-overlays-in (point) end)
(delete-region (point) end)
@@ -658,9 +656,9 @@ Returns a cons of buffer positions, (START . END)."
(if (equal (char-before) ?`)
(backward-char))
(let ((sexp (funcall macrostep-sexp-at-point-function))
- (macrostep-environment (funcall
macrostep-environment-at-point-function)))
+ (env (funcall macrostep-environment-at-point-function)))
;; If this isn't a macro form, try to find the next one in the buffer
- (unless (funcall macrostep-macro-form-p-function sexp)
+ (unless (funcall macrostep-macro-form-p-function sexp env)
(condition-case nil
(macrostep-next-macro)
(error
@@ -680,7 +678,7 @@ expansion, so that they can be fontified consistently. (See
(or (get-text-property (point) 'macrostep-expanded-text)
(sexp-at-point)))
-(defun macrostep-macro-form-p (form)
+(defun macrostep-macro-form-p (form environment)
"Return non-nil if FORM would be evaluated via macro expansion.
If FORM is an invocation of a macro defined by `defmacro' or an
@@ -691,13 +689,14 @@ call to a function with a compiler macro, return the
symbol
`compiler-macro'.
Otherwise, return nil."
- (car (macrostep--macro-form-info form t)))
+ (car (macrostep--macro-form-info form environment t)))
-(defun macrostep--macro-form-info (form &optional inhibit-autoload)
+(defun macrostep--macro-form-info (form environment &optional inhibit-autoload)
"Return information about macro definitions that apply to FORM.
-If no macros are involved in the evaluation of FORM, returns nil.
-Otherwise, returns a cons (TYPE . DEFINITION).
+If no macros are involved in the evaluation of FORM within
+ENVIRONMENT, returns nil. Otherwise, returns a cons (TYPE
+. DEFINITION).
If FORM would be evaluated by a macro defined by `defmacro',
`cl-macrolet', etc., TYPE is the symbol `macro' and DEFINITION is
@@ -717,7 +716,7 @@ value of DEFINITION in the result will be nil."
(pcase form
(`(,(and (pred symbolp) head) . ,_)
(let ((macrolet-definition
- (assoc-default head macrostep-environment 'eq)))
+ (assoc-default head environment 'eq)))
(if macrolet-definition
`(macro . ,macrolet-definition)
(let ((compiler-macro-definition
@@ -739,11 +738,11 @@ value of DEFINITION in the result will be nil."
(void-function nil)))))))
(_ nil)))
-(defun macrostep-expand-1 (form)
+(defun macrostep-expand-1 (form environment)
"Return result of macro-expanding the top level of FORM by exactly one step.
Unlike `macroexpand', this function does not continue macro
expansion until a non-macro-call results."
- (pcase (macrostep--macro-form-info form)
+ (pcase (macrostep--macro-form-info form environment)
(`nil form)
(`(macro . ,definition)
(apply definition (cdr form)))
@@ -883,12 +882,12 @@ Controls the printing of sub-forms in
`macrostep-print-sexp'.")
(defvar macrostep-collected-compiler-macro-forms nil
"A list of compiler-macro forms to be highlighted in
`macrostep-print-sexp'.")
-(defun macrostep-pp (sexp)
+(defun macrostep-pp (sexp environment)
"Pretty-print SEXP, fontifying macro forms and uninterned symbols."
(cl-destructuring-bind
(macrostep-collected-macro-form-alist
macrostep-collected-compiler-macro-forms)
- (macrostep-collect-macro-forms sexp macrostep-environment)
+ (macrostep-collect-macro-forms sexp environment)
(let ((print-quoted t))
(macrostep-print-sexp sexp)
;; Point is now after the expanded form; pretty-print it
- [nongnu] elpa/macrostep c61b836 062/110: Use SB-WALKER:WALK-FORM to collect macro forms, (continued)
- [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
- [nongnu] elpa/macrostep 1be6c4d 061/110: Extract Elisp macro environments accurately, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep d9c7629 063/110: Improvements to Elisp environment handling, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 59972eb 071/110: Fix handling of subforms contained within other subforms, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a0ae61c 073/110: Properly handle forms not present in the expansion, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 817322b 074/110: Properly place the macrostep[-compiler]-macro-face, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep aa40d97 076/110: Test expansion within Elisp macro-defining macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 1edee85 080/110: Reorganise and comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep bbfb033 081/110: Reorganise and document generic interface, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2bdc946 082/110: Remove dynamic binding of `macrostep-environment'.,
ELPA Syncer <=
- [nongnu] elpa/macrostep 31a23eb 085/110: Toggle separate-buffer expansion with prefix (#8), ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 47cbacb 087/110: Define `macrostep-propertize` before using it, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep a8e730e 089/110: Improve Makefile, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 2473a6f 094/110: Pass START and END args to sexp-at-point-function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 03d4d7b 096/110: Add basic C macro expansion via cmacexp.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 9a6b04a 100/110: Restore Emacs 23 compatibility, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep d48e52b 101/110: Add tests for compiler-macro expansion, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep aa59895 103/110: Add .travis.yml, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 7b2c1f3 108/110: Load all autoloaded macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/macrostep 4d75baf 003/110: Bump version number, ELPA Syncer, 2021/08/07