From c3dd696e8f1e8bbc9efd34b830b53e81ee63cb70 Mon Sep 17 00:00:00 2001 From: DinoChiesa Date: Wed, 1 Jan 2025 02:40:10 +0000 Subject: [PATCH] feat: use process-file to allw eval-buffer to work over tramp --- jsonnet-mode.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/jsonnet-mode.el b/jsonnet-mode.el index fa77574..d672f91 100644 --- a/jsonnet-mode.el +++ b/jsonnet-mode.el @@ -643,7 +643,8 @@ TYPE is an opening paren-like character." ;; Utilities for evaluating and jumping around Jsonnet code. ;;;###autoload (defun jsonnet-eval-buffer () - "Run jsonnet with the path of the current file." + "Run jsonnet with the path of the current file. This also works for +remote files accessed over TRAMP." (interactive) (let ((file-to-eval (file-truename (buffer-file-name))) (search-dirs jsonnet-library-search-directories) @@ -659,16 +660,18 @@ TYPE is an opening paren-like character." (cl-loop for dir in search-dirs collect "-J" collect dir) - (list file-to-eval)))) + (list (file-local-name file-to-eval)))) + (dir-to-use-for-process-file (file-name-directory (buffer-file-name)))) (with-current-buffer (get-buffer-create output-buffer-name) (setq buffer-read-only nil) (erase-buffer) - (if (zerop (apply #'call-process cmd nil t nil args)) - (progn - (when (fboundp 'json-mode) - (json-mode)) - (view-mode)) - (compilation-mode nil)) + (let ((default-directory dir-to-use-for-process-file)) + (if (zerop (apply #'process-file cmd nil t nil args)) + (progn + (when (fboundp 'json-mode) + (json-mode)) + (view-mode)) + (compilation-mode nil))) (goto-char (point-min)) (display-buffer (current-buffer) '(nil (inhibit-same-window . t)))))))