Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-08-26 Thread Ludovic Courtès
Alex Kost alez...@gmail.com skribis:

 Ludovic Courtès (2015-08-18 17:05 +0300) wrote:

[...]

 +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.

 Could you mention a use case here?  Like:

   For instance, you may call this command while visiting a file that
   defines packages; you can then switch to the associated REPL with
   @kbd{C-c C-z}, which will be in the current module, which is handy.

 The REPL will not be in the current module.  M-x
 guix-devel-use-current-module is the equivalent of ,use, not
 ,module.  I thought the documentation was clear about that, no?

Now that I reread it, it seems clear, indeed.  Forget my previous
comment.

 The “-devel” part might make it sound like it has an effect similar to
 ‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
 that they must set ‘guix-load-path’ appropriately?

 Setting ‘guix-load-path’ will not take any effect here.  The whole point
 of this guix-devel stuff is to provide additional commands for
 scheme-mode, like Geiser does.  And these additional commands are
 independent from Guix REPL; they are called in the current Geiser REPL
 the same way you would use other Geiser commands.

Right, sorry for messing things up!

Thanks,
Ludo’.



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-08-19 Thread Alex Kost
Ludovic Courtès (2015-08-18 17:05 +0300) wrote:

 Alex Kost alez...@gmail.com skribis:

 * 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'.

 [...]

 +@node Emacs Development
 +@subsection Development
 +
 +This section describes some additional commands for Guix developers who
 +use Geiser to work with guile code.

 s/guile/Guile/

 It’s fine to leave this section here, but there should be a sentence
 under “Contributing” with a cross-reference to here.

OK.

 +@table @kbd
 +
 +@item M-x guix-devel-use-current-module
 +Use the current guile module.  Often after opening a scheme file, you

 Capitalize “Guile” and “Scheme” here.

 +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.

 Could you mention a use case here?  Like:

   For instance, you may call this command while visiting a file that
   defines packages; you can then switch to the associated REPL with
   @kbd{C-c C-z}, which will be in the current module, which is handy.

The REPL will not be in the current module.  M-x
guix-devel-use-current-module is the equivalent of ,use, not
,module.  I thought the documentation was clear about that, no?

For switching to the current module, Geiser provides C-c C-a or
C-u C-c C-z.

 The “-devel” part might make it sound like it has an effect similar to
 ‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
 that they must set ‘guix-load-path’ appropriately?

Setting ‘guix-load-path’ will not take any effect here.  The whole point
of this guix-devel stuff is to provide additional commands for
scheme-mode, like Geiser does.  And these additional commands are
independent from Guix REPL; they are called in the current Geiser REPL
the same way you would use other Geiser commands.

So, for example, you open some guile file, you press some key bound to
‘guix-devel-use-current-module’ command to use this module in the
current Geiser REPL.  Then (if it's a module with guix packages), you
press another key to build the current package, or (in future) to
download the current package source, etc.

 Otherwise OK, thanks!

Thank you!

-- 
Alex



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-08-18 Thread Ludovic Courtès
Alex Kost alez...@gmail.com skribis:

 * 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'.

[...]

 +@node Emacs Development
 +@subsection Development
 +
 +This section describes some additional commands for Guix developers who
 +use Geiser to work with guile code.

s/guile/Guile/

It’s fine to leave this section here, but there should be a sentence
under “Contributing” with a cross-reference to here.

 +@table @kbd
 +
 +@item M-x guix-devel-use-current-module
 +Use the current guile module.  Often after opening a scheme file, you

Capitalize “Guile” and “Scheme” here.

 +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.

Could you mention a use case here?  Like:

  For instance, you may call this command while visiting a file that
  defines packages; you can then switch to the associated REPL with
  @kbd{C-c C-z}, which will be in the current module, which is handy.

The “-devel” part might make it sound like it has an effect similar to
‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
that they must set ‘guix-load-path’ appropriately?

Otherwise OK, thanks!

Ludo’.



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-28 Thread Mathieu Lirzin
Alex Kost alez...@gmail.com writes:

 Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:

 I don't know whether there is such (or any other) suggestion anywhere.
 But since that was just an example, not a recommendation (not even a
 suggestion), I think it doesn't matter what key binding to use there.
 Do you have any preference?  What about C-H-M-s-u? :-)

 I agree it's not really important for advanced Emacs users who will have
 no problem choosing something adapted to their setup. Nonetheless IMHO
 consistency and simplicity helps newcomers to understand, So I will be
 in favour of anything that follows this convention. :)

 (global-set-key (kbd C-c letter) foo-function-callable-anywhere)

 (define-key bar-mode-map
 (kbd C-c C-letter)
 'foo-function-for-bar-mode)

 According to (info (elisp) Key Binding Conventions), 'C-c LETTER'
 bindings are reserved for users, so I think using C-c u in that
 example is absolutely fine, don't you agree?

I agree.  Sorry for the noise and thanks for retrieving this
reference. ;)

--
Mathieu Lirzin



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-26 Thread Alex Kost
Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:

 Alex Kost alez...@gmail.com writes:

 * 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'.

 [...]

 @@ -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

 What do you think about integrating it in section Contributing instead?

Maybe, I don't have a preference here.

 +And as always if you use a command often, it is a good idea to bind a
 +key to it, for example like this:
 +
 +@example
 +(with-eval-after-load 'scheme
 +  (define-key scheme-mode-map (kbd C-c u)
 +'guix-devel-use-current-module))
 +@end example

 I remember reading somewhere in the Emacs manual that C-c Letter is
 meant for user customization in the global key map (can't remember where
 ;)). So what suggesting C-c C-u which is a mode specific key binding?

I don't know whether there is such (or any other) suggestion anywhere.
But since that was just an example, not a recommendation (not even a
suggestion), I think it doesn't matter what key binding to use there.
Do you have any preference?  What about C-H-M-s-u? :-)

-- 
Alex



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-26 Thread Mathieu Lirzin
Alex Kost alez...@gmail.com writes:

 Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:
 What do you think about integrating it in section Contributing instead?

 Maybe, I don't have a preference here.

Since it's not really related to package management, I think it would be
preferable to move this in the node The perfect Setup.

 I remember reading somewhere in the Emacs manual that C-c Letter is
 meant for user customization in the global key map (can't remember where
 ;)). So what suggesting C-c C-u which is a mode specific key binding?

 I don't know whether there is such (or any other) suggestion anywhere.
 But since that was just an example, not a recommendation (not even a
 suggestion), I think it doesn't matter what key binding to use there.
 Do you have any preference?  What about C-H-M-s-u? :-)

I agree it's not really important for advanced Emacs users who will have
no problem choosing something adapted to their setup. Nonetheless IMHO
consistency and simplicity helps newcomers to understand, So I will be
in favour of anything that follows this convention. :)

--8---cut here---start-8---
(global-set-key (kbd C-c letter) foo-function-callable-anywhere)

(define-key bar-mode-map
(kbd C-c C-letter)
'foo-function-for-bar-mode)
--8---cut here---end---8---

--
Mathieu Lirzin



Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-26 Thread Alex Kost
Mathieu Lirzin (2015-07-26 17:00 +0300) wrote:

 Alex Kost alez...@gmail.com writes:

 Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:
 What do you think about integrating it in section Contributing instead?

 Maybe, I don't have a preference here.

 Since it's not really related to package management, I think it would be
 preferable to move this in the node The perfect Setup.

OK, you convinced me :-) I'll put the docs there.

 I remember reading somewhere in the Emacs manual that C-c Letter is
 meant for user customization in the global key map (can't remember where
 ;)). So what suggesting C-c C-u which is a mode specific key binding?

 I don't know whether there is such (or any other) suggestion anywhere.
 But since that was just an example, not a recommendation (not even a
 suggestion), I think it doesn't matter what key binding to use there.
 Do you have any preference?  What about C-H-M-s-u? :-)

 I agree it's not really important for advanced Emacs users who will have
 no problem choosing something adapted to their setup. Nonetheless IMHO
 consistency and simplicity helps newcomers to understand, So I will be
 in favour of anything that follows this convention. :)

 (global-set-key (kbd C-c letter) foo-function-callable-anywhere)

 (define-key bar-mode-map
 (kbd C-c C-letter)
 'foo-function-for-bar-mode)

According to (info (elisp) Key Binding Conventions), 'C-c LETTER'
bindings are reserved for users, so I think using C-c u in that
example is absolutely fine, don't you agree?

-- 
Alex



[PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-25 Thread Alex Kost
* 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,des}@key{TAB}
 
 @end itemize
+
+
+@node Emacs Development
+@subsection Development
+
+This section describes some additional commands for Guix developers who
+use Geiser to work with guile code.
+
+@table @kbd
+
+@item 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.
+
+@end 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:
+
+@example
+(with-eval-after-load 'scheme
+  (define-key scheme-mode-map (kbd C-c u)
+'guix-devel-use-current-module))
+@end example
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
new file mode 100644
index 000..e99b289
--- /dev/null
+++ b/emacs/guix-devel.el
@@ -0,0 +1,44 @@
+;;; guix-devel.el --- Development tools
+
+;; Copyright © 2015 Alex Kost alez...@gmail.com
+
+;; 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




Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.

2015-07-25 Thread Mathieu Lirzin
Alex Kost alez...@gmail.com writes:

 * 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'.

[...]

 @@ -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

What do you think about integrating it in section Contributing instead?

 +And as always if you use a command often, it is a good idea to bind a
 +key to it, for example like this:
 +
 +@example
 +(with-eval-after-load 'scheme
 +  (define-key scheme-mode-map (kbd C-c u)
 +'guix-devel-use-current-module))
 +@end example

I remember reading somewhere in the Emacs manual that C-c Letter is
meant for user customization in the global key map (can't remember where
;)). So what suggesting C-c C-u which is a mode specific key binding?

--
Mathieu Lirzin