* [PATCH] emacs: Add completions for '--type' option of 'refresh' popup.
@ 2015-10-28 18:55 Alex Kost
2015-10-29 20:14 ` Ludovic Courtès
0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-10-28 18:55 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
This is for completions in "M-x guix r =t".
In 'emacs/guix-main.scm' I used:
(map (@ (guix upstream) upstream-updater-name)
(@ (guix scripts refresh) %updaters)))
instead of adding these modules to the top-level (use-modules ...) to
avoid loading them on start. If it's OK, I'm going to do the same for
(guix scripts graph) and (guix scripts lint) modules, as they are used
only to get graph types and lint checkers.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Add-completions-for-type-option-of-refresh-pop.patch --]
[-- Type: text/x-patch, Size: 3556 bytes --]
From f2bd4c152ddd48a6c1cc13adfff0a616d1732bd3 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Wed, 28 Oct 2015 21:11:36 +0300
Subject: [PATCH] emacs: Add completions for '--type' option of 'refresh'
popup.
* guix/scripts/refresh.scm: Export '%updaters'.
* emacs/guix-main.scm (refresh-updater-names): New procedure.
* emacs/guix-base.el (guix-refresh-updater-names): New function.
* emacs/guix-read.el (guix-read-refresh-updater-names,
guix-read-refresh-updater-names-string): New functions.
* emacs/guix-command.el (guix-command-improve-refresh-argument): Use
'guix-read-refresh-updater-names-string'.
---
emacs/guix-base.el | 4 ++++
emacs/guix-command.el | 1 +
emacs/guix-main.scm | 5 +++++
emacs/guix-read.el | 6 ++++++
guix/scripts/refresh.scm | 3 ++-
5 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 2e99c54..14ea3d4 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -186,6 +186,10 @@ For the meaning of location, see `guix-find-location'."
"Return a list of names of available graph node types."
(guix-eval-read (guix-make-guile-expression 'graph-type-names)))
+(guix-memoized-defun guix-refresh-updater-names ()
+ "Return a list of names of available refresh updater types."
+ (guix-eval-read (guix-make-guile-expression 'refresh-updater-names)))
+
(guix-memoized-defun guix-lint-checker-names ()
"Return a list of names of available lint checkers."
(guix-eval-read (guix-make-guile-expression 'lint-checker-names)))
diff --git a/emacs/guix-command.el b/emacs/guix-command.el
index 36ce7bc..f8a6df7 100644
--- a/emacs/guix-command.el
+++ b/emacs/guix-command.el
@@ -241,6 +241,7 @@ to be modified."
(guix-command-define-argument-improver
guix-command-improve-refresh-argument
'(("--select" :fun guix-read-refresh-subset)
+ ("--type" :fun guix-read-refresh-updater-names-string)
("--key-server" :char ?S)))
(guix-command-define-argument-improver
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index e29a0a0..9eac518 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -991,6 +991,11 @@ Return #t if the shell command was executed successfully."
"Return a list of names of available graph node types."
(map node-type-name %node-types))
+(define (refresh-updater-names)
+ "Return a list of names of available refresh updater types."
+ (map (@ (guix upstream) upstream-updater-name)
+ (@ (guix scripts refresh) %updaters)))
+
(define (lint-checker-names)
"Return a list of names of available lint checkers."
(map (lambda (checker)
diff --git a/emacs/guix-read.el b/emacs/guix-read.el
index 5a7201c..e60af9c 100644
--- a/emacs/guix-read.el
+++ b/emacs/guix-read.el
@@ -137,6 +137,12 @@ keywords are available:
:single-prompt "Refresh subset: ")
(guix-define-readers
+ :completions-getter guix-refresh-updater-names
+ :multiple-reader guix-read-refresh-updater-names
+ :multiple-prompt "Refresh updater,s: "
+ :multiple-separator ",")
+
+(guix-define-readers
:completions-var guix-help-key-policies
:single-reader guix-read-key-policy
:single-prompt "Key policy: ")
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index a66b3f9..a67907b 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -42,7 +42,8 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
#:use-module (rnrs io ports)
- #:export (guix-refresh))
+ #:export (guix-refresh
+ %updaters))
\f
;;;
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: Add completions for '--type' option of 'refresh' popup.
2015-10-28 18:55 [PATCH] emacs: Add completions for '--type' option of 'refresh' popup Alex Kost
@ 2015-10-29 20:14 ` Ludovic Courtès
2015-10-31 20:29 ` Alex Kost
0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2015-10-29 20:14 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> This is for completions in "M-x guix r =t".
>
> In 'emacs/guix-main.scm' I used:
>
> (map (@ (guix upstream) upstream-updater-name)
> (@ (guix scripts refresh) %updaters)))
>
> instead of adding these modules to the top-level (use-modules ...) to
> avoid loading them on start.
That doesn’t avoid anything actually.
You could use #:autoload, but only for ‘%updaters’ because
‘upstream-updater-name’ is a macro so it needs to be available at
expansion time.
> From f2bd4c152ddd48a6c1cc13adfff0a616d1732bd3 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Wed, 28 Oct 2015 21:11:36 +0300
> Subject: [PATCH] emacs: Add completions for '--type' option of 'refresh'
> popup.
>
> * guix/scripts/refresh.scm: Export '%updaters'.
> * emacs/guix-main.scm (refresh-updater-names): New procedure.
> * emacs/guix-base.el (guix-refresh-updater-names): New function.
> * emacs/guix-read.el (guix-read-refresh-updater-names,
> guix-read-refresh-updater-names-string): New functions.
> * emacs/guix-command.el (guix-command-improve-refresh-argument): Use
> 'guix-read-refresh-updater-names-string'.
OK with guix-main.scm using appropriate #:autoload and #:use-module.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: Add completions for '--type' option of 'refresh' popup.
2015-10-29 20:14 ` Ludovic Courtès
@ 2015-10-31 20:29 ` Alex Kost
2015-11-01 17:18 ` Ludovic Courtès
0 siblings, 1 reply; 5+ messages in thread
From: Alex Kost @ 2015-10-31 20:29 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2015-10-29 23:14 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> This is for completions in "M-x guix r =t".
>>
>> In 'emacs/guix-main.scm' I used:
>>
>> (map (@ (guix upstream) upstream-updater-name)
>> (@ (guix scripts refresh) %updaters)))
>>
>> instead of adding these modules to the top-level (use-modules ...) to
>> avoid loading them on start.
>
> That doesn’t avoid anything actually.
Ouch :-(
> You could use #:autoload, but only for ‘%updaters’ because
> ‘upstream-updater-name’ is a macro so it needs to be available at
> expansion time.
I looked at (info "(guile) Using Guile Modules") and it has the following:
An autoload is a good way to put off loading a big module
until it’s really needed, for instance for faster startup or
if it will only be needed in certain circumstances.
‘@’ can do a similar thing (see Using Guile Modules), but
in that case an ‘@’ form must be written every time a binding
from the module is used.
To me it sounds like ‘@’ does the same thing as ‘#:autoload’, no?
Also #:autoload should be used inside (define-module ...), but
‘guix-main.scm’ does not define a module.
>> From f2bd4c152ddd48a6c1cc13adfff0a616d1732bd3 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Wed, 28 Oct 2015 21:11:36 +0300
>> Subject: [PATCH] emacs: Add completions for '--type' option of 'refresh'
>> popup.
>>
>> * guix/scripts/refresh.scm: Export '%updaters'.
>> * emacs/guix-main.scm (refresh-updater-names): New procedure.
>> * emacs/guix-base.el (guix-refresh-updater-names): New function.
>> * emacs/guix-read.el (guix-read-refresh-updater-names,
>> guix-read-refresh-updater-names-string): New functions.
>> * emacs/guix-command.el (guix-command-improve-refresh-argument): Use
>> 'guix-read-refresh-updater-names-string'.
>
> OK with guix-main.scm using appropriate #:autoload and #:use-module.
Not sure if I understand it correctly after all, but I think I should
either leave ‘@’ or add (guix upstream) and (guix scripts refresh) to
(use-modules ...), right?
--
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: Add completions for '--type' option of 'refresh' popup.
2015-10-31 20:29 ` Alex Kost
@ 2015-11-01 17:18 ` Ludovic Courtès
2015-11-02 13:01 ` Alex Kost
0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2015-11-01 17:18 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> Ludovic Courtès (2015-10-29 23:14 +0300) wrote:
[...]
>> You could use #:autoload, but only for ‘%updaters’ because
>> ‘upstream-updater-name’ is a macro so it needs to be available at
>> expansion time.
>
> I looked at (info "(guile) Using Guile Modules") and it has the following:
>
> An autoload is a good way to put off loading a big module
> until it’s really needed, for instance for faster startup or
> if it will only be needed in certain circumstances.
>
> ‘@’ can do a similar thing (see Using Guile Modules), but
> in that case an ‘@’ form must be written every time a binding
> from the module is used.
>
> To me it sounds like ‘@’ does the same thing as ‘#:autoload’, no?
I guess I was confused. A simple example confirms what the manual
explains:
--8<---------------cut here---------------start------------->8---
$ guild compile t.scm
wrote `/home/ludo/.cache/guile/ccache/2.0-LE-8-2.0/home/ludo/src/guix/t.scm.go'
$ guile t.scm
$ cat t.scm
(define (foo)
(@ (asdfasdfa) sdfsf))
--8<---------------cut here---------------end--------------->8---
> Also #:autoload should be used inside (define-module ...), but
> ‘guix-main.scm’ does not define a module.
Oh, right, I had overlooked that.
So yes, you can go ahead with your initial approach.
Thanks, and sorry for the confusion!
Ludo’.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: Add completions for '--type' option of 'refresh' popup.
2015-11-01 17:18 ` Ludovic Courtès
@ 2015-11-02 13:01 ` Alex Kost
0 siblings, 0 replies; 5+ messages in thread
From: Alex Kost @ 2015-11-02 13:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Ludovic Courtès (2015-11-01 20:18 +0300) wrote:
> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-10-29 23:14 +0300) wrote:
>
> [...]
>
>>> You could use #:autoload, but only for ‘%updaters’ because
>>> ‘upstream-updater-name’ is a macro so it needs to be available at
>>> expansion time.
>>
>> I looked at (info "(guile) Using Guile Modules") and it has the following:
>>
>> An autoload is a good way to put off loading a big module
>> until it’s really needed, for instance for faster startup or
>> if it will only be needed in certain circumstances.
>>
>> ‘@’ can do a similar thing (see Using Guile Modules), but
>> in that case an ‘@’ form must be written every time a binding
>> from the module is used.
>>
>> To me it sounds like ‘@’ does the same thing as ‘#:autoload’, no?
>
> I guess I was confused. A simple example confirms what the manual
> explains:
>
> $ guild compile t.scm
> wrote `/home/ludo/.cache/guile/ccache/2.0-LE-8-2.0/home/ludo/src/guix/t.scm.go'
> $ guile t.scm
> $ cat t.scm
> (define (foo)
> (@ (asdfasdfa) sdfsf))
Ah, good example, thank you!
>> Also #:autoload should be used inside (define-module ...), but
>> ‘guix-main.scm’ does not define a module.
>
> Oh, right, I had overlooked that.
>
> So yes, you can go ahead with your initial approach.
Great, thanks!
> Thanks, and sorry for the confusion!
No problem, pushed.
--
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-02 13:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-28 18:55 [PATCH] emacs: Add completions for '--type' option of 'refresh' popup Alex Kost
2015-10-29 20:14 ` Ludovic Courtès
2015-10-31 20:29 ` Alex Kost
2015-11-01 17:18 ` Ludovic Courtès
2015-11-02 13:01 ` Alex Kost
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).