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

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

[nongnu] scratch/editorconfig-cc e867da296c 124/351: Reindent using Emac


From: Stefan Monnier
Subject: [nongnu] scratch/editorconfig-cc e867da296c 124/351: Reindent using Emacs-lisp style.
Date: Thu, 13 Jun 2024 18:38:46 -0400 (EDT)

branch: scratch/editorconfig-cc
commit e867da296c78f7c9ba39680e1cef2c9dc25fc940
Author: Hong Xu <hong@topbug.net>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Reindent using Emacs-lisp style.
---
 editorconfig.el | 194 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 97 insertions(+), 97 deletions(-)

diff --git a/editorconfig.el b/editorconfig.el
index 3157251762..f4ad969615 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -40,8 +40,8 @@
 ;;; Code:
 
 (declare-function editorconfig-core-get-properties-hash
-  "editorconfig-core"
-  nil)
+                  "editorconfig-core"
+                  nil)
 
 (defgroup editorconfig nil
   "EditorConfig Emacs Plugin.
@@ -104,52 +104,52 @@ property emacs_linum to decide whether to show line 
numbers on the left
 (defcustom editorconfig-indentation-alist
   ;; For contributors: Sort modes in alphabetical order, please :)
   '((awk-mode c-basic-offset)
-     (c++-mode c-basic-offset)
-     (c-mode c-basic-offset)
-     (cmake-mode cmake-tab-width)
-     (coffee-mode coffee-tab-width)
-     (cperl-mode cperl-indent-level)
-     (css-mode css-indent-offset)
-     (emacs-lisp-mode lisp-indent-offset)
-     (erlang-mode erlang-indent-level)
-     (ess-mode ess-indent-offset)
-     (groovy-mode c-basic-offset)
-     (haskell-mode haskell-indent-spaces
-       haskell-indent-offset
-       shm-indent-spaces)
-     (idl-mode c-basic-offset)
-     (java-mode c-basic-offset)
-     (js-mode js-indent-level)
-     (js2-mode js2-basic-offset)
-     (js3-mode js3-indent-level)
-     (json-mode js-indent-level)
-     (latex-mode . editorconfig-set-indentation/latex-mode)
-     (lisp-mode lisp-indent-offset)
-     (livescript-mode livescript-tab-width)
-     (matlab-mode matlab-indent-level)
-     (mustache-mode mustache-basic-offset)
-     (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
-     (objc-mode c-basic-offset)
-     (octave-mode octave-block-offset)
-     (perl-mode perl-indent-level)
-     (pike-mode c-basic-offset)
-     (ps-mode ps-mode-tab)
-     (puppet-mode puppet-indent-level)
-     (python-mode . editorconfig-set-indentation/python-mode)
-     (ruby-mode ruby-indent-level)
-     (scala-mode scala-indent:step)
-     (scss-mode css-indent-offset)
-     (sgml-mode sgml-basic-offset)
-     (sh-mode sh-basic-offset sh-indentation)
-     (tcl-mode tcl-indent-level
-       tcl-continued-indent-level)
-     (web-mode (web-mode-indent-style . (lambda (size) 2))
-       web-mode-markup-indent-offset
-       web-mode-css-indent-offset
-       web-mode-code-indent-offset
-       web-mode-script-padding
-       web-mode-style-padding)
-     (yaml-mode yaml-indent-offset))
+    (c++-mode c-basic-offset)
+    (c-mode c-basic-offset)
+    (cmake-mode cmake-tab-width)
+    (coffee-mode coffee-tab-width)
+    (cperl-mode cperl-indent-level)
+    (css-mode css-indent-offset)
+    (emacs-lisp-mode lisp-indent-offset)
+    (erlang-mode erlang-indent-level)
+    (ess-mode ess-indent-offset)
+    (groovy-mode c-basic-offset)
+    (haskell-mode haskell-indent-spaces
+                  haskell-indent-offset
+                  shm-indent-spaces)
+    (idl-mode c-basic-offset)
+    (java-mode c-basic-offset)
+    (js-mode js-indent-level)
+    (js2-mode js2-basic-offset)
+    (js3-mode js3-indent-level)
+    (json-mode js-indent-level)
+    (latex-mode . editorconfig-set-indentation/latex-mode)
+    (lisp-mode lisp-indent-offset)
+    (livescript-mode livescript-tab-width)
+    (matlab-mode matlab-indent-level)
+    (mustache-mode mustache-basic-offset)
+    (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
+    (objc-mode c-basic-offset)
+    (octave-mode octave-block-offset)
+    (perl-mode perl-indent-level)
+    (pike-mode c-basic-offset)
+    (ps-mode ps-mode-tab)
+    (puppet-mode puppet-indent-level)
+    (python-mode . editorconfig-set-indentation/python-mode)
+    (ruby-mode ruby-indent-level)
+    (scala-mode scala-indent:step)
+    (scss-mode css-indent-offset)
+    (sgml-mode sgml-basic-offset)
+    (sh-mode sh-basic-offset sh-indentation)
+    (tcl-mode tcl-indent-level
+              tcl-continued-indent-level)
+    (web-mode (web-mode-indent-style . (lambda (size) 2))
+              web-mode-markup-indent-offset
+              web-mode-css-indent-offset
+              web-mode-code-indent-offset
+              web-mode-script-padding
+              web-mode-style-padding)
+    (yaml-mode yaml-indent-offset))
   "Alist of indentation setting methods by modes.
 
 Each element looks like (MODE . FUNCTION) or (MODE . INDENT-SPEC-LIST).
@@ -204,7 +204,7 @@ yet.")
 (defun editorconfig-string-integer-p (string)
   "Return non-nil if STRING represents integer."
   (and (stringp string)
-    (string-match-p "\\`[0-9]+\\'" string)))
+       (string-match-p "\\`[0-9]+\\'" string)))
 
 (defun editorconfig-set-indentation/python-mode (size)
   "Set `python-mode' indent size to SIZE."
@@ -217,36 +217,36 @@ yet.")
 (defun editorconfig-set-indentation (style &optional size tab_width)
   "Set indentation type from STYLE, SIZE and TAB_WIDTH."
   (if (editorconfig-string-integer-p size)
-    (setq size (string-to-number size))
+      (setq size (string-to-number size))
     (when (not (equal size "tab")) (setq size nil)))
   )
 
 (defun editorconfig-set-coding-system (end-of-line charset)
   "Set buffer coding system by END-OF-LINE and CHARSET."
   (let ((eol (cond
-               ((equal end-of-line "lf") 'undecided-unix)
-               ((equal end-of-line "cr") 'undecided-mac)
-               ((equal end-of-line "crlf") 'undecided-dos)
-               (t 'undecided)))
-         (cs (cond
-               ((equal charset "latin1") 'iso-latin-1)
-               ((equal charset "utf-8") 'utf-8)
-               ((equal charset "utf-8-bom") 'utf-8-with-signature)
-               ((equal charset "utf-16be") 'utf-16be)
-               ((equal charset "utf-16le") 'utf-16le)
-               (t 'undecided))))
+              ((equal end-of-line "lf") 'undecided-unix)
+              ((equal end-of-line "cr") 'undecided-mac)
+              ((equal end-of-line "crlf") 'undecided-dos)
+              (t 'undecided)))
+        (cs (cond
+             ((equal charset "latin1") 'iso-latin-1)
+             ((equal charset "utf-8") 'utf-8)
+             ((equal charset "utf-8-bom") 'utf-8-with-signature)
+             ((equal charset "utf-16be") 'utf-16be)
+             ((equal charset "utf-16le") 'utf-16le)
+             (t 'undecided))))
     (unless (and (eq eol 'undecided)
-              (eq cs 'undecided))
+                 (eq cs 'undecided))
       (set-buffer-file-coding-system (merge-coding-systems
-                                       cs
-                                       eol)
-        nil t))))
+                                      cs
+                                      eol)
+                                     nil t))))
 
 
 (defun editorconfig-set-line-length (length)
   "Set the max line length (fill-column) to LENGTH."
   (when (and (editorconfig-string-integer-p length)
-          (> (string-to-number length) 0))
+             (> (string-to-number length) 0))
     (set-fill-column (string-to-number length))))
 
 (defun editorconfig-call-editorconfig-exec ()
@@ -258,7 +258,7 @@ yet.")
 (defun editorconfig-get-properties-from-exec ()
   "Get EditorConfig properties of current buffer by calling 
`editorconfig-exec-path'."
   (if (executable-find editorconfig-exec-path)
-    (editorconfig-parse-properties (editorconfig-call-editorconfig-exec))
+      (editorconfig-parse-properties (editorconfig-call-editorconfig-exec))
     (error "Unable to find editorconfig executable")))
 
 (defun editorconfig-get-properties ()
@@ -268,7 +268,7 @@ It calls `editorconfig-get-properties-from-exec' if
 `editorconfig-exec-path` is found, otherwise
 `editorconfig-core-get-properties-hash'."
   (if (executable-find editorconfig-exec-path)
-    (editorconfig-get-propergies-from-exec)
+      (editorconfig-get-propergies-from-exec)
     (require 'editorconfig-core)
     (editorconfig-core-get-properties-hash)))
 
@@ -276,17 +276,17 @@ It calls `editorconfig-get-properties-from-exec' if
   "Display EditorConfig properties extracted for current buffer."
   (interactive)
   (if editorconfig-properties-hash
-    (let (
-           (buf (get-buffer-create "*EditorConfig Properties*"))
-           (file buffer-file-name)
-           (props editorconfig-properties-hash))
-      (with-current-buffer buf
-        (erase-buffer)
-        (insert (format "# EditorConfig for %s\n" file))
-        (maphash (lambda (k v)
-                   (insert (format "%S = %s\n" k v)))
-          props))
-      (display-buffer buf))
+      (let (
+            (buf (get-buffer-create "*EditorConfig Properties*"))
+            (file buffer-file-name)
+            (props editorconfig-properties-hash))
+        (with-current-buffer buf
+          (erase-buffer)
+          (insert (format "# EditorConfig for %s\n" file))
+          (maphash (lambda (k v)
+                     (insert (format "%S = %s\n" k v)))
+                   props))
+        (display-buffer buf))
     (message "Properties are not applied to current buffer yet.")
     nil))
 
@@ -298,30 +298,30 @@ properties."
   (interactive)
   (when buffer-file-name
     (condition-case err
-      (progn
-        (unless (functionp editorconfig-get-properties-function)
-          (error "Invalid editorconfig-get-properties-function value"))
-        (let ((props (funcall editorconfig-get-properties-function)))
-          (progn
-            (setq editorconfig-properties-hash props)
-            (editorconfig-set-coding-system
-              (gethash 'end_of_line props)
-              (gethash 'charset props))
-            (editorconfig-set-line-length (gethash 'max_line_length props))
-            (run-hook-with-args 'editorconfig-custom-hooks props))))
+        (progn
+          (unless (functionp editorconfig-get-properties-function)
+            (error "Invalid editorconfig-get-properties-function value"))
+          (let ((props (funcall editorconfig-get-properties-function)))
+            (progn
+              (setq editorconfig-properties-hash props)
+              (editorconfig-set-coding-system
+               (gethash 'end_of_line props)
+               (gethash 'charset props))
+              (editorconfig-set-line-length (gethash 'max_line_length props))
+              (run-hook-with-args 'editorconfig-custom-hooks props))))
       (error
-        (display-warning 'editorconfig
-          (concat (error-message-string err)
-            ".  Styles will not be applied.")
-          :error)))))
+       (display-warning 'editorconfig
+                        (concat (error-message-string err)
+                                ".  Styles will not be applied.")
+                        :error)))))
 
 (defun editorconfig-mode-apply ()
   "Apply EditorConfig properties for current buffer.
 This function do the job only when the major mode is not listed in
 `editorconfig-exclude-modes'."
   (when (and major-mode
-          (not (memq major-mode
-                 editorconfig-exclude-modes)))
+             (not (memq major-mode
+                        editorconfig-exclude-modes)))
     (editorconfig-apply)))
 
 
@@ -335,7 +335,7 @@ visiting files or changing major modes if the major mode is 
not listed in
   :lighter " EditorConfig"
   (dolist (hook '(after-change-major-mode-hook))
     (if editorconfig-mode
-      (add-hook hook 'editorconfig-mode-apply)
+        (add-hook hook 'editorconfig-mode-apply)
       (remove-hook hook 'editorconfig-mode-apply))))
 
 (provide 'editorconfig)



reply via email to

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