branch: scratch/editorconfig
commit ec1e5d8135a85b65f9bc0236a94bc415289fa5b9
Author: Stefan Monnier <monn...@iro.umontreal.ca>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Fix minor cosmetic issues
    
    Mostly fix compiler warnings and prefer #' to quote function names.
    
    * editorconfig.el: Remove dependency on `nadvice` since we require
    Emacs-26 which includes `nadvice` already.
    Remove redundant `require`s.  Remove redundant `:group` arguments.
    Move `defvar`s outside of `eval-when-compile`.
    Remove "post-end trailer".
    * .dir-locals.el: New file, to replace the "post-end trailer".
    
    * ert-tests/editorconfig-core-handle-tests.el (editorconfig--fixtures):
    Rename from `fixtures`.  Change all uses.
    
    * ert-tests/editorconfig-tests.el (test-editorconfig)
    (test-local-variables, test-hack-properties-functions):
    Use `bound-and-true-p` when it's not guaranteed that the var will
    be defined.
---
 .dir-locals.el                              |  4 ++
 editorconfig-fnmatch.el                     |  2 +-
 editorconfig-tools.el                       |  2 +-
 editorconfig.el                             | 68 ++++++++++-------------------
 ert-tests/editorconfig-core-handle-tests.el | 20 ++++-----
 ert-tests/editorconfig-tests.el             | 12 ++---
 6 files changed, 46 insertions(+), 62 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000000..cc741e0189
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,4 @@
+;;; Directory Local Variables         -*- no-byte-compile: t; -*-
+;;; For more information see (info "(emacs) Directory Variables")
+
+((emacs-lisp-mode (sentence-end-double-space . t)))
diff --git a/editorconfig-fnmatch.el b/editorconfig-fnmatch.el
index 25a344dc2e..520aeb16c2 100644
--- a/editorconfig-fnmatch.el
+++ b/editorconfig-fnmatch.el
@@ -234,7 +234,7 @@ translation is found for PATTERN."
                            (number-end (string-to-number (match-string 2
                                                                        
pattern-sub))))
                        (setq result `(,@result ,(concat "\\(?:"
-                                                        (mapconcat 
'number-to-string
+                                                        (mapconcat 
#'number-to-string
                                                                    (cl-loop 
for i from number-start to number-end
                                                                             
collect i)
                                                                    "\\|")
diff --git a/editorconfig-tools.el b/editorconfig-tools.el
index 12c4057714..31f7c17ba2 100644
--- a/editorconfig-tools.el
+++ b/editorconfig-tools.el
@@ -115,7 +115,7 @@ any of regexps in `editorconfig-exclude-regexps'."
     nil))
 ;;;###autoload
 (defalias 'describe-editorconfig-properties
-  'editorconfig-display-current-properties)
+  #'editorconfig-display-current-properties)
 
 ;;;###autoload
 (defun editorconfig-format-buffer()
diff --git a/editorconfig.el b/editorconfig.el
index cf6c03249a..6e215ce23d 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -5,7 +5,7 @@
 ;; Author: EditorConfig Team <editorcon...@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
@@ -41,17 +41,12 @@
 ;;; 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))
+(defvar tex-indent-basic)
+(defvar tex-indent-item)
+(defvar tex-indent-arg)
+(defvar evil-shift-width)
 
 (require 'editorconfig-core)
 
@@ -73,8 +68,7 @@ coding styles between different editors and IDEs."
   "Path to EditorConfig executable.
 
 Used by `editorconfig--execute-editorconfig-exec'."
-  :type 'string
-  :group 'editorconfig)
+  :type 'string)
 
 (define-obsolete-variable-alias
   'edconf-get-properties-function
@@ -107,13 +101,11 @@ Possible known values are:
     use `editorconfig-core-get-properties-hash'
 * `editorconfig-get-properties-from-exec'
   * Get properties by executing EditorConfig executable"
-  :type 'function
-  :group 'editorconfig)
+  :type 'function)
 
 (defcustom editorconfig-mode-lighter " EditorConfig"
   "Command `editorconfig-mode' lighter string."
-  :type 'string
-  :group 'editorconfig)
+  :type 'string)
 
 (define-obsolete-variable-alias
   'edconf-custom-hooks
@@ -143,8 +135,7 @@ show line numbers on the left:
 
 This hook will be run even when there are no matching sections in
 \".editorconfig\", or no \".editorconfig\" file was found at all."
-  :type 'hook
-  :group 'editorconfig)
+  :type 'hook)
 
 (defcustom editorconfig-hack-properties-functions ()
   "A list of function to alter property values before applying them.
@@ -166,8 +157,7 @@ overwrite \"indent_style\" property when current 
`major-mode' is a
 
 This hook will be run even when there are no matching sections in
 \".editorconfig\", or no \".editorconfig\" file was found at all."
-  :type 'hook
-  :group 'editorconfig)
+  :type 'hook)
 (make-obsolete-variable 'editorconfig-hack-properties-functions
                         "Using `editorconfig-after-apply-functions' instead is 
recommended,
     because since 2021/08/30 (v0.9.0) this variable cannot support all 
properties:
@@ -349,21 +339,18 @@ following forms:
 
 NOTE: Only the **buffer local** value of VARIABLE will be set."
   :type '(alist :key-type symbol :value-type sexp)
-  :risky t
-  :group 'editorconfig)
+  :risky t)
 
 (defcustom editorconfig-exclude-modes ()
   "Modes in which `editorconfig-mode-apply' will not run."
-  :type '(repeat (symbol :tag "Major Mode"))
-  :group 'editorconfig)
+  :type '(repeat (symbol :tag "Major Mode")))
 
 (defcustom editorconfig-exclude-regexps ()
   "List of regexp for buffer filenames `editorconfig-mode-apply' will not run.
 
 When variable `buffer-file-name' matches any of the regexps, then
 `editorconfig-mode-apply' will not do its work."
-  :type '(repeat string)
-  :group 'editorconfig)
+  :type '(repeat string))
 (with-eval-after-load 'recentf
   (add-to-list 'editorconfig-exclude-regexps
                (rx-to-string '(seq string-start
@@ -375,8 +362,7 @@ When variable `buffer-file-name' matches any of the 
regexps, then
 
 If set, enable that mode when `trim_trailing_whitespace` is set to true.
 Otherwise, use `delete-trailing-whitespace'."
-  :type 'symbol
-  :group 'editorconfig)
+  :type 'symbol)
 
 (defvar editorconfig-properties-hash nil
   "Hash object of EditorConfig properties that was enabled for current buffer.
@@ -400,13 +386,11 @@ number - `lisp-indent-offset' is not set only if 
indent_size is
 
 (defcustom editorconfig-override-file-local-variables t
   "Non-nil means editorconfig will override file local variable values."
-  :type 'boolean
-  :group 'editorconfig)
+  :type 'boolean)
 
 (defcustom editorconfig-override-dir-local-variables t
   "Non-nil means editorconfig will override values defined in dir-locals.el ."
-  :type 'boolean
-  :group 'editorconfig)
+  :type 'boolean)
 
 (define-error 'editorconfig-error
               "Error thrown from editorconfig lib")
@@ -676,7 +660,7 @@ to non-nil when FINAL-NEWLINE is true."
       (let ((key-val (split-string prop " *= *")))
         (when (> (length key-val) 1)
           (let ((key (intern (car key-val)))
-                (val (mapconcat 'identity (cdr key-val) "")))
+                (val (mapconcat #'identity (cdr key-val) "")))
             (puthash key val properties)))))))
 
 (defun editorconfig-get-properties-from-exec (filename)
@@ -875,16 +859,16 @@ To disable EditorConfig in some buffers, modify
                      rpm-spec-mode-hook)))
     (if editorconfig-mode
         (progn
-          (advice-add 'find-file-noselect :around 
'editorconfig--advice-find-file-noselect)
-          (advice-add 'insert-file-contents :around 
'editorconfig--advice-insert-file-contents)
+          (advice-add 'find-file-noselect :around 
#'editorconfig--advice-find-file-noselect)
+          (advice-add 'insert-file-contents :around 
#'editorconfig--advice-insert-file-contents)
           (dolist (hook modehooks)
             (add-hook hook
-                      'editorconfig-major-mode-hook
+                      #'editorconfig-major-mode-hook
                       t)))
-      (advice-remove 'find-file-noselect 
'editorconfig--advice-find-file-noselect)
-      (advice-remove 'insert-file-contents 
'editorconfig--advice-insert-file-contents)
+      (advice-remove 'find-file-noselect 
#'editorconfig--advice-find-file-noselect)
+      (advice-remove 'insert-file-contents 
#'editorconfig--advice-insert-file-contents)
       (dolist (hook modehooks)
-        (remove-hook hook 'editorconfig-major-mode-hook)))))
+        (remove-hook hook #'editorconfig-major-mode-hook)))))
 
 
 ;; (defconst editorconfig--version
@@ -924,7 +908,3 @@ version in the echo area and the messages buffer."
 
 (provide 'editorconfig)
 ;;; editorconfig.el ends here
-
-;; Local Variables:
-;; sentence-end-double-space: t
-;; End:
diff --git a/ert-tests/editorconfig-core-handle-tests.el 
b/ert-tests/editorconfig-core-handle-tests.el
index 2c28137394..0ebdab0c8c 100644
--- a/ert-tests/editorconfig-core-handle-tests.el
+++ b/ert-tests/editorconfig-core-handle-tests.el
@@ -25,47 +25,47 @@
 
 (require 'editorconfig-core-handle)
 
-(defconst fixtures (concat (file-name-directory load-file-name) "fixtures/")
+(defconst editorconfig--fixtures (concat (file-name-directory load-file-name) 
"fixtures/")
   "Path to fixtures.")
 
 (set-variable 'vc-handled-backends nil)
 
 (ert-deftest test-editorconfig-core-handle ()
   ;; handle.ini
-  (let* ((conf (concat fixtures "handle.ini"))
+  (let* ((conf (concat editorconfig--fixtures "handle.ini"))
          (handle (editorconfig-core-handle conf)))
     (should (editorconfig-core-handle-root-p handle))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "b.js"))
                    '((("key2" . "value2")))))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "a.js"))
                    '((("key1" . "value1")) (("key2" . "value2"))))))
   ;; Test twice for checking cache
-  (let* ((conf (concat fixtures "handle.ini"))
+  (let* ((conf (concat editorconfig--fixtures "handle.ini"))
          (handle (editorconfig-core-handle conf)))
     (should (editorconfig-core-handle-root-p handle))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "b.js"))
                    '((("key2" . "value2")))))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "a.js"))
                    '((("key1" . "value1")) (("key2" . "value2"))))))
 
   ;; handle2.ini
-  (let* ((conf (concat fixtures "handle2.ini"))
+  (let* ((conf (concat editorconfig--fixtures "handle2.ini"))
          (handle (editorconfig-core-handle conf)))
     (should-not (editorconfig-core-handle-root-p handle))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "b.js"))
                    nil))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
+                                                            (concat 
editorconfig--fixtures
                                                                     "a.js"))
                    '((("key" . "value"))))))
 
diff --git a/ert-tests/editorconfig-tests.el b/ert-tests/editorconfig-tests.el
index 4fcfe13f4e..75da5ebade 100644
--- a/ert-tests/editorconfig-tests.el
+++ b/ert-tests/editorconfig-tests.el
@@ -75,7 +75,7 @@
     (should (eq indent-tabs-mode nil)))
 
   (with-visit-file (concat editorconfig-ert-dir "4_space.py")
-    (should (eq python-indent-offset 4))
+    (should (eq (bound-and-true-p python-indent-offset) 4))
     (should (eq tab-width 8))
     (should (eq indent-tabs-mode nil)))
   (editorconfig-mode -1))
@@ -127,21 +127,21 @@
   (editorconfig-mode 1)
   (with-visit-file (concat editorconfig-local-variables-ert-dir 
"file_locals.rb")
     (should (eq tab-width 9))
-    (should (eq ruby-indent-level 7)))
+    (should (eq (bound-and-true-p ruby-indent-level) 7)))
 
   (with-visit-file (concat editorconfig-local-variables-ert-dir "dir_locals.c")
     (should (eq tab-width 9))
-    (should (eq c-basic-offset 7)))
+    (should (eq (bound-and-true-p c-basic-offset) 7)))
 
   (let ((editorconfig-override-file-local-variables nil))
     (with-visit-file (concat editorconfig-local-variables-ert-dir 
"file_locals.rb")
       (should (eq tab-width 5))
-      (should (eq ruby-indent-level 3))))
+      (should (eq (bound-and-true-p ruby-indent-level) 3))))
 
   (let ((editorconfig-override-dir-local-variables nil))
     (with-visit-file (concat editorconfig-local-variables-ert-dir 
"dir_locals.c")
       (should (eq tab-width 5))
-      (should (eq c-basic-offset 3))))
+      (should (eq (bound-and-true-p c-basic-offset) 3))))
   (editorconfig-mode -1))
 
 (ert-deftest test-file-type-emacs nil
@@ -168,7 +168,7 @@
             (lambda (props)
               (puthash 'indent_size "5" props)))
   (with-visit-file (concat editorconfig-ert-dir "4_space.py")
-    (should (eq python-indent-offset 5)))
+    (should (eq (bound-and-true-p python-indent-offset) 5)))
   (setq editorconfig-hack-properties-functions nil)
   (editorconfig-mode -1))
 

Reply via email to