[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/leaf e0c4b74 06/46: Merge pull request #467 from Z572/l
From: |
Stefan Monnier |
Subject: |
[elpa] externals/leaf e0c4b74 06/46: Merge pull request #467 from Z572/load-file-name |
Date: |
Mon, 15 Mar 2021 22:20:42 -0400 (EDT) |
branch: externals/leaf
commit e0c4b7484ab6ee3bbf8413f620ccb99af4328d2f
Merge: ef0bdd4 e0f84ad
Author: Naoya Yamashita <conao3@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #467 from Z572/load-file-name
Add load-file-name in Warning and more.
---
leaf-tests.el | 96 +++++++++++++++++++++++++++++------------------------------
leaf.el | 40 ++++++++++++++++++-------
2 files changed, 78 insertions(+), 58 deletions(-)
diff --git a/leaf-tests.el b/leaf-tests.el
index ff47f0e..1a78e53 100644
--- a/leaf-tests.el
+++ b/leaf-tests.el
@@ -851,11 +851,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
@@ -865,23 +865,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
@@ -891,15 +891,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*
'(
@@ -926,11 +926,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
@@ -971,7 +971,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
@@ -979,8 +979,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
'(
@@ -989,7 +989,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'
@@ -999,17 +999,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
'(
@@ -2036,7 +2036,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'
@@ -2046,17 +2046,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
'(
@@ -2234,7 +2234,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 ee95eb5..d7f1d7b 100644
--- a/leaf.el
+++ b/leaf.el
@@ -5,7 +5,7 @@
;; Author: Naoya Yamashita <conao3@gmail.com>
;; Maintainer: Naoya Yamashita <conao3@gmail.com>
;; Keywords: lisp settings
-;; Version: 4.3.2
+;; Version: 4.3.3
;; URL: https://github.com/conao3/leaf.el
;; Package-Requires: ((emacs "24.1"))
@@ -134,11 +134,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)
@@ -587,6 +587,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
@@ -905,8 +915,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-package (name pkg _pin)
"Handler ensure PKG via PIN in NAME leaf block."
@@ -923,8 +939,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)
- [elpa] externals/leaf updated (ef0bdd4 -> b1fe4f2), Stefan Monnier, 2021/03/15
- [elpa] externals/leaf e0f84ad 05/46: tagged v4.3.3, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf a314668 04/46: fix test, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 6e9a4cc 02/46: unify expression; use `in <leafname> block at <filename>`, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 86b4b85 03/46: implement leaf--create-custom-comment and use it, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf e0c4b74 06/46: Merge pull request #467 from Z572/load-file-name,
Stefan Monnier <=
- [elpa] externals/leaf f425433 14/46: Revert "add :commands* keyword", Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 7936c2f 13/46: Revert "update document, tagged v4.3.4", Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 7cce6cc 15/46: tagged v4.3.5, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf e5c185e 21/46: handle no candidates situation, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf f1746b8 41/46: use leaf-this-file instead of just ref load-file-name, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 721319c 01/46: Add load-file-name in Warning, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf 562885f 08/46: README: add documentation about the leaf-find, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf c5ddde8 09/46: leaf-path: add test, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf a82c47d 10/46: add :commands* keyword, Stefan Monnier, 2021/03/15
- [elpa] externals/leaf ad2d3ee 12/46: Merge pull request #472 from conao3/feature#471, Stefan Monnier, 2021/03/15