[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
From: |
Alex Kost |
Subject: |
[PATCH 4/7] emacs: Add 'guix-devel-use-current-module'. |
Date: |
Sat, 25 Jul 2015 11:49:54 +0300 |
* emacs/guix-guile.el (guix-guile-current-module): New function.
* emacs/guix-devel.el: New file.
(guix-devel-use-modules, guix-devel-use-current-module): New functions.
* doc/emacs.texi (Emacs Development): New node. Document
'guix-devel-use-current-module'.
---
doc/emacs.texi | 29 ++++++++++++++++++++++++++++-
emacs/guix-devel.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
emacs/guix-guile.el | 13 +++++++++++++
3 files changed, 85 insertions(+), 1 deletion(-)
create mode 100644 emacs/guix-devel.el
diff --git a/doc/emacs.texi b/doc/emacs.texi
index 180037a..6920bef 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -19,7 +19,8 @@ guix package}). Specifically, ``guix.el'' makes it easy to:
* Usage: Emacs Usage. Using the interface.
* Configuration: Emacs Configuration. Configuring the interface.
* Prettify Mode: Emacs Prettify. Abbreviating @file{/gnu/store/@dots{}}
file names.
-* Completions: Emacs Completions. Completing @command{guix} shell
command.
+* Completions: Emacs Completions. Completing @command{guix} shell command.
+* Development: Emacs Development. Tools for Guix developers.
@end menu
@node Emacs Initial Setup
@@ -554,3 +555,29 @@ something:
@item @code{guix lint --checkers=synopsis,address@hidden
@end itemize
+
+
address@hidden Emacs Development
address@hidden Development
+
+This section describes some additional commands for Guix developers who
+use Geiser to work with guile code.
+
address@hidden @kbd
+
address@hidden M-x guix-devel-use-current-module
+Use the current guile module. Often after opening a scheme file, you
+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.
+
address@hidden table
+
+And as always if you use a command often, it is a good idea to bind a
+key to it, for example like this:
+
address@hidden
+(with-eval-after-load 'scheme
+ (define-key scheme-mode-map (kbd "C-c u")
+ 'guix-devel-use-current-module))
address@hidden example
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
new file mode 100644
index 0000000..e99b289
--- /dev/null
+++ b/emacs/guix-devel.el
@@ -0,0 +1,44 @@
+;;; guix-devel.el --- Development tools
+
+;; Copyright © 2015 Alex Kost <address@hidden>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides commands useful for developing Guix (or even arbitrary
+;; guile code) with Geiser.
+
+;;; Code:
+
+(require 'guix-guile)
+(require 'guix-geiser)
+
+(defun guix-devel-use-modules (&rest modules)
+ "Use guile MODULES."
+ (apply #'guix-geiser-call "use-modules" modules))
+
+;;;###autoload
+(defun guix-devel-use-current-module ()
+ "Use the current guile module."
+ (interactive)
+ (let ((module (guix-guile-current-module)))
+ (guix-devel-use-modules module)
+ (message "Using %s module." module)))
+
+(provide 'guix-devel)
+
+;;; guix-devel.el ends here
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index 87af192..ffa8848 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -24,6 +24,19 @@
;;; Code:
+(require 'geiser-guile)
+
+(defun guix-guile-current-module ()
+ "Return string with current guile module.
+Return nil, if current buffer does not define a module."
+ ;; Modified version of `geiser-guile--get-module'.
+ (save-excursion
+ (geiser-syntax--pop-to-top)
+ (when (or (re-search-backward geiser-guile--module-re nil t)
+ (looking-at geiser-guile--library-re)
+ (re-search-forward geiser-guile--module-re nil t))
+ (match-string-no-properties 1))))
+
(defun guix-guile-make-call-expression (proc &rest args)
"Return \"(PROC ARGS ...)\" string.
PROC and ARGS should be strings."
--
2.4.3
[PATCH 3/7] emacs: Add code to call guile procedures., Alex Kost, 2015/07/25
[PATCH 5/7] ui: Add 'show-derivation-outputs'., Alex Kost, 2015/07/25
[PATCH 6/7] guix build: Add 'build-package'., Alex Kost, 2015/07/25
[PATCH 7/7] emacs: Add 'guix-devel-use-current-module'., Alex Kost, 2015/07/25