]> git.eshelyaron.com Git - emacs.git/commitdiff
editorconfig.el: Miscellaneous minor changes
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 18 Jun 2024 14:51:48 +0000 (10:51 -0400)
committerEshel Yaron <me@eshelyaron.com>
Fri, 21 Jun 2024 19:00:14 +0000 (21:00 +0200)
* 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)

lisp/editorconfig-core.el
lisp/editorconfig-fnmatch.el
lisp/editorconfig.el

index bdd5f49aa6eacd6364743286c65fb70666566b8c..3dfdd5c71883e1b31efed0e891a2ec4ac4504636 100644 (file)
@@ -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.
index 4f6feb0f8934efee82afdc1553b7c7e7433fd50c..745c3cf8a40a71017dee1246e3e2e9f03dbd22de 100644 (file)
@@ -83,7 +83,6 @@
             string (substring string (match-end 0))))
     num))
 
-;;;###autoload
 (defun editorconfig-fnmatch-p (string pattern)
   "Test whether STRING match PATTERN.
 
index c5bf08f772c326d696ef15cbc736158ceca66d8d..a1283e23ae05327d348075f3a1be45434a8d2893 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: EditorConfig Team <editorconfig@googlegroups.com>
 ;; 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
 ;;; 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))