Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created January 12, 2023 15:44
Show Gist options
  • Save dotemacs/c194d071b33320100abbf57b439ae34e to your computer and use it in GitHub Desktop.
Save dotemacs/c194d071b33320100abbf57b439ae34e to your computer and use it in GitHub Desktop.
Rough first draft of antifennel.el, a way to call `antifennel` CLI from within Emacs buffers
;; antifennel.el --- Turn Lua code into Fennel code
(defgroup antifennel nil
"Tool to convert Lua code into Fennel code."
:group 'tools)
(defcustom antifennel-cli "antifennel"
"Path to the antifennel executable"
:type 'string
:group 'antifennel)
;;;###autoload
(defun antifennel (beginning end)
(interactive "r")
(save-excursion
(kill-ring-save beginning end)
(let ((temp-file (make-temp-file "antifennel")))
(write-region (substring-no-properties (car kill-ring)) nil temp-file 'append)
(thread-first (list antifennel-cli temp-file)
(string-join " ")
shell-command-to-string
kill-new)
(switch-to-buffer
(get-buffer-create "*antifennel*"))
(insert (car kill-ring-yank-pointer)))))
(provide 'antifennel)
;;; antifennel.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment