guix-devel
[Top][All Lists]
Advanced

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

[PATCH 1/4] emacs: Add 'guix-devel-with-definition'.


From: Alex Kost
Subject: [PATCH 1/4] emacs: Add 'guix-devel-with-definition'.
Date: Fri, 2 Oct 2015 16:04:03 +0300

* emacs/guix-devel.el (guix-devel-with-definition): New macro.
  (guix-devel-build-package-definition): Use it.
  (guix-devel-font-lock-keywords): New variable.
---
 emacs/guix-devel.el | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index 8a6fc1e..ee7629f 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -88,12 +88,21 @@ Interactively, use the module defined by the current scheme 
file."
       (guix-devel-setup-repl repl)
       (push process guix-devel-repl-processes))))
 
+(defmacro guix-devel-with-definition (def-var &rest body)
+  "Run BODY with the current guile definition bound to DEF-VAR.
+Bind DEF-VAR variable to the name of the current top-level
+definition, setup the current REPL, use the current module, and
+run BODY."
+  (declare (indent 1) (debug (symbolp body)))
+  `(let ((,def-var (guix-guile-current-definition)))
+     (guix-devel-setup-repl-maybe)
+     (guix-devel-use-modules (guix-guile-current-module))
+     ,@body))
+
 (defun guix-devel-build-package-definition ()
   "Build a package defined by the current top-level variable definition."
   (interactive)
-  (let ((def (guix-guile-current-definition)))
-    (guix-devel-setup-repl-maybe)
-    (guix-devel-use-modules (guix-guile-current-module))
+  (guix-devel-with-definition def
     (when (or (not guix-operation-confirm)
               (guix-operation-prompt (format "Build '%s'?" def)))
       (guix-geiser-eval-in-repl
@@ -184,6 +193,13 @@ bindings:
   (when guix-devel-activate-mode
     (guix-devel-mode)))
 
+
+(defvar guix-devel-font-lock-keywords
+  (eval-when-compile
+    `((,(rx "(" (group "guix-devel-with-definition") symbol-end) . 1))))
+
+(font-lock-add-keywords 'emacs-lisp-mode guix-devel-font-lock-keywords)
+
 (provide 'guix-devel)
 
 ;;; guix-devel.el ends here
-- 
2.5.0




reply via email to

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