[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)
- [nongnu] scratch/editorconfig-cc d02b7027ae 132/351: Add plugin-tests submodule, (continued)
- [nongnu] scratch/editorconfig-cc d02b7027ae 132/351: Add plugin-tests submodule, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc a09b197c76 156/351: Add two test cases for fnmatch, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc d5c50cb9d7 102/351: Update README: add information about customize-variable., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc c48f549c3a 152/351: Fix typo, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 0b314fcbea 135/351: Update README for some variables, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 90fba8ee80 164/351: Add doc/.gitignore, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 7ab129a73b 096/351: Add a comment for contributors, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 508e854392 107/351: Trivial commentary fix, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 49421bc1a4 123/351: Add one space to editorconfig-mode lighter text, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc f0abc53ff0 157/351: Fix fnmatch for new cases, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc e867da296c 124/351: Reindent using Emacs-lisp style.,
Stefan Monnier <=
- [nongnu] scratch/editorconfig-cc d8742edc38 168/351: Fix make doc command, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc ccfd1910f4 171/351: Remove unused variable, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc efffe74bbf 166/351: Remove doc/.gitignore, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 706ac40ec2 193/351: Make `fixtures' a constant (#176), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 4b3784445a 180/351: Add trim-trailing-ws tests, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc b6d0bb7757 201/351: Do not call major-mode when already enabled (#178), Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 642ff1b62f 215/351: Use ws-butler when enabled and available., Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 9fdc9cc689 218/351: Add variable editorconfig-trim-whitespaces-mode, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc 96123213ed 229/351: Add support for Emacs24.5, Stefan Monnier, 2024/06/13
- [nongnu] scratch/editorconfig-cc de83e09632 243/351: Update docstring, Stefan Monnier, 2024/06/13