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

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

[nongnu] elpa/nix-mode a8a513770a 436/500: Simplify some functions


From: ELPA Syncer
Subject: [nongnu] elpa/nix-mode a8a513770a 436/500: Simplify some functions
Date: Sat, 29 Jan 2022 08:27:54 -0500 (EST)

branch: elpa/nix-mode
commit a8a513770a61ca425f876e10bf7ea11d5c82d7c9
Author: Daniel Nagy <danielnagy@posteo.de>
Commit: Daniel Nagy <danielnagy@posteo.de>

    Simplify some functions
    
    Reduce the number of explicit temp buffers used.
---
 nix.el | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/nix.el b/nix.el
index ede66d7790..2ea7d09b9b 100644
--- a/nix.el
+++ b/nix.el
@@ -17,6 +17,7 @@
 ;;; Code:
 
 (require 'pcomplete)
+(require 'json)
 
 (defgroup nix nil
   "Nix-related customizations"
@@ -59,35 +60,24 @@
 
 (defun nix-system ()
   "Get the current system tuple."
-  (let ((stdout (generate-new-buffer "nix eval"))
-        result)
-    (call-process nix-executable nil (list stdout nil) nil
-                 "eval" "--raw" "(builtins.currentSystem)")
-    (with-current-buffer stdout (setq result (buffer-string)))
-    (kill-buffer stdout)
-    result))
+  (with-temp-buffer
+    (call-process nix-executable nil (list t nil) nil "eval" "--raw" 
"(builtins.currentSystem)")
+    (buffer-string)))
 
 (defvar nix-version nil)
 (defun nix-version ()
   "Get the version of Nix"
-  (if nix-version nix-version
-    (let ((stdout (generate-new-buffer "nix eval"))
-          result)
-      (call-process nix-executable nil (list stdout nil) nil "--version")
-      (with-current-buffer stdout (setq result (buffer-string)))
-      (kill-buffer stdout)
-      result)))
+  (or nix-version
+    (with-temp-buffer
+      (call-process nix-executable nil (list t nil) nil "--version")
+      (buffer-string))))
 
 (defun nix-show-config ()
   "Show nix config."
-  (let ((stdout (generate-new-buffer "nix config"))
-        result)
-    (call-process nix-executable nil (list stdout nil) nil "show-config" 
"--json")
-    (setq result (with-current-buffer stdout
-                  (goto-char (point-min))
-                  (json-read)))
-    (kill-buffer stdout)
-    result))
+  (with-temp-buffer
+    (call-process nix-executable nil (list t nil) nil "show-config" "--json")
+    (goto-char (point-min))
+    (json-read)))
 
 (defvar nix-commands
   '("add-to-store"



reply via email to

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