unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 0/4] emacs: Some fixes and improvements.
@ 2016-04-01  8:06 Alex Kost
  2016-04-01  8:06 ` [PATCH 1/4] emacs: Stylistic improvements in guile code Alex Kost
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alex Kost @ 2016-04-01  8:06 UTC (permalink / raw)
  To: guix-devel

Stylistic and performance improvements for scheme side.

[PATCH 1/4] emacs: Stylistic improvements in guile code.
[PATCH 2/4] emacs: Remove unused module.
[PATCH 3/4] emacs: Use (guix scripts lint) only when needed.
[PATCH 4/4] emacs: Speed up starting the REPL.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] emacs: Stylistic improvements in guile code.
  2016-04-01  8:06 [PATCH 0/4] emacs: Some fixes and improvements Alex Kost
@ 2016-04-01  8:06 ` Alex Kost
  2016-04-03 21:16   ` Ludovic Courtès
  2016-04-01  8:06 ` [PATCH 2/4] emacs: Remove unused module Alex Kost
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Kost @ 2016-04-01  8:06 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm (package-unique?): Use 'match' instead of 'cdr'.
(package-by-address): Likewise.
---
 emacs/guix-main.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index bcff9ce..da42450 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -293,8 +293,10 @@ Example:
 
 (define (package-unique? package)
   "Return #t if PACKAGE is a single package with such name/version."
-  (null? (cdr (packages-by-name (package-name package)
-                                (package-version package)))))
+  (match (packages-by-name (package-name package)
+                           (package-version package))
+    ((package) #t)
+    (_ #f)))
 
 (define %package-param-alist
   `((id                . ,object-address)
@@ -330,8 +332,9 @@ Example:
 ;;; Finding packages.
 
 (define (package-by-address address)
-  (and=> (vhash-assq address %packages)
-         cdr))
+  (match (vhash-assq address %packages)
+    ((_ . package) package)
+    (_ #f)))
 
 (define (packages-by-name+version name version)
   (or (hash-ref %package-table
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] emacs: Remove unused module.
  2016-04-01  8:06 [PATCH 0/4] emacs: Some fixes and improvements Alex Kost
  2016-04-01  8:06 ` [PATCH 1/4] emacs: Stylistic improvements in guile code Alex Kost
@ 2016-04-01  8:06 ` Alex Kost
  2016-04-03 21:16   ` Ludovic Courtès
  2016-04-01  8:06 ` [PATCH 3/4] emacs: Use (guix scripts lint) only when needed Alex Kost
  2016-04-01  8:06 ` [PATCH 4/4] emacs: Speed up starting the REPL Alex Kost
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Kost @ 2016-04-01  8:06 UTC (permalink / raw)
  To: guix-devel

This is a followup to commit c67e344f21fda2bf5a2a377a34d4749a1c7e7c9c.

* emacs/guix-main.scm: Do not use (guix scripts pull).
---
 emacs/guix-main.scm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index da42450..eb79adb 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -60,7 +60,6 @@
  (guix ui)
  (guix scripts lint)
  (guix scripts package)
- (guix scripts pull)
  (gnu packages)
  (gnu system))
 
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] emacs: Use (guix scripts lint) only when needed.
  2016-04-01  8:06 [PATCH 0/4] emacs: Some fixes and improvements Alex Kost
  2016-04-01  8:06 ` [PATCH 1/4] emacs: Stylistic improvements in guile code Alex Kost
  2016-04-01  8:06 ` [PATCH 2/4] emacs: Remove unused module Alex Kost
@ 2016-04-01  8:06 ` Alex Kost
  2016-04-03 21:18   ` Ludovic Courtès
  2016-04-01  8:06 ` [PATCH 4/4] emacs: Speed up starting the REPL Alex Kost
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Kost @ 2016-04-01  8:06 UTC (permalink / raw)
  To: guix-devel

* emacs/guix-main.scm: Do not use (guix scripts pull) module.
(lint-checker-names): Adjust to use it.
---
 emacs/guix-main.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index eb79adb..925d2b2 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -58,7 +58,6 @@
  (guix licenses)
  (guix utils)
  (guix ui)
- (guix scripts lint)
  (guix scripts package)
  (gnu packages)
  (gnu system))
@@ -1022,8 +1021,9 @@ Return #t if the shell command was executed successfully."
 (define (lint-checker-names)
   "Return a list of names of available lint checkers."
   (map (lambda (checker)
-         (symbol->string (lint-checker-name checker)))
-       %checkers))
+         (symbol->string ((@ (guix scripts lint) lint-checker-name)
+                          checker)))
+       (@ (guix scripts lint) %checkers)))
 
 (define (package-names)
   "Return a list of names of available packages."
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] emacs: Speed up starting the REPL.
  2016-04-01  8:06 [PATCH 0/4] emacs: Some fixes and improvements Alex Kost
                   ` (2 preceding siblings ...)
  2016-04-01  8:06 ` [PATCH 3/4] emacs: Use (guix scripts lint) only when needed Alex Kost
@ 2016-04-01  8:06 ` Alex Kost
  2016-04-03 21:19   ` Ludovic Courtès
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Kost @ 2016-04-01  8:06 UTC (permalink / raw)
  To: guix-devel

Delay initializing variables.

* emacs/guix-main.scm: (%packages): Rename to...
(%package-vhash): ... this.  Delay setting the value.
(package-vhash): New procedure (wrapper for '%package-vhash').
(%package-table): Delay setting the value.
(package-table): New procedure (wrapper for '%package-table').
(package-by-address, packages-by-name+version): Use wrappers.
---
 emacs/guix-main.scm | 46 ++++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 925d2b2..c620440 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -103,24 +103,34 @@ return two values: name and version.  For example, for SPEC
 (define name+version->key cons)
 (define key->name+version car+cdr)
 
-(define %packages
-  (fold-packages (lambda (pkg res)
-                   (vhash-consq (object-address pkg) pkg res))
-                 vlist-null))
+(define %package-vhash
+  (delay
+    (fold-packages (lambda (pkg res)
+                     (vhash-consq (object-address pkg) pkg res))
+                   vlist-null)))
+
+(define (package-vhash)
+  "Return vhash of 'package ID (address)'/'package' pairs."
+  (force %package-vhash))
 
 (define %package-table
-  (let ((table (make-hash-table (vlist-length %packages))))
-    (vlist-for-each
-     (lambda (elem)
-       (match elem
-         ((address . pkg)
-          (let* ((key (name+version->key (package-name pkg)
-                                         (package-version pkg)))
-                 (ref (hash-ref table key)))
-            (hash-set! table key
-                       (if ref (cons pkg ref) (list pkg)))))))
-     %packages)
-    table))
+  (delay
+    (let ((table (make-hash-table (vlist-length (package-vhash)))))
+      (vlist-for-each
+       (lambda (elem)
+         (match elem
+           ((address . pkg)
+            (let* ((key (name+version->key (package-name pkg)
+                                           (package-version pkg)))
+                   (ref (hash-ref table key)))
+              (hash-set! table key
+                         (if ref (cons pkg ref) (list pkg)))))))
+       (package-vhash))
+      table)))
+
+(define (package-table)
+  "Return hash table of 'name+version key'/'list of packages' pairs."
+  (force %package-table))
 
 (define (manifest-entry->name+version+output entry)
   (values
@@ -330,12 +340,12 @@ Example:
 ;;; Finding packages.
 
 (define (package-by-address address)
-  (match (vhash-assq address %packages)
+  (match (vhash-assq address (package-vhash))
     ((_ . package) package)
     (_ #f)))
 
 (define (packages-by-name+version name version)
-  (or (hash-ref %package-table
+  (or (hash-ref (package-table)
                 (name+version->key name version))
       '()))
 
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] emacs: Stylistic improvements in guile code.
  2016-04-01  8:06 ` [PATCH 1/4] emacs: Stylistic improvements in guile code Alex Kost
@ 2016-04-03 21:16   ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2016-04-03 21:16 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-main.scm (package-unique?): Use 'match' instead of 'cdr'.
> (package-by-address): Likewise.

OK!

Ludo'.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] emacs: Remove unused module.
  2016-04-01  8:06 ` [PATCH 2/4] emacs: Remove unused module Alex Kost
@ 2016-04-03 21:16   ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2016-04-03 21:16 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> This is a followup to commit c67e344f21fda2bf5a2a377a34d4749a1c7e7c9c.
>
> * emacs/guix-main.scm: Do not use (guix scripts pull).

OK

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] emacs: Use (guix scripts lint) only when needed.
  2016-04-01  8:06 ` [PATCH 3/4] emacs: Use (guix scripts lint) only when needed Alex Kost
@ 2016-04-03 21:18   ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2016-04-03 21:18 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-main.scm: Do not use (guix scripts pull) module.
> (lint-checker-names): Adjust to use it.

OK.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] emacs: Speed up starting the REPL.
  2016-04-01  8:06 ` [PATCH 4/4] emacs: Speed up starting the REPL Alex Kost
@ 2016-04-03 21:19   ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2016-04-03 21:19 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Delay initializing variables.
>
> * emacs/guix-main.scm: (%packages): Rename to...
> (%package-vhash): ... this.  Delay setting the value.
> (package-vhash): New procedure (wrapper for '%package-vhash').
> (%package-table): Delay setting the value.
> (package-table): New procedure (wrapper for '%package-table').
> (package-by-address, packages-by-name+version): Use wrappers.

OK, sounds reasonable.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-04-03 21:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-01  8:06 [PATCH 0/4] emacs: Some fixes and improvements Alex Kost
2016-04-01  8:06 ` [PATCH 1/4] emacs: Stylistic improvements in guile code Alex Kost
2016-04-03 21:16   ` Ludovic Courtès
2016-04-01  8:06 ` [PATCH 2/4] emacs: Remove unused module Alex Kost
2016-04-03 21:16   ` Ludovic Courtès
2016-04-01  8:06 ` [PATCH 3/4] emacs: Use (guix scripts lint) only when needed Alex Kost
2016-04-03 21:18   ` Ludovic Courtès
2016-04-01  8:06 ` [PATCH 4/4] emacs: Speed up starting the REPL Alex Kost
2016-04-03 21:19   ` Ludovic Courtès

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