emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/leaf fce3378f98 4/6: Merge pull request #539 from conao


From: ELPA Syncer
Subject: [elpa] externals/leaf fce3378f98 4/6: Merge pull request #539 from conao3/feature/532
Date: Thu, 3 Aug 2023 03:58:14 -0400 (EDT)

branch: externals/leaf
commit fce3378f987bf118a0a5f1a24c4408ac920f858d
Merge: c37b31cc1f 2c13911481
Author: Naoya Yamashita <conao3@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #539 from conao3/feature/532
    
    Add :vc keyword
---
 README.org    | 28 +++++++++++++++++++++++++++-
 leaf-tests.el | 18 ++++++++++++++++++
 leaf.el       | 20 ++++++++++++++++++++
 3 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index ca11f4bec6..01cd67795d 100644
--- a/README.org
+++ b/README.org
@@ -27,6 +27,7 @@
   - [[none (keyword)]]
   - [[:require keyword]]
   - [[#ensure][:ensure, :package keywords]]
+  - [[:vc keyword]]
   - [[:preface, :init, :config keywords]]
   - [[:defer-config keyword]]
   - [[:commands keyword]]
@@ -105,7 +106,7 @@ Currently, ~leaf.el~ and ~leaf-keywords.el~ has below rich 
keywords.
   ;;    :preface
   ;;    :when :unless :if
   ;;    :emacs< :emacs<= :emacs= :emacs> :emacs>=
-  ;;    :ensure :package :feather :straight :el-get
+  ;;    :ensure :package :vc :feather :straight :el-get
   ;;    :after
   ;;    :commands
   ;;    :bind :bind*
@@ -436,6 +437,31 @@ Since ~:ensure~ is to use ~package.el~ by default, 
~:ensure~ and
                                         (error-message-string err)))))))))))
 #+end_src
 
+** :vc keyword
+
+~:vc~ provide ~package-vc-install~ frontend.
+
+#+begin_src emacs-lisp
+(cort-deftest-with-macroexpand leaf/vc
+  '(((leaf bbdb
+       :vc ( :url "https://git.savannah.nongnu.org/git/bbdb.git";
+             :lisp-dir "lisp"))
+     (prog1 'bbdb
+       (leaf-handler-vc bbdb
+         (bbdb
+          (:url "https://git.savannah.nongnu.org/git/bbdb.git"; :lisp-dir 
"lisp")))))
+
+    ((leaf *bbdb-custom*
+       :vc (bbdb
+            :url "https://git.savannah.nongnu.org/git/bbdb.git";
+            :lisp-dir "lisp"))
+     (prog1 '*bbdb-custom*
+       (leaf-handler-vc *bbdb-custom*
+         (bbdb
+          (:url "https://git.savannah.nongnu.org/git/bbdb.git"; :lisp-dir 
"lisp")))))))
+#+end_src
+
+
 ** :preface, :init, :config keywords
 
 These keywords are provided to directly describe elisp with various
diff --git a/leaf-tests.el b/leaf-tests.el
index b7fdeeb113..abf2d00c95 100644
--- a/leaf-tests.el
+++ b/leaf-tests.el
@@ -319,6 +319,24 @@ Example:
      (prog1 'leaf
        (leaf-handler-package leaf leaf pin)))))
 
+(cort-deftest-with-macroexpand leaf/vc
+  '(((leaf bbdb
+       :vc ( :url "https://git.savannah.nongnu.org/git/bbdb.git";
+             :lisp-dir "lisp"))
+     (prog1 'bbdb
+       (leaf-handler-vc bbdb
+         (bbdb
+          (:url "https://git.savannah.nongnu.org/git/bbdb.git"; :lisp-dir 
"lisp")))))
+
+    ((leaf *bbdb-custom*
+       :vc (bbdb
+            :url "https://git.savannah.nongnu.org/git/bbdb.git";
+            :lisp-dir "lisp"))
+     (prog1 '*bbdb-custom*
+       (leaf-handler-vc *bbdb-custom*
+         (bbdb
+          (:url "https://git.savannah.nongnu.org/git/bbdb.git"; :lisp-dir 
"lisp")))))))
+
 (cort-deftest-with-macroexpand leaf/doc
   '(
     ;; any sexp will be ignored
diff --git a/leaf.el b/leaf.el
index 101a8790e2..905b7d23e5 100644
--- a/leaf.el
+++ b/leaf.el
@@ -98,6 +98,7 @@ Same as `list' but this macro does not evaluate any 
arguments."
    :emacs>=           (when leaf--body `((when (version<= ,leaf--value  
emacs-version) ,@leaf--body)))
 
    :package           `(,@(mapcar (lambda (elm) `(leaf-handler-package 
,leaf--name ,(car elm) ,(cdr elm))) leaf--value) ,@leaf--body)
+   :vc                `(,@(mapcar (lambda (elm) `(leaf-handler-vc ,leaf--name 
,elm)) leaf--value) ,@leaf--body)
 
    :after             (when leaf--body (let ((ret `(progn ,@leaf--body)))
                                          (dolist (elm leaf--value) (setq ret 
`(eval-after-load ',elm ',ret)))
@@ -318,6 +319,13 @@ Sort by `leaf-sort-leaf--values-plist' in this order.")
                   leaf--value))
        `(,val ,(delq nil (mapcar (lambda (elm) (when (symbolp elm) elm)) 
fns)))))
 
+    ((memq leaf--key '(:vc))
+     (mapcar (lambda (elm)
+               (if (keywordp (car elm))
+                   `(,leaf--name ,elm)
+                 `(,(car elm) ,(cdr elm))))
+             leaf--value))
+
     (t
      leaf--value))
   "Normalize rule.")
@@ -1104,6 +1112,18 @@ via PIN in the leaf block NAME."
                                  "  Error msg: %s")
                                (error-message-string err))))))))))
 
+(defmacro leaf-handler-vc (_name spec &optional _local-path)
+  "Handler for :vc SPEC for leaf block NAME.
+SPEC is a list of the form (PKG OPTIONS REVISION)"
+  (declare (indent 1))
+  (let ((pkg (nth 0 spec))
+        (opts (nth 1 spec))
+        (rev (nth 2 spec)))
+    `(unless (package-installed-p ',pkg)
+       (package-vc-install
+        ',(if opts `(,pkg ,@opts) pkg)
+        ,rev))))
+
 (defmacro leaf-handler-auth (name sym store)
   "Handler auth-* to set SYM of NAME from STORE."
   (if leaf-use-authinfo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]