emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master a72314c 008/271: Write temp files.


From: Jackson Ray Hamilton
Subject: [elpa] master a72314c 008/271: Write temp files.
Date: Thu, 05 Feb 2015 18:29:23 +0000

branch: master
commit a72314c42e153945de2508363f47338e6d3916b2
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]