From: Stefan Monnier Date: Tue, 18 Jun 2024 14:51:48 +0000 (-0400) Subject: editorconfig.el: Miscellaneous minor changes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9053a3b40c9814708756eb74cfad00541b9d4074;p=emacs.git editorconfig.el: Miscellaneous minor changes * lisp/editorconfig.el: Drop redundant `require`s of pcase, nadvice, rx. Remove unnecessary (and incorrect) `defvar`s in `eval-when-compile`. (find-library-name, lm-version): Move declarations to right after the corresponding `require` so we have a reason to believe they're defined. (editorconfig-version): Use `package-get-version` when available. * lisp/editorconfig-core.el (editorconfig-core-get-nearest-editorconfig) (editorconfig-core-get-properties, editorconfig-core-get-properties-hash): * lisp/editorconfig-fnmatch.el (editorconfig-fnmatch-p): Remove autoload cookies. (cherry picked from commit 57b2439cb566599c570826b141d31cdf52478f9d) --- diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index bdd5f49aa6e..3dfdd5c7188 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -90,7 +90,6 @@ RESULT is used internally and normally should not be used." confname (cons handle result))))) -;;;###autoload (defun editorconfig-core-get-nearest-editorconfig (directory) "Return path to .editorconfig file that is closest to DIRECTORY." (when-let* ((handle (car (last @@ -98,7 +97,6 @@ RESULT is used internally and normally should not be used." ".editorconfig"))))) (editorconfig-core-handle-path handle))) -;;;###autoload (defun editorconfig-core-get-properties (&optional file confname confversion) "Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. @@ -122,7 +120,6 @@ When the same key exists in both two hashes, values of UPDATE takes precedence." (maphash (lambda (key value) (puthash key value into)) update) into) -;;;###autoload (defun editorconfig-core-get-properties-hash (&optional file confname confversion) "Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index 4f6feb0f893..745c3cf8a40 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -83,7 +83,6 @@ string (substring string (match-end 0)))) num)) -;;;###autoload (defun editorconfig-fnmatch-p (string pattern) "Test whether STRING match PATTERN. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index c5bf08f772c..a1283e23ae0 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -5,7 +5,7 @@ ;; Author: EditorConfig Team ;; Version: 0.11.0 ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme -;; Package-Requires: ((emacs "26.1") (nadvice "0.3")) +;; Package-Requires: ((emacs "26.1")) ;; Keywords: convenience editorconfig ;; See @@ -49,17 +49,8 @@ ;;; Code: (require 'cl-lib) -(require 'pcase) -(require 'nadvice) - -(eval-when-compile - (require 'rx) - (require 'subr-x) - (defvar tex-indent-basic) - (defvar tex-indent-item) - (defvar tex-indent-arg) - (defvar evil-shift-width)) +(eval-when-compile (require 'subr-x)) (require 'editorconfig-core) @@ -686,9 +677,6 @@ Meant to be used on `hack-dir-local-get-variables-functions'." ;; (lm-version)) ;; "EditorConfig version.") -(declare-function find-library-name "find-func" (library)) -(declare-function lm-version "lisp-mnt" nil) - ;;;###autoload (defun editorconfig-version (&optional show-version) "Get EditorConfig version as string. @@ -696,20 +684,26 @@ Meant to be used on `hack-dir-local-get-variables-functions'." If called interactively or if SHOW-VERSION is non-nil, show the version in the echo area and the messages buffer." (interactive (list t)) - (let* ((version (with-temp-buffer - (require 'find-func) - (insert-file-contents (find-library-name "editorconfig")) - (require 'lisp-mnt) - (lm-version))) - (pkg (and (eval-and-compile (require 'package nil t)) - (cadr (assq 'editorconfig - package-alist)))) - (pkg-version (and pkg - (package-version-join (package-desc-version pkg)))) - (version-full (if (and pkg-version - (not (string= version pkg-version))) - (concat version "-" pkg-version) - version))) + (let ((version-full + (if (fboundp 'package-get-version) + (package-get-version) + (let* ((version + (with-temp-buffer + (require 'find-func) + (declare-function find-library-name "find-func" (library)) + (insert-file-contents (find-library-name "editorconfig")) + (require 'lisp-mnt) + (declare-function lm-version "lisp-mnt" nil) + (lm-version))) + (pkg (and (eval-and-compile (require 'package nil t)) + (cadr (assq 'editorconfig + package-alist)))) + (pkg-version (and pkg (package-version-join + (package-desc-version pkg))))) + (if (and pkg-version + (not (string= version pkg-version))) + (concat version "-" pkg-version) + version))))) (when show-version (message "EditorConfig Emacs v%s" version-full)) version-full))