Skip to content

Save the buffer associated with the importjs command #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions plugin/import-js.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
(require 'grizzl))

(defvar import-js-handler nil "Current import-js output handler")
(defvar import-js-handler-buffer nil "Current import-js buffer to write to when handler is invoked.")
(defvar import-js-output "" "Partial import-js output")
(defvar import-js-process nil "Current import-js process")
(defvar import-js-current-project-root nil "Current project root")
Expand All @@ -51,6 +52,7 @@
(let ((input-json (import-js-json-encode-alist (append input-alist
`(("fileContent" . ,(buffer-string))
("pathToFile" . ,(buffer-file-name)))))))
(setq import-js-handler-buffer (current-buffer))
(process-send-string import-js-process input-json)
(process-send-string import-js-process "\n")))

Expand All @@ -76,8 +78,11 @@
(defun import-js-write-content (import-data)
"Write output data from import-js to the buffer"
(let ((file-content (cdr (assoc 'fileContent import-data))))
(write-region file-content nil buffer-file-name))
(revert-buffer t t t))
(write-region file-content nil (buffer-file-name import-js-handler-buffer)))
(save-window-excursion
(switch-to-buffer import-js-handler-buffer)
(revert-buffer t t t))
(setq import-js-handler-buffer nil))

(defun import-js-add (add-alist)
"Resolves an import with multiple matches"
Expand Down