joddie / macrostep Goto Github PK
View Code? Open in Web Editor NEWinteractive macro-expander for Emacs
interactive macro-expander for Emacs
Just recently I'm getting (iter ...) is not a macro form
when running macrostep-expand
. This only happens on macros which are imported from a different package than the one the file is in. slime-macroexpand-1
and friends all work as expected.
Hello,
Could this version be tagged 0.9 so that MELPA stable can build it?
Thanks!
Unless `if' has some hidden feature I don't know about, I think there's a spurious colon character (mis-typed comment char?) on,
https://github.com/joddie/macrostep/blob/master/macrostep.el#L324
(defmacro my-bad ()
`(1+ ,(/ 1 0)))
(my-bad)
Using macrostep-expand
on the last form results in an arithmetic error. I'm not sure whether that's intended behaviour, but I'd expect a preview of the code instead. Any thoughts on this?
I would be really useful to be able to expand things that are defined with macrolet. Any clue how macrostep could be expanded to do that?
macrostep-expand
should detect the case where a macro is autoloaded, but not yet loaded, and load the macro's file if necessary.
For instance, in emacs -Q
:
(symbol-function 'define-minor-mode) => (autoload "easy-mmode" 947743 nil t)
If the 5th element of the list is either t
or macro
, then it is indeed an autoloaded macro and should be loaded.
If one simply expands then collapses a macro the buffer is marked as modified but it should not be.
Hi @joddie,
When I start Emacs , I got this warning.
Can you update to use keywords rather than positional arguments?
/.emacs.d/lib/macrostep/macrostep.el: Warning: Use keywords rather than deprecated positional arguments to `define-minor-mode'
Emacs 28.1
With eval-last-sexp
you can evaluate the last expression even if you put your cursor on the whitespace after the outer form, macrostep-expand
however fails with Scan error: "Unbalanced parentheses"
. Would it make sense to remedy this behaviour for more consistency?
Hi, I figured I would link this macrostepper for makefiles, since I find that I use it all the time for expanding makefile variables. It will get confused by various complications but I find it useful enough for my purposes. You mentioned on the previous julia macrostepper you'd
be interested some sort of linkage between extensions, so I figure I would throw it
out there. Unfortunately I havent used julia in some time so haven't looked at that
one in ages.
Would it be possible for the region to be highlighted like normal when in macrostepped code?
Native-compiled on guix with the emacs indicated in the title. The package builds, but three tests fail.
Test macrostep-expand-macrolet-in-separate-buffer backtrace:
error("(%s ...) is not a macro form" dummy-macro-2)
(if (consp sexp) (error "(%s ...) is not a macro form" (car sexp)) (
(condition-case nil (macrostep-next-macro) (error (if (consp sexp) (
(if (funcall macrostep-macro-form-p-function sexp env) nil (conditio
(let ((sexp (funcall macrostep-sexp-at-point-function)) (env (funcal
(save-excursion (if (not (looking-at "[(`]")) (backward-up-list 1))
macrostep-sexp-bounds()
funcall(macrostep-sexp-bounds)
(let* ((end (funcall macrostep-sexp-bounds-function)) (start (if end
macrostep-expand()
(let ((original-buffer (current-buffer))) (macrostep-goto "(dummy-ma
(let ((print-level nil) (print-length nil) (standard-output (current
(progn (emacs-lisp-mode) (let ((print-level nil) (print-length nil)
(unwind-protect (progn (emacs-lisp-mode) (let ((print-level nil) (pr
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(let ((macrostep-expand-in-separate-buffer t)) (let ((temp-buffer (g
(closure (t) nil (let ((macrostep-expand-in-separate-buffer t)) (let
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name macrostep-expand-macrolet-in-separate
ert-run-or-rerun-test(#s(ert--stats :selector "^macrostep" :tests ..
ert-run-tests("^macrostep" #f(compiled-function (event-type &rest ev
ert-run-tests-batch("^macrostep")
(let ((stats (ert-run-tests-batch "^macrostep"))) (if noninteractive
(progn (load-file (expand-file-name "macrostep.el" (file-name-direct
(if noninteractive (progn (load-file (expand-file-name "macrostep.el
load-with-code-conversion("/tmp/guix-build-emacs-macrostep-0.9.2.drv
command-line-1(("-L" "." "-l" "macrostep-test.el" "-f" "ert-run-test
command-line()
normal-top-level()
Test macrostep-expand-macrolet-in-separate-buffer condition:
(error "(dummy-macro-2 ...) is not a macro form")
FAILED 11/15 macrostep-expand-macrolet-in-separate-buffer (0.000447 sec) at macrostep-test.el:324
Entering macro stepper mode. Use e to expand, c to collapse, q to exit.
Entering macro stepper mode. Use e to expand, c to collapse, q to exit.
passed 12/15 macrostep-expand-shadowed-macrolet (0.000703 sec)
Entering macro stepper mode. Use e to expand, c to collapse, q to exit.
Test macrostep-fontify-compiler-macros backtrace:
ert-fail(((should (eq (get-char-property (1+ (point)) 'font-lock-fac
(if (unwind-protect (setq value-233 (apply fn-231 args-232)) (setq f
(let (form-description-235) (if (unwind-protect (setq value-233 (app
(let ((value-233 'ert-form-evaluation-aborted-234)) (let (form-descr
(let* ((fn-231 #'eq) (args-232 (condition-case err (let ((signal-hoo
(let ((print-level nil) (print-length nil) (standard-output (current
(progn (emacs-lisp-mode) (let ((print-level nil) (print-length nil)
(unwind-protect (progn (emacs-lisp-mode) (let ((print-level nil) (pr
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(closure (t) nil (defalias 'macrostep-dummy-macro (cons 'macro #'(la
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name macrostep-fontify-compiler-macros :do
ert-run-or-rerun-test(#s(ert--stats :selector "^macrostep" :tests ..
ert-run-tests("^macrostep" #f(compiled-function (event-type &rest ev
ert-run-tests-batch("^macrostep")
(let ((stats (ert-run-tests-batch "^macrostep"))) (if noninteractive
(progn (load-file (expand-file-name "macrostep.el" (file-name-direct
(if noninteractive (progn (load-file (expand-file-name "macrostep.el
load-with-code-conversion("/tmp/guix-build-emacs-macrostep-0.9.2.drv
command-line-1(("-L" "." "-l" "macrostep-test.el" "-f" "ert-run-test
command-line()
normal-top-level()
Test macrostep-fontify-compiler-macros condition:
(ert-test-failed
((should
(eq (get-char-property ... ...) 'macrostep-compiler-macro-face))
:form (eq nil macrostep-compiler-macro-face) :value nil))
FAILED 13/15 macrostep-fontify-compiler-macros (0.000288 sec) at macrostep-test.el:367
Test macrostep-pp-macrolet-environment backtrace:
ert-fail(((should (eq (get-char-property (point) 'font-lock-face) 'm
(if (unwind-protect (setq value-169 (apply fn-167 args-168)) (setq f
(let (form-description-171) (if (unwind-protect (setq value-169 (app
(let ((value-169 'ert-form-evaluation-aborted-170)) (let (form-descr
(let* ((fn-167 #'eq) (args-168 (condition-case err (let ((signal-hoo
(progn (funcall --cl-search-- "(some-macro (&rest") (let* ((fn-162 #
(let* ((--cl-search-- #'(lambda (text) (progn (macrostep-goto text t
(progn (emacs-lisp-mode) (macrostep-pp '(cl-macrolet ((some-macro (&
(unwind-protect (progn (emacs-lisp-mode) (macrostep-pp '(cl-macrolet
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(closure (t) nil (let ((temp-buffer (generate-new-buffer " *temp*" t
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name macrostep-pp-macrolet-environment :do
ert-run-or-rerun-test(#s(ert--stats :selector "^macrostep" :tests ..
ert-run-tests("^macrostep" #f(compiled-function (event-type &rest ev
ert-run-tests-batch("^macrostep")
(let ((stats (ert-run-tests-batch "^macrostep"))) (if noninteractive
(progn (load-file (expand-file-name "macrostep.el" (file-name-direct
(if noninteractive (progn (load-file (expand-file-name "macrostep.el
load-with-code-conversion("/tmp/guix-build-emacs-macrostep-0.9.2.drv
command-line-1(("-L" "." "-l" "macrostep-test.el" "-f" "ert-run-test
command-line()
normal-top-level()
Test macrostep-pp-macrolet-environment condition:
(ert-test-failed
((should (eq (get-char-property ... ...) 'macrostep-macro-face))
:form (eq nil macrostep-macro-face) :value nil))
FAILED 14/15 macrostep-pp-macrolet-environment (0.000374 sec) at macrostep-test.el:260
passed 15/15 macrostep-print-sexp (0.000138 sec)
Ran 15 tests, 12 results as expected, 3 unexpected (2023-09-27 12:07:41+0000, 0.558410 sec)
3 unexpected results:
FAILED macrostep-expand-macrolet-in-separate-buffer
FAILED macrostep-fontify-compiler-macros
FAILED macrostep-pp-macrolet-environment
This isn't a problem in elisp since empty macros are replaced with nil
, but I just made an extension for makefiles, https://github.com/nverno/macrostep-make, and noticed that when a macro's
definition hasn't been defined, eg.
CC =
then, when
${CC}
is expanded, it is blank but doesn't replace with ${CC}
upon exit from macroexpansion.
A workaround is to expand with " "
instead of ""
. I don't know if this is something to fix on
this end, but thought I would mention it.
THanks
Backquote is technically a macro, and macrostep-mode does not currently treat it correctly when it occurs in expansions.
Is there a way to expand the macro in another buffer, like slime
or imacroexpand
do, and continue the expansions there?
Two motivations:
Hi! This package is awesome!
I found this package use function
instead of #'
.
I want to use #'
but how?
This can be really confusing. Is it enough to save buffer-undo-list
on entering and restore it on exiting the mode?
Need to make sure it works properly with undo-tree
mode too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.