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

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

[elpa] externals/leaf a1442a8 29/46: Merge branch 'master' into find-fun


From: Stefan Monnier
Subject: [elpa] externals/leaf a1442a8 29/46: Merge branch 'master' into find-func
Date: Mon, 15 Mar 2021 22:20:45 -0400 (EDT)

branch: externals/leaf
commit a1442a8e44d733d65a0533d2bb06117d3f094e9d
Merge: 005481d b07b728
Author: Naoya Yamashita <conao3@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge branch 'master' into find-func
---
 leaf-tests.el | 96 +++++++++++++++++++++++++++++------------------------------
 leaf.el       | 38 +++++++++++++++++------
 2 files changed, 77 insertions(+), 57 deletions(-)

diff --git a/leaf-tests.el b/leaf-tests.el
index a0fbcf5..e8e4071 100644
--- a/leaf-tests.el
+++ b/leaf-tests.el
@@ -854,11 +854,11 @@ Example:
        (foo-package-to-function . #'ignore)
        (foo-package-to-lambda   . (lambda (elm) (message elm))))
      (prog1 'foo-package
-       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in foo-package block")
-       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in foo-package block")))
+       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in `foo-package' block")
+       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in `foo-package' block")))
 
     ;; multi cons-cell in list will be accepted
     ((leaf foo-package
@@ -868,23 +868,23 @@ Example:
                 (foo-package-to-function . #'ignore)
                 (foo-package-to-lambda   . (lambda (elm) (message elm)))))
      (prog1 'foo-package
-       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in foo-package block")
-       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in foo-package block")))
+       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in `foo-package' block")
+       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in `foo-package' block")))
 
     ;; distribution feature is supported
     ((leaf foo-package
        :custom (((to-enable1 to-enable2 to-enable3) . t)
                 ((to-disable1 to-disable2 to-disable3) . nil)))
      (prog1 'foo-package
-       (customize-set-variable 'to-enable1 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-enable2 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-enable3 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable1 nil "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable2 nil "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable3 nil "Customized with leaf in 
foo-package block")))
+       (customize-set-variable 'to-enable1 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-enable2 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-enable3 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable1 nil "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable2 nil "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable3 nil "Customized with leaf in 
`foo-package' block")))
 
     ;; and mix specification is accepted
     ((leaf foo-package
@@ -894,15 +894,15 @@ Example:
        (((to-enable1 to-enable2 to-enable3) . t)
         ((to-disable1 to-disable2 to-disable3) . nil)))
      (prog1 'foo-package
-       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in foo-package block")
-       (customize-set-variable 'to-symbol1 'baz "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-symbol2 'baz "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-enable1 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-enable2 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-enable3 t "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable1 nil "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable2 nil "Customized with leaf in 
foo-package block")
-       (customize-set-variable 'to-disable3 nil "Customized with leaf in 
foo-package block")))))
+       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in `foo-package' block")
+       (customize-set-variable 'to-symbol1 'baz "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-symbol2 'baz "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-enable1 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-enable2 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-enable3 t "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable1 nil "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable2 nil "Customized with leaf in 
`foo-package' block")
+       (customize-set-variable 'to-disable3 nil "Customized with leaf in 
`foo-package' block")))))
 
 (cort-deftest-with-macroexpand leaf/custom*
   '(
@@ -929,11 +929,11 @@ Example:
                  (foo-package-to-function #'ignore)
                  (foo-package-to-lambda   (lambda (elm) (message elm)))))
      (prog1 'foo-package
-       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in foo-package block")
-       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in foo-package block")
-       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in foo-package block")))
+       (customize-set-variable 'foo-package-to-enable t "Customized with leaf 
in `foo-package' block")
+       (customize-set-variable 'foo-package-to-disable nil "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-symbol 'symbol "Customized with 
leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-function #'ignore "Customized 
with leaf in `foo-package' block")
+       (customize-set-variable 'foo-package-to-lambda (lambda (elm) (message 
elm)) "Customized with leaf in `foo-package' block")))
 
     ;; distribution feature is supported
     ;; ((leaf foo-package
@@ -974,7 +974,7 @@ Example:
        (eruby-standard-face . '((t (:slant italic)))))
      (prog1 'eruby-mode
        (custom-set-faces
-        '(eruby-standard-face ((t (:slant italic))) nil "Customized with leaf 
in eruby-mode block"))))
+        '(eruby-standard-face ((t (:slant italic))) nil "Customized with leaf 
in `eruby-mode' block"))))
 
     ;; distribution feature is supported
     ((leaf eruby-mode
@@ -982,8 +982,8 @@ Example:
        ((default eruby-standard-face) . '((t (:slant italic)))))
      (prog1 'eruby-mode
        (custom-set-faces
-        '(default ((t (:slant italic))) nil "Customized with leaf in 
eruby-mode block")
-        '(eruby-standard-face ((t (:slant italic))) nil "Customized with leaf 
in eruby-mode block"))))))
+        '(default ((t (:slant italic))) nil "Customized with leaf in 
`eruby-mode' block")
+        '(eruby-standard-face ((t (:slant italic))) nil "Customized with leaf 
in `eruby-mode' block"))))))
 
 (cort-deftest-with-macroexpand leaf/pl-custom
   '(
@@ -992,7 +992,7 @@ Example:
        :pl-custom
        (sql-connection-alist . some-plstore))
      (prog1 'sql
-       (customize-set-variable 'sql-connection-alist (leaf-handler-auth sql 
sql-connection-alist some-plstore) "Customized in leaf `sql' from plstore 
`some-plstore'")))
+       (customize-set-variable 'sql-connection-alist (leaf-handler-auth sql 
sql-connection-alist some-plstore) "Customized with leaf in `sql' block using 
`some-plstore' plstore")))
 
     ;; Emulate customizing `erc-password' and `erc-nickserv-passwords'
     ;; with values taken from `some-plstore', and `erc-user-full-name'
@@ -1002,17 +1002,17 @@ Example:
        ((erc-password erc-nickserv-passwords) . some-plstore)
        ((erc-user-full-name erc-nick) . another-plstore))
      (prog1 'erc
-       (customize-set-variable 'erc-password           (leaf-handler-auth erc 
erc-password some-plstore) "Customized in leaf `erc' from plstore 
`some-plstore'")
-       (customize-set-variable 'erc-nickserv-passwords (leaf-handler-auth erc 
erc-nickserv-passwords some-plstore) "Customized in leaf `erc' from plstore 
`some-plstore'")
-       (customize-set-variable 'erc-user-full-name     (leaf-handler-auth erc 
erc-user-full-name another-plstore) "Customized in leaf `erc' from plstore 
`another-plstore'")
-       (customize-set-variable 'erc-nick               (leaf-handler-auth erc 
erc-nick another-plstore) "Customized in leaf `erc' from plstore 
`another-plstore'")))
+       (customize-set-variable 'erc-password           (leaf-handler-auth erc 
erc-password some-plstore) "Customized with leaf in `erc' block using 
`some-plstore' plstore")
+       (customize-set-variable 'erc-nickserv-passwords (leaf-handler-auth erc 
erc-nickserv-passwords some-plstore) "Customized with leaf in `erc' block using 
`some-plstore' plstore")
+       (customize-set-variable 'erc-user-full-name     (leaf-handler-auth erc 
erc-user-full-name another-plstore) "Customized with leaf in `erc' block using 
`another-plstore' plstore")
+       (customize-set-variable 'erc-nick               (leaf-handler-auth erc 
erc-nick another-plstore) "Customized with leaf in `erc' block using 
`another-plstore' plstore")))
 
     ;; you can use symbol to configure with `leaf-default-plstore'.
     ((leaf erc
        :pl-custom erc-nick erc-password)
      (prog1 'erc
-       (customize-set-variable 'erc-nick     (leaf-handler-auth erc erc-nick 
leaf-default-plstore) "Customized in leaf `erc' from plstore 
`leaf-default-plstore'")
-       (customize-set-variable 'erc-password (leaf-handler-auth erc 
erc-password leaf-default-plstore) "Customized in leaf `erc' from plstore 
`leaf-default-plstore'")))))
+       (customize-set-variable 'erc-nick     (leaf-handler-auth erc erc-nick 
leaf-default-plstore) "Customized with leaf in `erc' block using 
`leaf-default-plstore' plstore")
+       (customize-set-variable 'erc-password (leaf-handler-auth erc 
erc-password leaf-default-plstore) "Customized with leaf in `erc' block using 
`leaf-default-plstore' plstore")))))
 
 (cort-deftest-with-macroexpand leaf/bind
   '(
@@ -2039,7 +2039,7 @@ Example:
      (prog1 'sql
        (customize-set-variable 'sql-connection-alist
                                (leaf-handler-auth sql sql-connection-alist 
some-plstore)
-                               "Customized in leaf `sql' from plstore 
`some-plstore'")))
+                               "Customized with leaf in `sql' block using 
`some-plstore' plstore")))
 
     ;; Emulate customizing `erc-password' and `erc-nickserv-passwords'
     ;; with values taken from `some-plstore', and `erc-user-full-name'
@@ -2049,17 +2049,17 @@ Example:
        ((erc-password erc-nickserv-passwords) . some-plstore)
        ((erc-user-full-name erc-nick) . another-plstore))
      (prog1 'erc
-       (customize-set-variable 'erc-password           (leaf-handler-auth erc 
erc-password some-plstore) "Customized in leaf `erc' from plstore 
`some-plstore'")
-       (customize-set-variable 'erc-nickserv-passwords (leaf-handler-auth erc 
erc-nickserv-passwords some-plstore) "Customized in leaf `erc' from plstore 
`some-plstore'")
-       (customize-set-variable 'erc-user-full-name     (leaf-handler-auth erc 
erc-user-full-name another-plstore) "Customized in leaf `erc' from plstore 
`another-plstore'")
-       (customize-set-variable 'erc-nick               (leaf-handler-auth erc 
erc-nick another-plstore) "Customized in leaf `erc' from plstore 
`another-plstore'")))
+       (customize-set-variable 'erc-password           (leaf-handler-auth erc 
erc-password some-plstore) "Customized with leaf in `erc' block using 
`some-plstore' plstore")
+       (customize-set-variable 'erc-nickserv-passwords (leaf-handler-auth erc 
erc-nickserv-passwords some-plstore) "Customized with leaf in `erc' block using 
`some-plstore' plstore")
+       (customize-set-variable 'erc-user-full-name     (leaf-handler-auth erc 
erc-user-full-name another-plstore) "Customized with leaf in `erc' block using 
`another-plstore' plstore")
+       (customize-set-variable 'erc-nick               (leaf-handler-auth erc 
erc-nick another-plstore) "Customized with leaf in `erc' block using 
`another-plstore' plstore")))
 
     ;; you can use symbol to configure with `leaf-default-plstore'.
     ((leaf erc
        :auth-custom erc-nick erc-password)
      (prog1 'erc
-       (customize-set-variable 'erc-nick     (leaf-handler-auth erc erc-nick 
leaf-default-plstore) "Customized in leaf `erc' from plstore 
`leaf-default-plstore'")
-       (customize-set-variable 'erc-password (leaf-handler-auth erc 
erc-password leaf-default-plstore) "Customized in leaf `erc' from plstore 
`leaf-default-plstore'")))))
+       (customize-set-variable 'erc-nick     (leaf-handler-auth erc erc-nick 
leaf-default-plstore) "Customized with leaf in `erc' block using 
`leaf-default-plstore' plstore")
+       (customize-set-variable 'erc-password (leaf-handler-auth erc 
erc-password leaf-default-plstore) "Customized with leaf in `erc' block using 
`leaf-default-plstore' plstore")))))
 
 (cort-deftest-with-macroexpand leaf/auth-setq
   '(
@@ -2262,7 +2262,7 @@ Example:
                 (package-install 'macrostep))
             (error
              (display-warning 'leaf
-                              (format "In `macrostep' block, failed to 
:package of macrostep.  Error msg: %s"
+                              (format "In `macrostep' block, failed to 
:package of `macrostep'.  Error msg: %s"
                                       (error-message-string err)))))))))))
 
 (when (version< "24.0" emacs-version)
diff --git a/leaf.el b/leaf.el
index 7bc74df..c5cedbb 100644
--- a/leaf.el
+++ b/leaf.el
@@ -136,11 +136,11 @@ Same as `list' but this macro does not evaluate any 
arguments."
    :pl-pre-setq       `(,@(mapcar (lambda (elm) `(setq ,(car elm) 
(leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)))) leaf--value) 
,@leaf--body)
    :auth-pre-setq     `(,@(mapcar (lambda (elm) `(setq ,(car elm) 
(leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)))) leaf--value) 
,@leaf--body)
 
-   :custom            `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) ,(cdr elm) ,(format "Customized with leaf in %s block" 
leaf--name))) leaf--value) ,@leaf--body)
-   :custom*           `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) ,(cdr elm) ,(format "Customized with leaf in %s block" 
leaf--name))) leaf--value) ,@leaf--body)
-   :pl-custom         `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) (leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)) ,(format 
"Customized in leaf `%s' from plstore `%s'" leaf--name (symbol-name (cdr 
elm))))) leaf--value) ,@leaf--body)
-   :auth-custom       `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) (leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)) ,(format 
"Customized in leaf `%s' from plstore `%s'" leaf--name (symbol-name (cdr 
elm))))) leaf--value) ,@leaf--body)
-   :custom-face       `((custom-set-faces     ,@(mapcar (lambda (elm) `'(,(car 
elm) ,(car (cddr elm)) nil ,(format "Customized with leaf in %s block" 
leaf--name))) leaf--value)) ,@leaf--body)
+   :custom            `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) ,(cdr elm) ,(leaf--create-custom-comment :custom))) leaf--value) 
,@leaf--body)
+   :custom*           `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) ,(cdr elm) ,(leaf--create-custom-comment :custom*))) leaf--value) 
,@leaf--body)
+   :pl-custom         `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) (leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)) 
,(leaf--create-custom-comment :pl-custom (cdr elm)))) leaf--value) ,@leaf--body)
+   :auth-custom       `(,@(mapcar (lambda (elm) `(customize-set-variable 
',(car elm) (leaf-handler-auth ,leaf--name ,(car elm) ,(cdr elm)) 
,(leaf--create-custom-comment :auth-custom (cdr elm)))) leaf--value) 
,@leaf--body)
+   :custom-face       `((custom-set-faces ,@(mapcar (lambda (elm) `'(,(car 
elm) ,(car (cddr elm)) nil ,(leaf--create-custom-comment :custom-face))) 
leaf--value)) ,@leaf--body)
    :init              `(,@leaf--value ,@leaf--body)
 
    :require           `(,@(mapcar (lambda (elm) `(require ',elm)) leaf--value) 
,@leaf--body)
@@ -596,6 +596,16 @@ see `alist-get'."
   "Raise error with type leaf.  MESSAGE and ARGS is same form as `lwarn'."
   (apply #'lwarn `(leaf :error ,message ,@args)))
 
+(defun leaf--create-custom-comment (type &rest args)
+  "Create message for TYPE using ARGS."
+  (concat
+   (format "Customized with leaf in `%s' block" leaf--name)
+   (when (memq type '(:pl-custom :auth-custom))
+     (let* ((store (pop args)))
+       (format " using `%s' plstore" store)))
+   (when load-file-name
+     (format " at `%s'" load-file-name))))
+
 
 ;;;; General functions for leaf
 
@@ -940,8 +950,14 @@ FN also accept list of FN."
   `(condition-case err
        (progn ,@body)
      (error
-      (display-warning 'leaf (format ,(format "Error in `%s' block.  Error 
msg: %%s" name)
-                                     (error-message-string err))))))
+      (display-warning 'leaf (format
+                              ,(concat
+                                (format "Error in `%s' block" name)
+                                (when load-file-name
+                                  (format " at `%s'" load-file-name))
+                                "."
+                                "  Error msg: %s")
+                              (error-message-string err))))))
 
 (defmacro leaf-handler-leaf-path (name)
   "Meta handler for :leaf-path for NAME."
@@ -966,8 +982,12 @@ FN also accept list of FN."
           (error
            (display-warning 'leaf
                             (format
-                             ,(format "In `%s' block, failed to :package of 
%s.  Error msg: %%s"
-                                      name pkg)
+                             ,(concat
+                               (format "In `%s' block" name)
+                               (when load-file-name
+                                 (format " at `%s'" load-file-name))
+                               (format ", failed to :package of `%s'." pkg)
+                               "  Error msg: %s")
                              (error-message-string err)))))))))
 
 (defmacro leaf-handler-auth (name sym store)



reply via email to

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