summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Purcell <steve@sanityinc.com>2024-02-15 03:23:27 +1300
committerGitHub <noreply@github.com>2024-02-15 03:23:27 +1300
commita78eb9a77dc1c6f0ffee6704b99621d10ca44be0 (patch)
tree906ac9ef783b3b7d374341c922a09fee6ffde315
parenta6a74293dbc9c69c568c79c509d2aa3b67bc6769 (diff)
parentd14e152edc387cb1445157dea984d57a58b56052 (diff)
Merge pull request #262 from minad/dump-compat-symbols
Add tools/compat-dump.el which generates data/compat-symbols
-rw-r--r--data/compat-symbols1
-rw-r--r--package-lint.el44
-rwxr-xr-xtools/compat-dump21
3 files changed, 37 insertions, 29 deletions
diff --git a/data/compat-symbols b/data/compat-symbols
new file mode 100644
index 0000000..a757a98
--- /dev/null
+++ b/data/compat-symbols
@@ -0,0 +1 @@
+((file-has-changed-p--hash-table set-transient-map-timer set-transient-map-timeout lisp-directory color-luminance-dark-limit read-answer-short read-char-from-minibuffer-map-hash read-char-from-minibuffer-map read-char-history major-mode--suspended regexp-unmatchable mouse-select-region-move-to-beginning mounted-file-systems gensym-counter text-quoting-style) ert-with-temp-directory ert-with-temp-file cl-once-only cl-with-gensyms cl-constantly count-sentences read-multiple-choice buttonize-region buttonize button--properties substitute-quotes define-key defvar-keymap define-keymap keymap-global-lookup keymap-local-lookup keymap-lookup keymap-set-after keymap-substitute keymap-local-unset keymap-global-unset keymap-local-set keymap-global-set keymap-unset keymap-set key-parse keymap--check key-valid-p file-has-changed-p file-name-parent-directory file-attribute-file-identifier file-name-split directory-abbrev-apply directory-abbrev-make-regexp while-let add-display-text-property with-buffer-unmodified-if-unchanged get-scratch-buffer-create use-region-end use-region-beginning use-region-noncontiguous-p char-uppercase-p set-transient-map match-buffers buffer-match-p function-alias-p compiled-function-p string-split with-memoization without-restriction with-restriction delete-line plistp list-of-strings-p buffer-local-set-state buffer-local-set-state--get buffer-local-restore-state readablep string-lines funcall-with-delayed-message with-delayed-message pos-eol pos-bol plist-member plist-put plist-get string-equal-ignore-case take ntake get-display-property window-configuration-equal-p button-buttonize text-quoting-style decoded-time-period with-environment-variables macroexp-file-name macroexp-warn-and-return mark-thing-at-mouse bounds-of-thing-at-mouse thing-at-mouse count-windows with-window-non-dedicated color-dark-p format-prompt make-lock-file-name file-backup-file-names file-modes-number-to-symbolic directory-empty-p file-name-with-extension named-let string-chop-newline string-pad string-fill string-clean-whitespace subr-native-elisp-p subr-primitive-p ensure-list dlet with-existing-directory buffer-local-boundp replace-regexp-in-region replace-string-in-region insert-into-buffer always string-replace process-lines-ignore-status process-lines-handling-status make-separator-line color-values-from-color-spec directory-files-and-attributes directory-files string-width garbage-collect-maybe file-name-concat length> length< length= string-search native-comp-available-p read-answer ring-resize text-property-search-backward text-property-search-forward date-ordinal-to-time date-days-in-month make-decoded-time package-get-version regexp-opt make-empty-file executable-find exec-path file-size-human-readable-iec file-size-human-readable file-name-unquote file-name-quote file-name-quoted-p image--set-property with-suppressed-warnings with-minibuffer-selected-window minibuffer-history-value read-char-from-minibuffer read-char-from-minibuffer-insert-other read-char-from-minibuffer-insert-char major-mode-restore major-mode-suspend assoc-delete-all xor flatten-tree dolist-with-progress-reporter ignore-error setq-local bignump fixnump time-equal-p lookup-key recenter string-distance proper-list-p read-multiple-choice image-property file-attribute-collect file-attribute-device-number file-attribute-inode-number file-attribute-modes file-attribute-size file-attribute-status-change-time file-attribute-modification-time file-attribute-access-time file-attribute-group-id file-attribute-user-id file-attribute-link-number file-attribute-type make-nearby-temp-file make-temp-file temporary-file-directory file-local-name and-let* when-let* if-let* gensym cddddr cdddar cddadr cddaar cdaddr cdadar cdaadr cdaaar cadddr caddar cadadr cadaar caaddr caadar caaadr caaaar cdddr cddar cdadr cdaar caddr cadar caadr caaar string-trim string-trim-right string-trim-left alist-get assoc provided-mode-derived-p region-bounds line-number-at-pos mapcan buffer-hash macroexpand-1 macroexp-quote macroexp-parse-body thread-last thread-first hash-table-empty-p when-let if-let with-file-modes string-greaterp region-noncontiguous-p save-mark-and-excursion directory-name-p format-message sort bool-vector) \ No newline at end of file
diff --git a/package-lint.el b/package-lint.el
index 49aa936..e491b0f 100644
--- a/package-lint.el
+++ b/package-lint.el
@@ -7,7 +7,7 @@
;; URL: https://github.com/purcell/package-lint
;; Keywords: lisp
;; Version: 0.21
-;; Package-Requires: ((cl-lib "0.5") (emacs "24.4") (let-alist "1.0.6") (compat "29.1"))
+;; Package-Requires: ((emacs "24.4") (let-alist "1.0.6"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -110,14 +110,18 @@ SYMBOL-NAME-MATCH PACKAGE VERSION?) where PACKAGE is the name of
a backport library shipping the feature and VERSION is an
optional minimum version containing the feature.")
+(defun package-lint--load-data (file)
+ "Load sexp data from FILE."
+ (with-temp-buffer
+ (insert-file-contents
+ (expand-file-name file
+ (if load-file-name
+ (file-name-directory load-file-name)
+ default-directory)))
+ (read (current-buffer))))
+
(defconst package-lint-symbol-info
- (let* ((stdlib-changes (with-temp-buffer
- (insert-file-contents
- (expand-file-name "data/stdlib-changes"
- (if load-file-name
- (file-name-directory load-file-name)
- default-directory)))
- (read (current-buffer))))
+ (let* ((stdlib-changes (package-lint--load-data "data/stdlib-changes"))
(info (make-hash-table)))
(pcase-dolist (`(,version . ,data) stdlib-changes)
(pcase-dolist (`(,syms . ,action)
@@ -172,33 +176,15 @@ symbol such as `variable-added'.")
(let-alist (package-lint-symbol-info sym)
(or .function-added .function-removed)))
-(defconst package-lint--supported-symbols
- (let (symbols functions)
- (dolist (ver '(25 26 27 28 29))
- (let ((el-path (locate-library (format "compat-%d.el" ver) t)))
- (unless el-path
- (error "compat package not installed"))
- (with-temp-buffer
- (insert-file-contents el-path)
- (goto-char (point-min))
- (while (search-forward-regexp (rx line-start
- "(compat-" (group (or "defun" "defmacro" "defvar" "defalias"))
- (+ space)
- symbol-start
- (group (+? any))
- symbol-end)
- nil t)
- (pcase (match-string 1)
- ("defvar" (push (intern (match-string 2)) symbols))
- ((or "defun" "defmacro" "defalias") (push (intern (match-string 2)) functions)))))))
- (cons symbols functions))
+(defconst package-lint--compat-symbols
+ (package-lint--load-data "data/compat-symbols")
"A cons cell of (VARS . FUNCTIONS) supported by \"compat\".")
(defun package-lint--supported-by-compat (type sym)
"Return non-nil if SYM is supported by the \"compat\" package.
TYPE is `function' or `variable'."
(memq sym (pcase type
- (`function (cdr package-lint--supported-symbols))
+ (`function (cdr package-lint--compat-symbols))
(_ nil))))
(defconst package-lint--sane-prefixes
diff --git a/tools/compat-dump b/tools/compat-dump
new file mode 100755
index 0000000..058d3cf
--- /dev/null
+++ b/tools/compat-dump
@@ -0,0 +1,21 @@
+#!/usr/bin/env -S emacs -Q --script
+(unless (string-suffix-p "/package-lint/" default-directory)
+ (error "Not in the package-lint directory"))
+(let (symbols functions)
+ (dolist (file (directory-files "../compat/" t "compat-[0-9]+\\.el$"))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (while (search-forward-regexp (rx line-start
+ "(compat-" (group (or "defun" "defmacro" "defvar" "defalias"))
+ (+ space)
+ symbol-start
+ (group (+? any))
+ symbol-end)
+ nil t)
+ (pcase (match-string 1)
+ ("defvar" (push (intern (match-string 2)) symbols))
+ ((or "defun" "defmacro" "defalias") (push (intern (match-string 2)) functions))))))
+ (with-temp-buffer
+ (insert (prin1-to-string (cons symbols functions)))
+ (write-region (point-min) (point-max) "data/compat-symbols" nil 'quiet)))