diff options
author | Ludovic Courtès <ludo@gnu.org> | 2016-04-06 12:00:29 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2016-04-06 12:00:29 +0200 |
commit | 933d2fe4cfb380f66af631a2203ec23c367e5b1a (patch) | |
tree | f10581ed0da1911eed9b02e69d999ba481d9d3c6 /emacs | |
parent | f8835ff4b3dd59d59bf44838d05d3d60114d15d2 (diff) | |
parent | 998afc3608242b75051f43ece36d52474c51e285 (diff) | |
download | patches-933d2fe4cfb380f66af631a2203ec23c367e5b1a.tar patches-933d2fe4cfb380f66af631a2203ec23c367e5b1a.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/guix-geiser.el | 22 | ||||
-rw-r--r-- | emacs/guix-init.el | 3 | ||||
-rw-r--r-- | emacs/guix-main.scm | 98 | ||||
-rw-r--r-- | emacs/guix-ui-package.el | 11 |
4 files changed, 70 insertions, 64 deletions
diff --git a/emacs/guix-geiser.el b/emacs/guix-geiser.el index 0e6cc03a84..833f5bb2b3 100644 --- a/emacs/guix-geiser.el +++ b/emacs/guix-geiser.el @@ -46,11 +46,23 @@ Return a list of strings with result values of evaluation." (defun guix-geiser-eval-read (str &optional repl) "Evaluate STR with guile expression using Geiser REPL. Return elisp expression of the first result value of evaluation." - ;; Parsing scheme code with elisp `read' is probably not the best idea. - (read (replace-regexp-in-string - "#f\\|#<unspecified>" "nil" - (replace-regexp-in-string - "#t" "t" (car (guix-geiser-eval str repl)))))) + ;; The goal is to convert a string with scheme expression into elisp + ;; expression. + (let ((result (car (guix-geiser-eval str repl)))) + (cond + ((or (string= result "#f") + (string= result "#<unspecified>")) + nil) + ((string= result "#t") + t) + (t + (read (replace-regexp-in-string + "[ (]\\(#f\\)" "nil" + (replace-regexp-in-string + "[ (]\\(#t\\)" "t" + result + nil nil 1) + nil nil 1)))))) (defun guix-repl-send (cmd &optional save-history) "Send CMD input string to the current REPL buffer. diff --git a/emacs/guix-init.el b/emacs/guix-init.el index 1d7d258f69..bd75e54e03 100644 --- a/emacs/guix-init.el +++ b/emacs/guix-init.el @@ -1,4 +1,3 @@ (require 'guix-autoloads) -(require 'guix-emacs) - +(message "(require 'guix-init) is obsolete, use (require 'guix-autoloads) instead.") (provide 'guix-init) diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm index 86cedfd459..c62044056f 100644 --- a/emacs/guix-main.scm +++ b/emacs/guix-main.scm @@ -58,9 +58,7 @@ (guix licenses) (guix utils) (guix ui) - (guix scripts lint) (guix scripts package) - (guix scripts pull) (gnu packages) (gnu system)) @@ -105,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 @@ -293,8 +301,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,11 +340,12 @@ Example: ;;; Finding packages. (define (package-by-address address) - (and=> (vhash-assq address %packages) - cdr)) + (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)) '())) @@ -917,34 +928,14 @@ OUTPUTS is a list of package outputs (may be an empty list)." manifest transaction))) (unless (and (null? install) (null? remove)) (with-store store - (let* ((derivation (run-with-store store - (mbegin %store-monad - (set-guile-for-build (default-guile)) - (profile-derivation new-manifest)))) - (derivations (list derivation)) - (new-profile (derivation->output-path derivation))) - (set-build-options store - #:print-build-trace #f - #:use-substitutes? use-substitutes?) - (show-manifest-transaction store manifest transaction - #:dry-run? dry-run?) - (show-what-to-build store derivations - #:use-substitutes? use-substitutes? - #:dry-run? dry-run?) - (unless dry-run? - (let ((name (generation-file-name - profile - (+ 1 (generation-number profile))))) - (and (build-derivations store derivations) - (let* ((entries (manifest-entries new-manifest)) - (count (length entries))) - (switch-symlinks name new-profile) - (switch-symlinks profile name) - (format #t (N_ "~a package in profile~%" - "~a packages in profile~%" - count) - count) - (display-search-paths entries (list profile))))))))))) + (set-build-options store + #:print-build-trace #f + #:use-substitutes? use-substitutes?) + (show-manifest-transaction store manifest transaction + #:dry-run? dry-run?) + (build-and-use-profile store profile new-manifest + #:use-substitutes? use-substitutes? + #:dry-run? dry-run?))))) (define (delete-generations* profile generations) "Delete GENERATIONS from PROFILE. @@ -1040,8 +1031,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." diff --git a/emacs/guix-ui-package.el b/emacs/guix-ui-package.el index 9d81c6126e..df5f8d12d1 100644 --- a/emacs/guix-ui-package.el +++ b/emacs/guix-ui-package.el @@ -357,7 +357,8 @@ formatted with this string, an action button is inserted.") (guix-buffer-get-display-entries-current 'info guix-package-info-type (list (guix-ui-current-profile) - 'name (button-label btn)) + 'name (or (button-get btn 'spec) + (button-label btn))) 'add))) (define-button-type 'guix-package-heading @@ -374,10 +375,12 @@ formatted with this string, an action button is inserted.") (message "Yes, this is the source URL. What did you expect?"))) (defun guix-package-info-insert-heading (entry) - "Insert package ENTRY heading (name specification) at point." + "Insert package ENTRY heading (name and version) at point." (guix-insert-button - (guix-package-entry->name-specification entry) - 'guix-package-heading)) + (concat (guix-entry-value entry 'name) " " + (guix-entry-value entry 'version)) + 'guix-package-heading + 'spec (guix-package-entry->name-specification entry))) (defun guix-package-info-insert-systems (systems entry) "Insert supported package SYSTEMS at point." |