From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 7/7] emacs: Add 'guix-devel-use-current-module'. Date: Sat, 25 Jul 2015 11:49:57 +0300 Message-ID: <1437814197-6321-8-git-send-email-alezost@gmail.com> References: <1437814197-6321-1-git-send-email-alezost@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIvAH-0004YK-9a for guix-devel@gnu.org; Sat, 25 Jul 2015 04:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIvAE-00057N-Cq for guix-devel@gnu.org; Sat, 25 Jul 2015 04:50:40 -0400 Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:32818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIvAE-00056i-1t for guix-devel@gnu.org; Sat, 25 Jul 2015 04:50:38 -0400 Received: by laah7 with SMTP id h7so25718597laa.0 for ; Sat, 25 Jul 2015 01:50:37 -0700 (PDT) In-Reply-To: <1437814197-6321-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 Cc: Alex Kost Suggested by Ludovic Courtès . * emacs/guix-guile.el (guix-guile-definition-regexp): New variable. (guix-guile-current-definition): New function. * emacs/guix-devel.el (guix-devel-build-current-package-definition): New command. * doc/emacs.texi (Emacs Development): Document it. --- doc/emacs.texi | 6 ++++++ emacs/guix-devel.el | 9 +++++++++ emacs/guix-guile.el | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/doc/emacs.texi b/doc/emacs.texi index 6920bef..5f1584c 100644 --- a/doc/emacs.texi +++ b/doc/emacs.texi @@ -571,6 +571,12 @@ want to use a module it defines, so you switch to the Geiser REPL and write @code{,use (some module)} there. You may just use this command instead. +@item M-x guix-devel-build-current-package-definition +Build package defined by the current variable definition. If you +modified the current package definition, don't forget to reevaluate it +before calling this command (for example, with @kbd{C-M-x} (@pxref{To +eval or not to eval,,, geiser, Geiser User Manual})). + @end table And as always if you use a command often, it is a good idea to bind a diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el index e99b289..1d3f381 100644 --- a/emacs/guix-devel.el +++ b/emacs/guix-devel.el @@ -39,6 +39,15 @@ (guix-devel-use-modules module) (message "Using %s module." module))) +;;;###autoload +(defun guix-devel-build-current-package-definition () + "Build package defined by the current top-level variable definition." + (interactive) + (guix-devel-use-modules "(guix scripts build)" + (guix-guile-current-module)) + (guix-geiser-call-in-repl "build-package" + (guix-guile-current-definition))) + (provide 'guix-devel) ;;; guix-devel.el ends here diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el index ffa8848..aa5d747 100644 --- a/emacs/guix-guile.el +++ b/emacs/guix-guile.el @@ -26,6 +26,23 @@ (require 'geiser-guile) +(defvar guix-guile-definition-regexp + (rx bol "(define" + (zero-or-one "*") + (zero-or-one "-public") + (one-or-more space) + (zero-or-one "(") + (group (one-or-more (or word (syntax symbol))))) + "Regexp used to find the guile definition.") + +(defun guix-guile-current-definition () + "Return string with name of the current top-level guile definition." + (save-excursion + (beginning-of-defun) + (if (looking-at guix-guile-definition-regexp) + (match-string-no-properties 1) + (error "Couldn't find the current definition")))) + (defun guix-guile-current-module () "Return string with current guile module. Return nil, if current buffer does not define a module." -- 2.4.3