From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 1/4] emacs: Add 'guix-devel-with-definition'. Date: Fri, 2 Oct 2015 16:04:03 +0300 Message-ID: <1443791046-1015-2-git-send-email-alezost@gmail.com> References: <1443791046-1015-1-git-send-email-alezost@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi00j-0007E6-ES for guix-devel@gnu.org; Fri, 02 Oct 2015 09:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi00e-0001pX-Sh for guix-devel@gnu.org; Fri, 02 Oct 2015 09:04:29 -0400 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:36013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi00e-0001pO-Ln for guix-devel@gnu.org; Fri, 02 Oct 2015 09:04:24 -0400 Received: by lbcao8 with SMTP id ao8so26068262lbc.3 for ; Fri, 02 Oct 2015 06:04:24 -0700 (PDT) Received: from localhost.localdomain ([217.107.192.146]) by smtp.gmail.com with ESMTPSA id a188sm1516555lfa.9.2015.10.02.06.04.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Oct 2015 06:04:23 -0700 (PDT) In-Reply-To: <1443791046-1015-1-git-send-email-alezost@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org * 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