Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M-x lisp-macroexpand-in-place #1289

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions extensions/lisp-mode/macroexpand.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
(backward-up-list point)
(skip-chars-backward point #'syntax-expr-prefix-char-p))
(values point
(form-offset (copy-point point :temporary) 1)))
(form-offset (copy-point point :temporary) 1)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the indentation out of alignment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a bug in #'indent-buffer, It has been happening in other spots too.

Screencast.from.2024-02-05.18-28-40.webm


(defmacro with-form-points ((start end point) &body body)
(check-type start symbol)
Expand Down Expand Up @@ -223,8 +223,8 @@
"Press \"q\" to undo.
Do you want to disable this message in the future?"
:gravity (make-instance 'lem/popup-window::gravity-cursor
:offset-x 1
:offset-y 1))
:offset-x 1
:offset-y 1))
(lisp-macrostep-disable-help)))))

(defun guard () (error 'read-only-error))
Expand All @@ -236,23 +236,33 @@ Do you want to disable this message in the future?"
(orig-package-name (buffer-package (current-buffer) "CL-USER"))
(p (and self (copy-point (current-point) :temporary))))
(lisp-eval-async `(,expander ,(lem-lisp-mode/internal::form-string-at-point))
(lambda (string)
(let ((buffer (make-buffer "*lisp-macroexpand*")))
(with-buffer-read-only buffer nil
(unless self (erase-buffer buffer))
(change-buffer-mode buffer 'lisp-mode)
(setf (buffer-package buffer) orig-package-name)
(when self
(move-point (current-point) p)
(kill-sexp))
(insert-string (buffer-point buffer)
string)
(indent-points (buffer-start-point buffer)
(buffer-end-point buffer))
(with-pop-up-typeout-window (s buffer)
(declare (ignore s)))
(when self
(move-point (buffer-point buffer) p))))))))
(lambda (string)
(let ((buffer (make-buffer "*lisp-macroexpand*")))
(with-buffer-read-only buffer nil
(unless self (erase-buffer buffer))
(change-buffer-mode buffer 'lisp-mode)
(setf (buffer-package buffer) orig-package-name)
(when self
(move-point (current-point) p)
(kill-sexp))
(insert-string (buffer-point buffer)
string)
(indent-points (buffer-start-point buffer)
(buffer-end-point buffer))
(with-pop-up-typeout-window (s buffer)
(declare (ignore s)))
(when self
(move-point (buffer-point buffer) p))))))))

(define-command lisp-macroexpand-in-place () ()
(check-connection)
(lisp-eval-async
`(micros:swank-macroexpand-1
(lem-lisp-mode/internal::form-string-at-point))
(lambda (string)
(kill-sexp)
(insert-string (current-point) string)
(indent-buffer (current-buffer)))))

(define-command lisp-macroexpand () ()
(check-connection)
Expand Down
Loading