emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] scratch/editorconfig-cc ebd09d700f 047/351: Fix all indentation


From: Stefan Monnier
Subject: [nongnu] scratch/editorconfig-cc ebd09d700f 047/351: Fix all indentation according to editorconfig
Date: Thu, 13 Jun 2024 18:38:39 -0400 (EDT)

branch: scratch/editorconfig-cc
commit ebd09d700f5c7e780fd454cfa24d218a8484aec2
Author: 10sr <8slashes+git@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Fix all indentation according to editorconfig
---
 bin/editorconfig-el                   |   4 +-
 editorconfig-core-handle.el           | 156 ++++++++++-----------
 editorconfig-core.el                  |  90 ++++++------
 editorconfig-fnmatch.el               | 254 +++++++++++++++++-----------------
 ert-tests/editorconfig-core-handle.el |  60 ++++----
 ert-tests/editorconfig-core.el        |  20 +--
 ert-tests/editorconfig-fnmatch.el     | 202 +++++++++++++--------------
 7 files changed, 393 insertions(+), 393 deletions(-)

diff --git a/bin/editorconfig-el b/bin/editorconfig-el
index fbba8ea971..975fbf2cf5 100755
--- a/bin/editorconfig-el
+++ b/bin/editorconfig-el
@@ -15,8 +15,8 @@
 (when (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
   (setq load-path
         (append (split-string (getenv "EDITORCONFIG_CORE_LIBRARY_PATH")
-                             ":")
-               load-path)))
+                              ":")
+                load-path)))
 
 (require 'cl-lib)
 (require 'editorconfig-core)
diff --git a/editorconfig-core-handle.el b/editorconfig-core-handle.el
index ac9fa2e2a6..452fce8b07 100644
--- a/editorconfig-core-handle.el
+++ b/editorconfig-core-handle.el
@@ -55,20 +55,20 @@
 If CONF does not exist return nil."
   (when (file-readable-p conf)
     (let ((cached (gethash conf
-                           editorconfig-core-handle--cache-hash))
-          (mtime (nth 5
-                      (file-attributes conf))))
+                    editorconfig-core-handle--cache-hash))
+           (mtime (nth 5
+                    (file-attributes conf))))
       (if (and cached
-               (equal (editorconfig-core-handle-mtime cached)
-                      mtime))
-          cached
+            (equal (editorconfig-core-handle-mtime cached)
+              mtime))
+        cached
         (let ((parsed (editorconfig-core-handle--parse-file conf)))
           (puthash conf
-                   (make-editorconfig-core-handle :top-prop (car parsed)
-                                                  :prop (cdr parsed)
-                                                  :mtime mtime
-                                                  :path conf)
-                   editorconfig-core-handle--cache-hash))))))
+            (make-editorconfig-core-handle :top-prop (car parsed)
+              :prop (cdr parsed)
+              :mtime mtime
+              :path conf)
+            editorconfig-core-handle--cache-hash))))))
 
 (defun editorconfig-core-handle-root-p (handle)
   "Return non-nil if HANDLE represent root EditorConfig file.
@@ -76,9 +76,9 @@ If CONF does not exist return nil."
 If HANDLE is nil return nil."
   (when handle
     (string-equal "true"
-             (downcase (or (cdr (assoc "root"
-                                       (editorconfig-core-handle-top-prop 
handle)))
-                           "")))))
+      (downcase (or (cdr (assoc "root"
+                           (editorconfig-core-handle-top-prop handle)))
+                  "")))))
 
 (defun editorconfig-core-handle-get-properties (handle file)
   "Return list of alist of properties from HANDLE for FILE.
@@ -87,11 +87,11 @@ The list returned will be ordered by the lines they appear.
 If HANDLE is nil return nil."
   (when handle
     (mapcar 'cdr
-            (cl-remove-if-not (lambda (prop)
-                                (editorconfig-core-handle--fnmatch-p file
-                                                                     (car prop)
-                                                                     
(file-name-directory (editorconfig-core-handle-path handle))))
-                              (editorconfig-core-handle-prop handle)))))
+      (cl-remove-if-not (lambda (prop)
+                          (editorconfig-core-handle--fnmatch-p file
+                            (car prop)
+                            (file-name-directory 
(editorconfig-core-handle-path handle))))
+        (editorconfig-core-handle-prop handle)))))
 
 (defun editorconfig-core-handle--fnmatch-p (name pattern dir)
   "Return non-nil if NAME match PATTERN.
@@ -99,24 +99,24 @@ If pattern has slash, pattern should be relative to DIR.
 
 This function is a fnmatch with a few modification for EditorConfig usage."
   (if (string-match-p "/" pattern)
-      (let ((pattern (replace-regexp-in-string "^/"
-                                               ""
-                                               pattern))
-            (dir (file-name-as-directory dir)))
-        (editorconfig-fnmatch-p name
-                                (concat dir
-                                        pattern)))
+    (let ((pattern (replace-regexp-in-string "^/"
+                     ""
+                     pattern))
+           (dir (file-name-as-directory dir)))
+      (editorconfig-fnmatch-p name
+        (concat dir
+          pattern)))
     (editorconfig-fnmatch-p name
-                            (concat "**/"
-                                    pattern))))
+      (concat "**/"
+        pattern))))
 
 (defsubst editorconfig-core-handle--string-trim (str)
   "Remove leading and trailing whitespace from STR."
   (replace-regexp-in-string "[ \t\n\r]+\\'"
-                            ""
-                            (replace-regexp-in-string "\\`[ \t\n\r]+"
-                                                      ""
-                                                      str)))
+    ""
+    (replace-regexp-in-string "\\`[ \t\n\r]+"
+      ""
+      str)))
 
 (defun editorconfig-core-handle--parse-file (conf)
   "Parse EditorConfig file CONF.
@@ -133,65 +133,65 @@ If CONF is not found return nil."
       (insert-file-contents conf)
       (goto-char (point-min))
       (let ((point-max (point-max))
-            (all-props ())
-            (top-props nil)
+             (all-props ())
+             (top-props nil)
 
-            ;; String of current line
-            (line "")
-            ;; nil when pattern not appeared yet, "" when pattern is empty 
("[]")
-            (pattern nil)
-            ;; Alist of properties for current PATTERN
-            (props ())
+             ;; String of current line
+             (line "")
+             ;; nil when pattern not appeared yet, "" when pattern is empty 
("[]")
+             (pattern nil)
+             ;; Alist of properties for current PATTERN
+             (props ())
 
-            )
+             )
         (while (not (eq (point) point-max))
           (setq line
-                (buffer-substring-no-properties (point-at-bol)
-                                                (point-at-eol)))
+            (buffer-substring-no-properties (point-at-bol)
+              (point-at-eol)))
           (setq line
-                (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$"
-                                          ""
-                                          
(editorconfig-core-handle--string-trim line)))
+            (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$"
+              ""
+              (editorconfig-core-handle--string-trim line)))
 
           (cond
-           ((string-equal "" line)
-            nil)
-
-           ((string-match "^\\[\\(.*\\)\\]$"
-                          line)
-            (when pattern
-              (setq all-props
-                    `(,@all-props (,pattern . ,props)))
-              (setq props nil))
-            (setq pattern (match-string 1 line)))
-
-           ((string-match-p "=\\|:"
-                            line)
-            ;; NOTE: Using match-string does not work as expected
-            (let* (
-                   (idx (string-match "=\\|:"
-                                      line))
-                   (key (downcase (editorconfig-core-handle--string-trim 
(substring line
-                                                                               
     0
-                                                                               
     idx))))
-                   (value (editorconfig-core-handle--string-trim (substring 
line
-                                                                            
(1+ idx))))
-                   )
-              (when (and (< (length key) 51)
-                         (< (length value) 256))
-                (if pattern
+            ((string-equal "" line)
+              nil)
+
+            ((string-match "^\\[\\(.*\\)\\]$"
+               line)
+              (when pattern
+                (setq all-props
+                  `(,@all-props (,pattern . ,props)))
+                (setq props nil))
+              (setq pattern (match-string 1 line)))
+
+            ((string-match-p "=\\|:"
+               line)
+              ;; NOTE: Using match-string does not work as expected
+              (let* (
+                      (idx (string-match "=\\|:"
+                             line))
+                      (key (downcase (editorconfig-core-handle--string-trim 
(substring line
+                                                                              0
+                                                                              
idx))))
+                      (value (editorconfig-core-handle--string-trim (substring 
line
+                                                                      (1+ 
idx))))
+                      )
+                (when (and (< (length key) 51)
+                        (< (length value) 256))
+                  (if pattern
                     (when (< (length pattern) 4097)
                       (setq props
-                            `(,@props (,key . ,value))))
-                  (setq top-props
-                        `(,@top-props (,key . ,value)))))))
-           )
+                        `(,@props (,key . ,value))))
+                    (setq top-props
+                      `(,@top-props (,key . ,value)))))))
+            )
           (forward-line 1))
         (when pattern
           (setq all-props
-                `(,@all-props (,pattern . ,props))))
+            `(,@all-props (,pattern . ,props))))
         (cons top-props
-              all-props)))))
+          all-props)))))
 
 (provide 'editorconfig-core-handle)
 
diff --git a/editorconfig-core.el b/editorconfig-core.el
index 5dee261f4a..a1766e139e 100644
--- a/editorconfig-core.el
+++ b/editorconfig-core.el
@@ -94,12 +94,12 @@ then the result will be
   (let ((result ()))
     (dolist (e alist)
       (let ((pair (assoc (car e)
-                         result)))
+                    result)))
         (if pair
-            (setcdr pair
-                    (cdr e))
+          (setcdr pair
+            (cdr e))
           (setq result
-                `(,@result ,e)))))
+            `(,@result ,e)))))
     result))
 
 (defun editorconfig-core--get-handles (dir confname &optional result)
@@ -111,17 +111,17 @@ The list may contains nil when no file was found for 
directories.
 RESULT is used internally and normally should not be used."
   (setq dir (expand-file-name dir))
   (let ((handle (editorconfig-core-handle (concat (file-name-as-directory dir)
-                                                  confname)))
-        (parent (file-name-directory (directory-file-name dir))))
+                                            confname)))
+         (parent (file-name-directory (directory-file-name dir))))
     (if (or (string= parent
-                     dir)
-            (and handle
-                 (editorconfig-core-handle-root-p handle)))
-        (cons handle result)
+              dir)
+          (and handle
+            (editorconfig-core-handle-root-p handle)))
+      (cons handle result)
       (editorconfig-core--get-handles parent
-                                      confname
-                                      (cons handle
-                                            result)))))
+        confname
+        (cons handle
+          result)))))
 
 
 ;;;###autoload
@@ -134,52 +134,52 @@ If need to specify config format version, give 
CONFVERSION.
 This functions returns alist of properties.  Each element will look like
 '(KEY . VALUE) ."
   (setq file (expand-file-name (or file
-                                   buffer-file-name
-                                   (error "FILE is not given and 
`buffer-file-name' is nil"))))
+                                 buffer-file-name
+                                 (error "FILE is not given and 
`buffer-file-name' is nil"))))
   (setq confname (or confname
-                     ".editorconfig"))
+                   ".editorconfig"))
   (setq confversion (or confversion
-                        "0.12.0"))
+                      "0.12.0"))
   (let ((result (editorconfig-core--remove-duplicate
-                 (apply 'append
-                        (mapcar (lambda (handle)
-                                  (apply 'append
-                                         
(editorconfig-core-handle-get-properties handle
-                                                                               
   file)))
-                                (editorconfig-core--get-handles 
(file-name-directory file)
-                                                                confname))))))
+                  (apply 'append
+                    (mapcar (lambda (handle)
+                              (apply 'append
+                                (editorconfig-core-handle-get-properties handle
+                                  file)))
+                      (editorconfig-core--get-handles (file-name-directory 
file)
+                        confname))))))
     (dolist (key '("end_of_line" "indent_style" "indent_size"
-                   "insert_final_newline" "trim_trailing_whitespace" 
"charset"))
+                    "insert_final_newline" "trim_trailing_whitespace" 
"charset"))
       (let ((pair (assoc key
-                         result)))
+                    result)))
         (when pair
           (setcdr pair
-                  (downcase (cdr pair))))))
+            (downcase (cdr pair))))))
 
     ;; Add indent_size property
     (let ((p-indent-size (assoc "indent_size" result))
-          (p-indent-style (assoc "indent_style" result)))
+           (p-indent-style (assoc "indent_style" result)))
       (when (and (not p-indent-size)
-                 (string= (cdr p-indent-style) "tab")
-                 ;; If VERSION < 0.9.0, indent_size should have no default 
value
-                 (version<= "0.9.0"
-                            confversion))
+              (string= (cdr p-indent-style) "tab")
+              ;; If VERSION < 0.9.0, indent_size should have no default value
+              (version<= "0.9.0"
+                confversion))
         (setq result
-              `(,@result ("indent_size" . "tab")))))
+          `(,@result ("indent_size" . "tab")))))
     ;; Add tab_width property
     (let ((p-indent-size (assoc "indent_size" result))
-          (p-tab-width (assoc "tab_width" result)))
+           (p-tab-width (assoc "tab_width" result)))
       (when (and p-indent-size
-                 (not p-tab-width)
-                 (not (string= (cdr p-indent-size) "tab")))
+              (not p-tab-width)
+              (not (string= (cdr p-indent-size) "tab")))
         (setq result
-              `(,@result ("tab_width" . ,(cdr p-indent-size))))))
+          `(,@result ("tab_width" . ,(cdr p-indent-size))))))
     ;; Update indent-size property
     (let ((p-indent-size (assoc "indent_size" result))
-          (p-tab-width (assoc "tab_width" result)))
+           (p-tab-width (assoc "tab_width" result)))
       (when (and p-indent-size
-                 p-tab-width
-                 (string= (cdr p-indent-size) "tab"))
+              p-tab-width
+              (string= (cdr p-indent-size) "tab"))
         (setcdr p-indent-size (cdr p-tab-width))))
 
     result))
@@ -194,13 +194,13 @@ If need to specify config format version, give 
CONFVERSION.
 This function is almost same as `editorconfig-core-get-properties', but returns
 hash object instead."
   (let ((result (editorconfig-core-get-properties file
-                                                  confname
-                                                  confversion))
-        (hash (make-hash-table :test 'equal)))
+                  confname
+                  confversion))
+         (hash (make-hash-table :test 'equal)))
     (dolist (prop result)
       (puthash (intern (car prop))
-               (cdr prop)
-               hash))
+        (cdr prop)
+        hash))
     hash))
 
 (provide 'editorconfig-core)
diff --git a/editorconfig-fnmatch.el b/editorconfig-fnmatch.el
index 4096eaf158..625edac67b 100644
--- a/editorconfig-fnmatch.el
+++ b/editorconfig-fnmatch.el
@@ -80,7 +80,7 @@
     ;; START arg does not work as expected in this case
     (while (string-match regexp string)
       (setq num (1+ num)
-            string (substring string (match-end 0))))
+        string (substring string (match-end 0))))
     num))
 
 ;;;###autoload
@@ -129,11 +129,11 @@ be used:
 
 Translation result will be cached, so same translation will not be done twice."
   (let ((cached (gethash pattern
-                         editorconfig-fnmatch--cache-hash)))
+                  editorconfig-fnmatch--cache-hash)))
     (or cached
-        (puthash pattern
-                 (editorconfig-fnmatch--do-translate pattern)
-                 editorconfig-fnmatch--cache-hash))))
+      (puthash pattern
+        (editorconfig-fnmatch--do-translate pattern)
+        editorconfig-fnmatch--cache-hash))))
 
 
 (defun editorconfig-fnmatch--do-translate (pattern &optional nested)
@@ -144,163 +144,163 @@ Set NESTED to t when this function is called from 
itself.
 This function is called from `editorconfig-fnmatch-translate', when no cached
 translation is found for PATTERN."
   (let ((index 0)
-        (length (length pattern))
-        (brace-level 0)
-        (in-brackets nil)
-        ;; List of strings of resulting regexp
-        (result ())
-        (is-escaped nil)
-        (matching-braces (= (editorconfig-fnmatch--match-num
-                             editorconfig-fnmatch--left-brace-regexp
-                             pattern)
+         (length (length pattern))
+         (brace-level 0)
+         (in-brackets nil)
+         ;; List of strings of resulting regexp
+         (result ())
+         (is-escaped nil)
+         (matching-braces (= (editorconfig-fnmatch--match-num
+                               editorconfig-fnmatch--left-brace-regexp
+                               pattern)
                             (editorconfig-fnmatch--match-num
-                             editorconfig-fnmatch--right-brace-regexp
-                             pattern)))
-        (numeric-groups ())
+                              editorconfig-fnmatch--right-brace-regexp
+                              pattern)))
+         (numeric-groups ())
 
-        current-char
-        pos
-        has-slash
-        has-comma
-        num-range)
+         current-char
+         pos
+         has-slash
+         has-comma
+         num-range)
 
     (while (< index length)
       (if (and (not is-escaped)
-               (string-match "[^]\\*?[{},/\\-]+"
-               ;;(string-match "[^]\\*?[{},/\\-]+" "?.a")
-                             pattern
-                             index)
-               (eq index (match-beginning 0)))
-          (setq result `(,@result ,(regexp-quote (match-string 0 pattern)))
-                index (match-end 0)
-                is-escaped nil)
+            (string-match "[^]\\*?[{},/\\-]+"
+              ;;(string-match "[^]\\*?[{},/\\-]+" "?.a")
+              pattern
+              index)
+            (eq index (match-beginning 0)))
+        (setq result `(,@result ,(regexp-quote (match-string 0 pattern)))
+          index (match-end 0)
+          is-escaped nil)
 
         (setq current-char (aref pattern index)
-              index (1+ index))
+          index (1+ index))
 
         (cl-case current-char
           (?*
-           (setq pos index)
-           (if (and (< pos length)
-                    (= (aref pattern pos) ?*))
-               (setq result `(,@result ".*"))
-             (setq result `(,@result "[^/]*"))))
+            (setq pos index)
+            (if (and (< pos length)
+                  (= (aref pattern pos) ?*))
+              (setq result `(,@result ".*"))
+              (setq result `(,@result "[^/]*"))))
 
           (??
-           (setq result `(,@result ".")))
+            (setq result `(,@result ".")))
 
           (?\[
-           (if in-brackets
-               (setq result `(,@result "\\["))
-             (setq pos index
-                   has-slash nil)
-             (while (and (< pos length)
-                         (not (= (aref pattern pos) ?\]))
-                         (not has-slash))
-               (if (and (= (aref pattern pos) ?/)
-                        (not (= (aref pattern (- pos 1)) ?\\)))
-                   (setq has-slash t)
-                 (setq pos (1+ pos))))
-             (if has-slash
-                 (setq result `(,@result ,(concat "\\["
-                                                  (substring pattern
-                                                             index
-                                                             (1+ pos))
-                                                  "\\]"))
-                       index (+ pos 2))
-               (if (and (< index length)
-                        (memq (aref pattern index)
-                              '(?! ?^)))
-                   (setq index (1+ index)
-                         result `(,@result "[^"))
-                 (setq result `(,@result "[")))
-               (setq in-brackets t))))
+            (if in-brackets
+              (setq result `(,@result "\\["))
+              (setq pos index
+                has-slash nil)
+              (while (and (< pos length)
+                       (not (= (aref pattern pos) ?\]))
+                       (not has-slash))
+                (if (and (= (aref pattern pos) ?/)
+                      (not (= (aref pattern (- pos 1)) ?\\)))
+                  (setq has-slash t)
+                  (setq pos (1+ pos))))
+              (if has-slash
+                (setq result `(,@result ,(concat "\\["
+                                           (substring pattern
+                                             index
+                                             (1+ pos))
+                                           "\\]"))
+                  index (+ pos 2))
+                (if (and (< index length)
+                      (memq (aref pattern index)
+                        '(?! ?^)))
+                  (setq index (1+ index)
+                    result `(,@result "[^"))
+                  (setq result `(,@result "[")))
+                (setq in-brackets t))))
 
           (?-
-           (if in-brackets
-               (setq result `(,@result "-"))
-             (setq result `(,@result "\\-"))))
+            (if in-brackets
+              (setq result `(,@result "-"))
+              (setq result `(,@result "\\-"))))
 
           (?\]
-           (setq result `(,@result "]")
-                 in-brackets nil))
+            (setq result `(,@result "]")
+              in-brackets nil))
 
           (?{
-           (setq pos index
-                 has-comma nil)
-           (while (and (or (and (< pos length)
-                                (not (= (aref pattern pos)
-                                        ?})))
-                           is-escaped)
-                       (not has-comma))
-             (if (and (eq (aref pattern pos)
-                          ?,)
-                      (not is-escaped))
-                 (setq has-comma t)
-               (setq is-escaped (and (eq (aref pattern pos)
-                                         ?\\)
-                                     (not is-escaped))
-                     pos (1+ pos))))
-           (if (and (not has-comma)
-                    (< pos length))
-               (let ((pattern-sub (substring pattern index pos)))
-                 (setq num-range (string-match 
editorconfig-fnmatch--numeric-range-regexp
-                                               pattern-sub))
-                 (if num-range
-                     (setq numeric-groups `(,@numeric-groups ,(mapcar 
'string-to-number
-                                                                      (list 
(match-string 1
-                                                                               
           pattern-sub)
-                                                                            
(match-string 2
-                                                                               
           pattern-sub))))
-                           result `(,@result "\\([+-]?[0-9]+\\)"))
-                   (let ((inner (editorconfig-fnmatch--do-translate 
pattern-sub t)))
-                     (setq result `(,@result ,(format "{%s}"
-                                                      (car inner)))
-                           numeric-groups `(,@numeric-groups ,@(nth 1 
inner)))))
-                 (setq index (1+ pos)))
-             (if matching-braces
-                 (setq result `(,@result "\\(?:")
-                       brace-level (1+ brace-level))
-               (setq result `(,@result "{")))))
+            (setq pos index
+              has-comma nil)
+            (while (and (or (and (< pos length)
+                              (not (= (aref pattern pos)
+                                     ?})))
+                          is-escaped)
+                     (not has-comma))
+              (if (and (eq (aref pattern pos)
+                         ?,)
+                    (not is-escaped))
+                (setq has-comma t)
+                (setq is-escaped (and (eq (aref pattern pos)
+                                        ?\\)
+                                   (not is-escaped))
+                  pos (1+ pos))))
+            (if (and (not has-comma)
+                  (< pos length))
+              (let ((pattern-sub (substring pattern index pos)))
+                (setq num-range (string-match 
editorconfig-fnmatch--numeric-range-regexp
+                                  pattern-sub))
+                (if num-range
+                  (setq numeric-groups `(,@numeric-groups ,(mapcar 
'string-to-number
+                                                             (list 
(match-string 1
+                                                                     
pattern-sub)
+                                                               (match-string 2
+                                                                 
pattern-sub))))
+                    result `(,@result "\\([+-]?[0-9]+\\)"))
+                  (let ((inner (editorconfig-fnmatch--do-translate pattern-sub 
t)))
+                    (setq result `(,@result ,(format "{%s}"
+                                               (car inner)))
+                      numeric-groups `(,@numeric-groups ,@(nth 1 inner)))))
+                (setq index (1+ pos)))
+              (if matching-braces
+                (setq result `(,@result "\\(?:")
+                  brace-level (1+ brace-level))
+                (setq result `(,@result "{")))))
 
           (?,
-           (if (and (> brace-level 0)
-                    (not is-escaped))
-               (setq result `(,@result "\\|"))
-             (setq result `(,@result "\\,"))))
+            (if (and (> brace-level 0)
+                  (not is-escaped))
+              (setq result `(,@result "\\|"))
+              (setq result `(,@result "\\,"))))
 
           (?}
-           (if (and (> brace-level 0)
-                    (not is-escaped))
-               (setq result `(,@result "\\)")
-                     brace-level (- brace-level 1))
-             (setq result `(,@result "}"))))
+            (if (and (> brace-level 0)
+                  (not is-escaped))
+              (setq result `(,@result "\\)")
+                brace-level (- brace-level 1))
+              (setq result `(,@result "}"))))
 
           (?/
-           (if (and (<= (+ index 3)
-                        (length pattern))
-                    (string= (substring pattern index (+ index 3))
-                             "**/"))
-               (setq result `(,@result "\\(?:/\\|/.*/\\)")
-                     index (+ index 3))
-             (setq result `(,@result "/"))))
+            (if (and (<= (+ index 3)
+                       (length pattern))
+                  (string= (substring pattern index (+ index 3))
+                    "**/"))
+              (setq result `(,@result "\\(?:/\\|/.*/\\)")
+                index (+ index 3))
+              (setq result `(,@result "/"))))
 
           (t
-           (unless (= current-char
+            (unless (= current-char
                       ?\\)
-             (setq result `(,@result ,(regexp-quote (char-to-string 
current-char)))))))
+              (setq result `(,@result ,(regexp-quote (char-to-string 
current-char)))))))
 
         (if (= current-char ?\\)
-            (progn (when is-escaped
-                     (setq result `(,@result "\\\\")))
-                   (setq is-escaped (not is-escaped)))
+          (progn (when is-escaped
+                   (setq result `(,@result "\\\\")))
+            (setq is-escaped (not is-escaped)))
           (setq is-escaped nil))))
     (unless nested
       (setq result `("^" ,@result "\\'")))
     (list (mapconcat 'identity
-                     result
-                     "")
-          numeric-groups)))
+            result
+            "")
+      numeric-groups)))
 
 (provide 'editorconfig-fnmatch)
 
diff --git a/ert-tests/editorconfig-core-handle.el 
b/ert-tests/editorconfig-core-handle.el
index 4f251d3889..6cef0349d4 100644
--- a/ert-tests/editorconfig-core-handle.el
+++ b/ert-tests/editorconfig-core-handle.el
@@ -3,48 +3,48 @@
 (ert-deftest editorconfig-core-handle ()
   ;; handle.ini
   (let* ((fixtures (concat default-directory
-                           "ert-tests/fixtures/"))
-         (conf (concat fixtures
-                       "handle.ini"))
-         (handle (editorconfig-core-handle conf)))
+                     "ert-tests/fixtures/"))
+          (conf (concat 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
-                                                                    "b.js"))
-                   '((("key2" . "value2")))))
+                     (concat fixtures
+                       "b.js"))
+              '((("key2" . "value2")))))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
-                                                                    "a.js"))
-                   '((("key1" . "value1")) (("key2" . "value2"))))))
+                     (concat fixtures
+                       "a.js"))
+              '((("key1" . "value1")) (("key2" . "value2"))))))
   ;; Test twice for checking cache
   (let* ((fixtures (concat default-directory
-                           "ert-tests/fixtures/"))
-         (conf (concat fixtures
-                       "handle.ini"))
-         (handle (editorconfig-core-handle conf)))
+                     "ert-tests/fixtures/"))
+          (conf (concat 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
-                                                                    "b.js"))
-                   '((("key2" . "value2")))))
+                     (concat fixtures
+                       "b.js"))
+              '((("key2" . "value2")))))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
-                                                                    "a.js"))
-                   '((("key1" . "value1")) (("key2" . "value2"))))))
+                     (concat fixtures
+                       "a.js"))
+              '((("key1" . "value1")) (("key2" . "value2"))))))
 
   ;; handle2.ini
   (let* ((fixtures (concat default-directory
-                           "ert-tests/fixtures/"))
-         (conf (concat fixtures
-                       "handle2.ini"))
-         (handle (editorconfig-core-handle conf)))
+                     "ert-tests/fixtures/"))
+          (conf (concat 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
-                                                                    "b.js"))
-                   nil))
+                     (concat fixtures
+                       "b.js"))
+              nil))
     (should (equal (editorconfig-core-handle-get-properties handle
-                                                            (concat fixtures
-                                                                    "a.js"))
-                   '((("key" . "value"))))))
+                     (concat fixtures
+                       "a.js"))
+              '((("key" . "value"))))))
   )
diff --git a/ert-tests/editorconfig-core.el b/ert-tests/editorconfig-core.el
index 5dceda9789..f70b1c83e5 100644
--- a/ert-tests/editorconfig-core.el
+++ b/ert-tests/editorconfig-core.el
@@ -2,23 +2,23 @@
 
 (ert-deftest editorconfig-core--remove-duplicate ()
   (should (equal (editorconfig-core--remove-duplicate '(("a" . 1) ("b" . 2) 
("c" . 3) ("b" . 4)))
-                 '(("a" . 1) ("b" . 4) ("c" . 3))))
+            '(("a" . 1) ("b" . 4) ("c" . 3))))
   (should (equal (editorconfig-core--remove-duplicate '(("a" . 1) ("b" . 2) 
("c" . 3)))
-                 '(("a" . 1) ("b" . 2) ("c" . 3))))
+            '(("a" . 1) ("b" . 2) ("c" . 3))))
   (should (equal (editorconfig-core--remove-duplicate nil)
-                 nil))
+            nil))
   )
 
 
 (ert-deftest editorconfig-core--get-handles ()
   (let* ((fixtures (concat default-directory
-                          "/ert-tests/fixtures/"))
-         (dir (concat fixtures
-                      "dir1"))
-         (confname "parent.ini")
-         (handles (editorconfig-core--get-handles dir
-                                                 confname)))
+                     "/ert-tests/fixtures/"))
+          (dir (concat fixtures
+                 "dir1"))
+          (confname "parent.ini")
+          (handles (editorconfig-core--get-handles dir
+                     confname)))
     (should (= 2
-               (length handles)))
+              (length handles)))
     (should (editorconfig-core-handle-p (car handles)))
     (should (editorconfig-core-handle-p (cadr handles)))))
diff --git a/ert-tests/editorconfig-fnmatch.el 
b/ert-tests/editorconfig-fnmatch.el
index 41421589ee..da923e3fcf 100644
--- a/ert-tests/editorconfig-fnmatch.el
+++ b/ert-tests/editorconfig-fnmatch.el
@@ -3,111 +3,111 @@
 
 (ert-deftest test-editorconfig-fnmatch-p ()
   (let ((cases-t
-         '(("a.js" "a.js")
-           ("/dir/a.js" "/dir/a.js")
-
-           ("a.js" "*.js")
-           ("a.js" "**.js")
-           ("/dir/a.js" "/dir/*.js")
-           ("/dir/a.js" "/dir/*")
-
-           ("/dir/sub/a.js" "**.js")
-           ("/dir/sub/a.py" "/dir/**.py")
-
-           ("a.js" "?.js")
-           ("abc.js" "a?c.js")
-           ("/dir/a.js" "/dir/?.js")
-
-           ("a.js" "[abc].js")
-           ("b.js" "[abc].js")
-           ("ab.js" "[abc]b.js")
-           ("/dir/a.js" "/dir/[abc].js")
-           ("ab[e/]cd.i" "ab[e/]cd.i")
-           ("a.js" "[a-c].js")
-           ("1.js" "[1-3].js")
-           ("a.js" "[a-c1-3].js")
-           ("1.js" "[a-c1-3].js")
-
-           ("d.js" "[^abc].js")
-           ("db.js" "[^abc]b.js")
-           ("/dir/d.js" "/dir/[^abc].js")
-           ("d.js" "[^a-c].js")
-
-           ("a.js" "a.{py,js}")
-           ("a.py" "a.{py,js}")
-           ("/dir/a.py" "/dir/a.{py,js}")
-           ("/dir/a.py" "/dir/a.{py,js}")
-           ("a.js" "*.{py,js}")
-           ("a.py" "*.{py,js}")
-           ("/dir/a.js" "/dir/*.{py,js}")
-           ("/dir/a.py" "/dir/*.{py,js}")
-           ("/dir/sub/a.py" "**.{py,js}")
-           ("/dir/sub/a.py" "/dir/**.{py,js}")
-           ("{single}.b" "{single}.b")
-           ("{.f" "{.f")
-           ("}.f" "}.f")
-
-           ("a.js" "{a,[0-9]}.js")
-           ("1.js" "{a,[0-9]}.js")
-           ("-3.py" "{-3..3}.{js,py}")
-
-           ("1.js" "{0..3}.js")
-           ("1.js" "{0..+3}.js")
-           ("-1.js" "{-3..3}.js")
-           ("-1.js" "{-3..3}.js")
-
-           ("test3" 
"{test3,test0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 [...]
-           ))
-        (cases-nil
-         '(("a.js" "b.js")
-
-           ("a.js" "*.py")
-           ("/dir/a.js" "/dir/*.py")
-           ("/dir/sub/a.js" "/dir/*.js")
-
-           ("/dir/a.js" "/sub/**.js")
-           ("/dir/sub/a.js" "/sub/**.js")
-
-           ("ab.js" "?.js")
-           ("ab.js" "?a.js")
-           ("/dir/ab.js" "/dir/?.js")
-           ("/dir/ab.js" "/dir/?a.js")
-
-           ("d.js" "[abc].js")
-           ("db.js" "[abc]b.js")
-           ("/dir/d.js" "/dir/[abc].js")
-           ("d.js" "[a-c].js")
-           ("4.js" "[1-3].js")
-           ("d.js" "[a-c1-3].js")
-           ("4.js" "[a-c1-3].js")
-
-           ("a.js" "[^abc].js")
-           ("ab.js" "[^abc]b.js")
-           ("/dir/a.js" "/dir/[^abc].js")
-           ("a.js" "[^a-c].js")
-           ("a.js" "[^a-c1-3].js")
-           ("1.js" "[^a-c1-3].js")
-
-           ("a.el" "a.{py,js}")
-           ("a.el" "*.{py,js}")
-           ("/dir/a.el" "/dir/a.{py,js}")
-           ("/dir/a.el" "/dir/*.{py,js}")
-           ("/dir/a.el" "**.{py,js}")
-
-           ("1.js" "{3..6}.js")
-           ("-1.js" "{0..3}.js")
-           ("-1.js" "{3..-3}.js")
-           )))
+          '(("a.js" "a.js")
+             ("/dir/a.js" "/dir/a.js")
+
+             ("a.js" "*.js")
+             ("a.js" "**.js")
+             ("/dir/a.js" "/dir/*.js")
+             ("/dir/a.js" "/dir/*")
+
+             ("/dir/sub/a.js" "**.js")
+             ("/dir/sub/a.py" "/dir/**.py")
+
+             ("a.js" "?.js")
+             ("abc.js" "a?c.js")
+             ("/dir/a.js" "/dir/?.js")
+
+             ("a.js" "[abc].js")
+             ("b.js" "[abc].js")
+             ("ab.js" "[abc]b.js")
+             ("/dir/a.js" "/dir/[abc].js")
+             ("ab[e/]cd.i" "ab[e/]cd.i")
+             ("a.js" "[a-c].js")
+             ("1.js" "[1-3].js")
+             ("a.js" "[a-c1-3].js")
+             ("1.js" "[a-c1-3].js")
+
+             ("d.js" "[^abc].js")
+             ("db.js" "[^abc]b.js")
+             ("/dir/d.js" "/dir/[^abc].js")
+             ("d.js" "[^a-c].js")
+
+             ("a.js" "a.{py,js}")
+             ("a.py" "a.{py,js}")
+             ("/dir/a.py" "/dir/a.{py,js}")
+             ("/dir/a.py" "/dir/a.{py,js}")
+             ("a.js" "*.{py,js}")
+             ("a.py" "*.{py,js}")
+             ("/dir/a.js" "/dir/*.{py,js}")
+             ("/dir/a.py" "/dir/*.{py,js}")
+             ("/dir/sub/a.py" "**.{py,js}")
+             ("/dir/sub/a.py" "/dir/**.{py,js}")
+             ("{single}.b" "{single}.b")
+             ("{.f" "{.f")
+             ("}.f" "}.f")
+
+             ("a.js" "{a,[0-9]}.js")
+             ("1.js" "{a,[0-9]}.js")
+             ("-3.py" "{-3..3}.{js,py}")
+
+             ("1.js" "{0..3}.js")
+             ("1.js" "{0..+3}.js")
+             ("-1.js" "{-3..3}.js")
+             ("-1.js" "{-3..3}.js")
+
+             ("test3" 
"{test3,test00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 [...]
+             ))
+         (cases-nil
+           '(("a.js" "b.js")
+
+              ("a.js" "*.py")
+              ("/dir/a.js" "/dir/*.py")
+              ("/dir/sub/a.js" "/dir/*.js")
+
+              ("/dir/a.js" "/sub/**.js")
+              ("/dir/sub/a.js" "/sub/**.js")
+
+              ("ab.js" "?.js")
+              ("ab.js" "?a.js")
+              ("/dir/ab.js" "/dir/?.js")
+              ("/dir/ab.js" "/dir/?a.js")
+
+              ("d.js" "[abc].js")
+              ("db.js" "[abc]b.js")
+              ("/dir/d.js" "/dir/[abc].js")
+              ("d.js" "[a-c].js")
+              ("4.js" "[1-3].js")
+              ("d.js" "[a-c1-3].js")
+              ("4.js" "[a-c1-3].js")
+
+              ("a.js" "[^abc].js")
+              ("ab.js" "[^abc]b.js")
+              ("/dir/a.js" "/dir/[^abc].js")
+              ("a.js" "[^a-c].js")
+              ("a.js" "[^a-c1-3].js")
+              ("1.js" "[^a-c1-3].js")
+
+              ("a.el" "a.{py,js}")
+              ("a.el" "*.{py,js}")
+              ("/dir/a.el" "/dir/a.{py,js}")
+              ("/dir/a.el" "/dir/*.{py,js}")
+              ("/dir/a.el" "**.{py,js}")
+
+              ("1.js" "{3..6}.js")
+              ("-1.js" "{0..3}.js")
+              ("-1.js" "{3..-3}.js")
+              )))
     (dolist (args cases-t)
       (message "-> t: %S"
-               `(editorconfig-fnmatch-p ,@args))
+        `(editorconfig-fnmatch-p ,@args))
       (message "   Elapsed: %S"
-               (car (benchmark-run 3 (should (apply 'editorconfig-fnmatch-p
-                                                    args))))))
+        (car (benchmark-run 3 (should (apply 'editorconfig-fnmatch-p
+                                        args))))))
     (dolist (args cases-nil)
       (message "-> nil: %S"
-               `(editorconfig-fnmatch-p ,@args))
+        `(editorconfig-fnmatch-p ,@args))
       (message "   Elapsed: %S"
-               (car (benchmark-run 3 (should-not (apply 'editorconfig-fnmatch-p
-                                                        args)))))))
+        (car (benchmark-run 3 (should-not (apply 'editorconfig-fnmatch-p
+                                            args)))))))
   )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]