Skip to content
Draft
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions lispy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,29 @@ Insert KEY if there's no command."
(should (equal
(lispy--read "#m(foo bar)")
'(ly-raw lisp-macro "#m(foo bar)")))
;; Guix gexp
(cl-flet ((test-gexp (expected)
(let ((actual (lispy--read
(with-temp-buffer
(scheme-mode)
(insert expected)
(buffer-string))))
(expected `(ly-raw lisp-macro ,expected)))
(should (equal actual expected)))))
;; gexp
(test-gexp "#~a")
;; ungexp
(test-gexp "#$a")
;; ungexp
(test-gexp "#$a:b")
;; ungexp-splicing
(test-gexp "#$@a")
;; ungexp-native
(test-gexp "#+a")
;; ungexp-native
(test-gexp "#+a:b")
;; ungexp-native-splicing
(test-gexp "#+@a"))
(should (equal
(lispy--read ",(or body)")
'(ly-raw \, (or body))))
Expand Down
20 changes: 20 additions & 0 deletions lispy.el
Original file line number Diff line number Diff line change
Expand Up @@ -7322,6 +7322,26 @@ See https://clojure.org/guides/weird_characters#_character_literal.")
beg (point))))
(delete-region beg (point))
(insert rep))))
;; ——— Guix gexp (in Guile Scheme)
;; Ref https://guix.gnu.org/manual/devel/en/html_node/G_002dExpressions.html#index-_0023_007eexp
;;
;; This is a regular symbol, but as the result here is passed to
;; `read', we have to use another construct.
;;
;; Matches
;; - gexp :: #~
;; - ungexp :: #$
;; - ungexp-splicing :: #$@
;; - ungexp-native :: #+
;; - ungexp-native-splicing #+@
(when (eq major-mode 'scheme-mode)
(goto-char (point-min))
(while (re-search-forward "\\(#~\\|#\\$\\|#\\$@\\|#+\\|#+@\\)" nil t)
(unless (lispy--in-string-or-comment-p)
(save-excursion
(forward-sexp)
(insert "\")"))
(insert "(ly-raw lisp-macro \""))))
;; ——— strings ————————————————
(goto-char (point-min))
(while (re-search-forward "\"" nil t)
Expand Down