diff --git a/lispy-test.el b/lispy-test.el index 6bd3de0c..a3adcb5e 100644 --- a/lispy-test.el +++ b/lispy-test.el @@ -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)))) diff --git a/lispy.el b/lispy.el index e2f20427..45741252 100644 --- a/lispy.el +++ b/lispy.el @@ -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)