diff --git a/racket-hash-lang.el b/racket-hash-lang.el index 9113947b..5c02d11d 100644 --- a/racket-hash-lang.el +++ b/racket-hash-lang.el @@ -931,6 +931,27 @@ rhombus\"." ,input t)))) +(defun org-babel-edit-prep:racket-hash-lang (babel-info) + "Recreate back-end hash-lang object using :shebang property. + +`org-edit-src-code' calls us AFTER the `racket-hash-lang-mode' +buffer is created. So if there is a :shebang property with +\"#lang foo\", we need to recreate the back end object using the +option where we can supply this." + (pcase babel-info + (`(,_racket-hash-lang ,_contents ,props . ,_) + (when-let (shebang (cdr (assq :shebang props))) + ;; re-create back end hash-lang object + (racket--hash-lang-delete) + (setq-local racket--hash-lang-id + (racket--cmd/await + nil + `(hash-lang + create + ,(cl-incf racket--hash-lang-next-id) + ,shebang + ,(buffer-substring-no-properties (point-min) (point-max))))))))) + (provide 'racket-hash-lang) ;; racket-hash-lang.el ends here