From 7ad62ccef2446011dfbdfb2dbe8cc58f46fb05d8 Mon Sep 17 00:00:00 2001
From: Pierre Langlois <pierre.langlois@gmx.com>
Date: Sat, 2 Apr 2022 19:22:52 +0100
Subject: [PATCH] wip
---
gnu/packages/tree-sitter.scm | 49 ++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 19 deletions(-)
@@ -795,11 +795,11 @@ (define-public emacs-tree-sitter
@end enumerate")
(license license:expat)))
-(define (make-emacs-tree-sitter-langs-grammar-bundle version)
+(define emacs-tree-sitter-langs-grammar-bundle
(package
(name "emacs-tree-sitter-langs-grammar-bundle")
(source #f)
- (version version)
+ (version (package-version tree-sitter))
(build-system trivial-build-system)
(inputs
;; FIXME: Support for some languages is still left to package.
@@ -836,11 +836,7 @@ (define (make-emacs-tree-sitter-langs-grammar-bundle version)
(map (match-lambda
((name directory)
(string-append directory "/lib/tree-sitter")))
- '#$(package-inputs this-package))))
- ;; The BUNDLE-VERSION file prevents emacs-tree-sitter-langs
- ;; from downloading libraries at load time.
- (call-with-output-file (string-append #$output "/BUNDLE-VERSION")
- (lambda (port) (display #$version port)))))))
+ '#$(package-inputs this-package))))))))
(synopsis #f)
(description #f)
(home-page #f)
@@ -861,7 +857,7 @@ (define-public emacs-tree-sitter-langs
"1p2zbb6ac7wi6x6zpbczcmpkb2p45md2csd2bj43d8s56ckzw5mp"))))
(build-system emacs-build-system)
(inputs
- (list (make-emacs-tree-sitter-langs-grammar-bundle version)))
+ (list emacs-tree-sitter-langs-grammar-bundle))
(propagated-inputs
(list emacs-tree-sitter))
(arguments
@@ -870,15 +866,36 @@ (define-public emacs-tree-sitter-langs
#:test-command ''("script/test")
#:phases
#~(modify-phases %standard-phases
+ (add-after 'unpack 'disable-downloader
+ (lambda _
+ (call-with-output-file "tree-sitter-langs-build.el"
+ (lambda (port)
+ (let ((on-load-message
+ (string-append
+ "tree-sitter-langs: Grammar bundle already installed "
+ "via Guix. Installing external grammars via this "
+ "function isn't supported, if a language you need is "
+ "missing please report a bug at bug-guix@gnu.org.")))
+ (format
+ port
+ ";;;###autoload
+ (defun tree-sitter-langs-install-grammars
+ (&optional skip-if-installed version os
+ keep-bundle)
+ (interactive)
+ (message \"~a\"))
+ (defconst tree-sitter-langs--queries-dir
+ (file-name-as-directory
+ (concat (file-name-directory (locate-library \"tree-sitter-langs.el\"))
+ \"queries\")))
+ (defun tree-sitter-langs--bin-dir () \"~a\")
+ (provide 'tree-sitter-langs-build)"
+ on-load-message
+ #$emacs-tree-sitter-langs-grammar-bundle))))))
(add-after 'unpack 'remove-cask
(lambda _
(substitute* "script/test"
(("cask") ""))))
- (add-before 'check 'bundle-for-testing
- (lambda* (#:key inputs #:allow-other-keys)
- (delete-file-recursively "bin")
- (symlink #$(make-emacs-tree-sitter-langs-grammar-bundle version)
- "bin")))
(add-before 'check 'patch-tree-sitter-require-test
(lambda _
(use-modules (ice-9 regex))
@@ -906,12 +923,6 @@ (define-public emacs-tree-sitter-langs
(lambda _
(delete-file-recursively "queries/hcl")
(delete-file-recursively "queries/pgn")))
- (add-before 'install 'install-bundle
- (lambda _
- (let ((elpa (elpa-directory #$output)))
- (mkdir-p elpa)
- (symlink #$(make-emacs-tree-sitter-langs-grammar-bundle version)
- (string-append elpa "/bin")))))
(add-after 'install 'install-queries
(lambda* (#:key outputs #:allow-other-keys)
(let ((elpa (elpa-directory (assoc-ref outputs "out"))))
--
2.36.0