branch: elpa/package-lint
commit 1c37329703a507fa357302cf6fc29d4f2fe631a8
Author: Steve Purcell <[email protected]>
Commit: Steve Purcell <[email protected]>
When linting a core+ELPA lib, don't complain that it isn't available
Fixes #281
---
package-lint-test.el | 7 +++++++
package-lint.el | 17 +++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/package-lint-test.el b/package-lint-test.el
index f4f8ccdd40c..8ee40bc0488 100644
--- a/package-lint-test.el
+++ b/package-lint-test.el
@@ -450,6 +450,13 @@ Alternatively, depend on (emacs \"24.3\") or greater, in
which cl-lib is bundled
(package-lint-test--run
"(seq-length '(foo))"))))
+(ert-deftest package-lint-test-no-dep-warnings-within-backported-libs ()
+ (should
+ (equal
+ '()
+ (package-lint-test--run
+ "(seq-length '(foo))" :featurename 'seq))))
+
(ert-deftest package-lint-test-accepts-new-backported-functions-with-emacs-dep
()
(should
(equal
diff --git a/package-lint.el b/package-lint.el
index 328521eeb65..5fe1b74f2d9 100644
--- a/package-lint.el
+++ b/package-lint.el
@@ -288,9 +288,9 @@ TYPE is `function' or `variable'."
(package-lint--check-no-use-of-cl-lib-sublibraries)
(package-lint--check-eval-after-load)
(package-lint--check-lexical-binding-requires-emacs-24 deps)
- (package-lint--check-libraries-available-in-emacs deps)
+ (package-lint--check-libraries-available-in-emacs deps prefix)
(package-lint--check-libraries-removed-from-emacs)
- (package-lint--check-macros-functions-available-in-emacs deps)
+ (package-lint--check-macros-functions-available-in-emacs deps
prefix)
(package-lint--check-macros-functions-removed-from-emacs deps)
(package-lint--check-objects-by-regexp
(concat "(" (regexp-opt '("format" "message" "error")) "\\s-")
@@ -623,7 +623,7 @@ CALLBACK."
(looking-at binding-pat))))))
(scan-error nil))))
-(defun package-lint--check-version-regexp-list (valid-deps symbol-regexp type)
+(defun package-lint--check-version-regexp-list (valid-deps prefix
symbol-regexp type)
"Warn if symbols matched by SYMBOL-REGEXP are unavailable in the target
Emacs.
The target Emacs version is taken from VALID-DEPS, which are the
declared dependencies of this package. TYPE is the
@@ -665,7 +665,10 @@ type of the symbol, either FUNCTION or FEATURE."
(cadr matching-dep))))
(and (eq type 'function)
(or (package-lint--seen-fboundp-check-for sym)
- (package-lint--is-a-let-binding))))
+ (package-lint--is-a-let-binding)))
+ ;; This is itself a core lib in ELPA
+ (and (eq type 'function) prefix
+ (string-prefix-p (format "%s-" prefix) sym)))
(list
'error
(format "You should depend on (emacs \"%s\")%s%s if you need
`%s'."
@@ -715,11 +718,12 @@ type of the symbol, either FUNCTION or FEATURE."
"(\\s-*?require\\s-*?'\\_<\\(.*?\\)\\_>\\s-*?)"
"Regexp to match unconditional `require' forms.")
-(defun package-lint--check-libraries-available-in-emacs (valid-deps)
+(defun package-lint--check-libraries-available-in-emacs (valid-deps prefix)
"Warn about use of libraries that are not available.
The check is performed against the Emacs version in VALID-DEPS."
(package-lint--check-version-regexp-list
valid-deps
+ prefix
package-lint--unconditional-require-regexp
'feature))
@@ -751,11 +755,12 @@ The check is performed against the Emacs version in
VALID-DEPS."
symbol-end))
"Regexp to match function names.")
-(defun package-lint--check-macros-functions-available-in-emacs (valid-deps)
+(defun package-lint--check-macros-functions-available-in-emacs (valid-deps
prefix)
"Warn about use of unavailable functions/macros that are not available.
The check is performed against the Emacs version in VALID-DEPS."
(package-lint--check-version-regexp-list
valid-deps
+ prefix
package-lint--function-name-regexp
'function))