branch: master commit a72314c42e153945de2508363f47338e6d3916b2 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Write temp files. --- context-coloring.el | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 7674faa..d498bbd 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -80,6 +80,15 @@ For example: 'context-coloring-depth-1-face'." (move-to-column column) (point))) +(defun context-coloring-save-buffer-to-temp () + "Save buffer to temp file. +Return the name of the temporary file." + (let ((file-name (make-temp-file "context-coloring"))) + ;; Do not flush short-lived temporary files onto disk. + (let ((write-region-inhibit-fsync t)) + (write-region nil nil file-name nil 0)) + file-name)) + ;;; The coloring. (defconst context-coloring-path @@ -87,12 +96,11 @@ For example: 'context-coloring-depth-1-face'." (defun context-coloring-propertize-region (start end) (interactive) - (let* ((json (shell-command-to-string - (format "echo '%s' | %s" - (buffer-substring-no-properties - (point-min) - (point-max)) - (expand-file-name "./tokenizer/tokenizer" context-coloring-path)))) + (let* ((temp-file (context-coloring-save-buffer-to-temp)) + (json (shell-command-to-string + (format "%s < %s" + (expand-file-name "./tokenizer/tokenizer" context-coloring-path) + temp-file))) (tokens (let ((json-array-type 'list)) (json-read-from-string json)))) (with-silent-modifications