+++ /dev/null
-This is the file .../info/dir, which contains the
-topmost node of the Info hierarchy, called (dir)Top.
-The first time you invoke Info you start off looking at this node.
-\1f
-File: dir, Node: Top This is the top of the INFO tree
-
- This (the Directory node) gives a menu of major topics.
- Typing "q" exits, "H" lists all Info commands, "d" returns here,
- "h" gives a primer for first-timers,
- "mEmacs<Return>" visits the Emacs manual, etc.
-
- In Emacs, you can click mouse button 2 on a menu item or cross reference
- to select it.
-
-* Menu:
-
-Emacs
-* EditorConfig: (editorconfig). EditorConfig Emacs Plugin.
+++ /dev/null
-;;; editorconfig-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
-\f
-;;;### (autoloads nil "editorconfig" "editorconfig.el" (23994 46775
-;;;;;; 385859 186000))
-;;; Generated autoloads from editorconfig.el
-
-(autoload 'editorconfig-apply "editorconfig" "\
-Get and apply EditorConfig properties to current buffer.
-This function ignores `editorconfig-exclude-modes' and
-`editorconfig-exclude-regexps', and always applies available properties.
-
-\(fn)" t nil)
-
-(defvar editorconfig-mode nil "\
-Non-nil if Editorconfig mode is enabled.
-See the `editorconfig-mode' command
-for a description of this minor mode.
-Setting this variable directly does not take effect;
-either customize it (see the info node `Easy Customization')
-or call the function `editorconfig-mode'.")
-
-(custom-autoload 'editorconfig-mode "editorconfig" nil)
-
-(autoload 'editorconfig-mode "editorconfig" "\
-Toggle EditorConfig feature.
-
-To disable EditorConfig in some buffers, modify
-`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'.
-
-\(fn &optional ARG)" t nil)
-
-(autoload 'editorconfig-find-current-editorconfig "editorconfig" "\
-Find the closest .editorconfig file for current file.
-
-\(fn)" t nil)
-
-(autoload 'editorconfig-display-current-properties "editorconfig" "\
-Display EditorConfig properties extracted for current buffer.
-
-\(fn)" t nil)
-
-(defalias 'describe-editorconfig-properties 'editorconfig-display-current-properties)
-
-(autoload 'editorconfig-format-buffer "editorconfig" "\
-Format buffer according to .editorconfig indent_style and indent_width.
-
-\(fn)" t nil)
-
-(autoload 'editorconfig-version "editorconfig" "\
-Get EditorConfig version as string.
-
-If called interactively or if SHOW-VERSION is non-nil, show the
-version in the echo area and the messages buffer.
-
-\(fn &optional SHOW-VERSION)" t nil)
-
-;;;***
-\f
-;;;### (autoloads nil "editorconfig-conf-mode" "editorconfig-conf-mode.el"
-;;;;;; (23994 46775 387237 773000))
-;;; Generated autoloads from editorconfig-conf-mode.el
-
-(autoload 'editorconfig-conf-mode "editorconfig-conf-mode" "\
-Major mode for editing .editorconfig files.
-
-\(fn)" t nil)
-
-(add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode))
-
-;;;***
-\f
-;;;### (autoloads nil "editorconfig-core" "editorconfig-core.el"
-;;;;;; (23994 46775 389628 618000))
-;;; Generated autoloads from editorconfig-core.el
-
-(autoload 'editorconfig-core-get-nearest-editorconfig "editorconfig-core" "\
-Return path to .editorconfig file that is closest to DIRECTORY.
-
-\(fn DIRECTORY)" nil nil)
-
-(autoload 'editorconfig-core-get-properties "editorconfig-core" "\
-Get EditorConfig properties for FILE.
-If FILE is not given, use currently visiting file.
-Give CONFNAME for basename of config file other than .editorconfig.
-If need to specify config format version, give CONFVERSION.
-
-This functions returns alist of properties. Each element will look like
-'(KEY . VALUE) .
-
-\(fn &optional FILE CONFNAME CONFVERSION)" nil nil)
-
-(autoload 'editorconfig-core-get-properties-hash "editorconfig-core" "\
-Get EditorConfig properties for FILE.
-If FILE is not given, use currently visiting file.
-Give CONFNAME for basename of config file other than .editorconfig.
-If need to specify config format version, give CONFVERSION.
-
-This function is almost same as `editorconfig-core-get-properties', but returns
-hash object instead.
-
-\(fn &optional FILE CONFNAME CONFVERSION)" nil nil)
-
-;;;***
-\f
-;;;### (autoloads nil "editorconfig-fnmatch" "editorconfig-fnmatch.el"
-;;;;;; (23994 46775 382026 449000))
-;;; Generated autoloads from editorconfig-fnmatch.el
-
-(autoload 'editorconfig-fnmatch-p "editorconfig-fnmatch" "\
-Test whether STRING match PATTERN.
-
-Matching ignores case if `case-fold-search' is non-nil.
-
-PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can
-be used:
-
-* Matches any string of characters, except path separators (/)
-** Matches any string of characters
-? Matches any single character
-\[name] Matches any single character in name
-\[^name] Matches any single character not in name
-{s1,s2,s3} Matches any of the strings given (separated by commas)
-{min..max} Matches any number between min and max
-
-\(fn STRING PATTERN)" nil nil)
-
-;;;***
-\f
-;;;### (autoloads nil nil ("editorconfig-core-handle.el" "editorconfig-pkg.el")
-;;;;;; (23994 46775 391699 251000))
-
-;;;***
-\f
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; End:
-;;; editorconfig-autoloads.el ends here
+++ /dev/null
-;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*-
-
-;; Copyright (C) 2011-2019 EditorConfig Team
-
-;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
-
-;; See
-;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
-;; or the CONTRIBUTORS file for the list of contributors.
-
-;; This file is part of EditorConfig Emacs Plugin.
-
-;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at your
-;; option) any later version.
-
-;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU General Public License along with
-;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Major mode for editing .editorconfig files.
-
-;;; Code:
-
-(require 'conf-mode)
-
-(defvar editorconfig-conf-mode-syntax-table
- (let ((table (make-syntax-table conf-unix-mode-syntax-table)))
- (modify-syntax-entry ?\; "<" table)
- table)
- "Syntax table in use in `editorconfig-conf-mode' buffers.")
-
-;;;###autoload
-(define-derived-mode editorconfig-conf-mode conf-unix-mode "Conf[EditorConfig]"
- "Major mode for editing .editorconfig files."
- (set-variable 'indent-line-function 'indent-relative)
- (let ((key-property-list
- '("charset"
- "end_of_line"
- "file_type_emacs"
- "file_type_ext"
- "indent_size"
- "indent_style"
- "insert_final_newline"
- "max_line_length"
- "root"
- "tab_width"
- "trim_trailing_whitespace"))
- (key-value-list
- '("unset"
- "true"
- "false"
- "lf"
- "cr"
- "crlf"
- "space"
- "tab"
- "latin1"
- "utf-8"
- "utf-8-bom"
- "utf-16be"
- "utf-16le"))
- (font-lock-value
- '(("^[ \t]*\\[\\(.+?\\)\\]" 1 font-lock-type-face)
- ("^[ \t]*\\(.+?\\)[ \t]*[=:]" 1 font-lock-variable-name-face))))
-
- ;; Highlight all key values
- (dolist (key-value key-value-list)
- (push
- `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value)
- 1 font-lock-constant-face)
- font-lock-value
- ))
- ;; Highlight all key properties
- (dolist (key-property key-property-list)
- (push
- `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property)
- 1 font-lock-builtin-face)
- font-lock-value
- ))
-
- (conf-mode-initialize "#" font-lock-value)))
-
-;;;###autoload
-(add-to-list 'auto-mode-alist
- '("\\.editorconfig\\'" . editorconfig-conf-mode))
-
-(provide 'editorconfig-conf-mode)
-
-;;; editorconfig-conf-mode.el ends here
+++ /dev/null
-;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*-
-
-;; Copyright (C) 2011-2019 EditorConfig Team
-
-;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
-
-;; See
-;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
-;; or the CONTRIBUTORS file for the list of contributors.
-
-;; This file is part of EditorConfig Emacs Plugin.
-
-;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at your
-;; option) any later version.
-
-;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU General Public License along with
-;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Handle structures for EditorConfig config file. This library is used
-;; internally from editorconfig-core.el .
-
-;;; Code:
-
-(require 'cl-lib)
-
-(require 'editorconfig-fnmatch)
-
-(defvar editorconfig-core-handle--cache-hash
- (make-hash-table :test 'equal)
- "Hash of EditorConfig filename and its `editorconfig-core-handle' instance.")
-
-(cl-defstruct editorconfig-core-handle-section
- "Structure representing one section in a .editorconfig file.
-
-Slots:
-
-`name'
- String of section name (glob string).
-
-`props'
- Alist of properties: (KEY . VALUE)."
- (name nil)
- (props nil))
-
-(defun editorconfig-core-handle-section-get-properties (section file dir)
- "Return properties alist when SECTION name match FILE.
-
-DIR should be the directory where .editorconfig file which has SECTION lives.
-IF not match, return nil."
- (when (editorconfig-core-handle--fnmatch-p
- file
- (editorconfig-core-handle-section-name section)
- dir)
- (editorconfig-core-handle-section-props section)))
-
-(cl-defstruct editorconfig-core-handle
- "Structure representing an .editorconfig file.
-
-Slots:
-`top-props'
- Alist of top propetties like ((\"root\" . \"true\"))
-
-`sections'
- List of `editorconfig-core-hadnle-section' strucure object.
-
-`mtime'
- Last modified time of .editorconfig file.
-
-`path'
- Absolute path to .editorconfig file.'
-"
- (top-props nil)
- (sections nil)
- (mtime nil)
- (path nil))
-
-
-(defun editorconfig-core-handle (conf)
- "Return EditorConfig handle for CONF, which should be a file path.
-
-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))))
- (if (and cached
- (equal (editorconfig-core-handle-mtime cached)
- mtime))
- cached
- (let ((parsed (editorconfig-core-handle--parse-file conf)))
- (puthash conf
- (make-editorconfig-core-handle :top-props (plist-get parsed :top-props)
- :sections (plist-get parsed :sections)
- :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.
-
-If HANDLE is nil return nil."
- (when handle
- (string-equal "true"
- (downcase (or (cdr (assoc "root"
- (editorconfig-core-handle-top-props handle)))
- "")))))
-
-(defun editorconfig-core-handle-get-properties (handle file)
- "Return list of alist of properties from HANDLE for FILE.
-The list returned will be ordered by the lines they appear.
-
-If HANDLE is nil return nil."
- (when handle
- (let ((dir (file-name-directory (editorconfig-core-handle-path handle))))
- (cl-loop for section in (editorconfig-core-handle-sections handle)
- for props = (editorconfig-core-handle-section-get-properties section
- file
- dir)
- when props collect (copy-alist props)))))
-(make-obsolete 'editorconfig-core-handle-get-properties
- 'editorconfig-core-handle-get-properties-hash
- "0.8.0")
-
-
-(defun editorconfig-core-handle-get-properties-hash (handle file)
- "Return hash of properties from HANDLE for FILE.
-
-If HANDLE is nil return nil."
- (when handle
- (let ((hash (make-hash-table))
- (dir (file-name-directory (editorconfig-core-handle-path
- handle))))
- (dolist (section (editorconfig-core-handle-sections handle))
- (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir)
- do (puthash (intern key) value hash)))
- hash)))
-
-(defun editorconfig-core-handle--fnmatch-p (name pattern dir)
- "Return non-nil if NAME match PATTERN.
-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)))
- (editorconfig-fnmatch-p name
- (concat "**/"
- pattern))))
-
-(defsubst editorconfig-core-handle--string-trim (str)
- "Remove leading and trailing whitespaces from STR."
- (replace-regexp-in-string "[[:space:]]+\\'"
- ""
- (replace-regexp-in-string "\\`[[:space:]]+"
- ""
- str)))
-
-(defun editorconfig-core-handle--parse-file (conf)
- "Parse EditorConfig file CONF.
-
-This function returns cons of its top properties alist and
-alist of patterns and its properties alist.
-The list returned will be ordered by the lines they appear.
-
-If CONF is not found return nil."
- (when (file-readable-p conf)
- (with-temp-buffer
- ;; NOTE: Use this instead of insert-file-contents-literally to enable
- ;; code conversion
- (insert-file-contents conf)
- (goto-char (point-min))
- (let ((point-max (point-max))
- (sections ())
- (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 ())
-
- ;; Current line num
- (current-line-number 1)
- )
- (while (not (eq (point) point-max))
- (setq line
- (buffer-substring-no-properties (point-at-bol)
- (point-at-eol)))
- (setq line
- (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$"
- ""
- (editorconfig-core-handle--string-trim line)))
-
- (cond
- ((string-equal "" line)
- nil)
-
- ;; Start of section
- ((string-match "^\\[\\(.*\\)\\]$"
- line)
- (when pattern
- (setq sections
- `(,@sections ,(make-editorconfig-core-handle-section
- :name pattern
- :props props)))
- (setq pattern nil)
- (setq props nil))
- (setq pattern (match-string 1 line)))
-
- (t
- (let ((idx (string-match "=\\|:"
- line)))
- (unless idx
- (error "Error while reading config file: %s:%d:\n %s\n"
- conf
- current-line-number
- line))
- (let (
- (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))))))))
- )
- (setq current-line-number
- (1+ current-line-number))
- (goto-char (point-min))
- (forward-line (1- current-line-number))
- )
- (when pattern
- (setq sections
- `(,@sections ,(make-editorconfig-core-handle-section
- :name pattern
- :props props))))
- (list :top-props top-props
- :sections sections)))))
-
-(provide 'editorconfig-core-handle)
-
-;;; editorconfig-core-handle.el ends here
+++ /dev/null
-;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*-
-
-;; Copyright (C) 2011-2019 EditorConfig Team
-
-;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
-
-;; See
-;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
-;; or the CONTRIBUTORS file for the list of contributors.
-
-;; This file is part of EditorConfig Emacs Plugin.
-
-;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at your
-;; option) any later version.
-
-;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU General Public License along with
-;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This library is one implementation of EditorConfig Core, which parses
-;; .editorconfig files and returns properties for given files.
-;; This can be used in place of, for example, editorconfig-core-c.
-
-
-;; Use from EditorConfig Emacs Plugin
-
-;; Emacs plugin (v0.5 or later) can utilize this implementation.
-;; By default, the plugin first search for any EditorConfig executable,
-;; and fallback to this library if not found.
-;; If you always want to use this library, add following lines to your init.el:
-
-;; (setq editorconfig-get-properties-function
-;; 'editorconfig-core-get-properties-hash)
-
-
-;; Functions
-
-;; editorconfig-core-get-properties (&optional file confname confversion)
-
-;; Get EditorConfig properties for FILE.
-
-;; If FILE is not given, use currently visiting file.
-;; Give CONFNAME for basename of config file other than .editorconfig.
-;; If need to specify config format version, give CONFVERSION.
-
-;; This functions returns alist of properties. Each element will look like
-;; (KEY . VALUE) .
-
-
-;; editorconfig-core-get-properties-hash (&optional file confname confversion)
-
-;; Get EditorConfig properties for FILE.
-
-;; This function is almost same as `editorconfig-core-get-properties', but
-;; returns hash object instead.
-
-;;; Code:
-
-(require 'cl-lib)
-
-(require 'editorconfig-core-handle)
-
-
-(defun editorconfig-core--get-handles (dir confname &optional result)
- "Get list of EditorConfig handlers for DIR from CONFNAME.
-
-In the resulting list, the handle for root config file comes first, and the
-nearest comes last.
-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))))
- (if (or (string= parent
- dir)
- (and handle
- (editorconfig-core-handle-root-p handle)))
- (cl-remove-if-not 'identity
- (cons handle result))
- (editorconfig-core--get-handles parent
- confname
- (cons handle
- result)))))
-
-;;;###autoload
-(defun editorconfig-core-get-nearest-editorconfig (directory)
- "Return path to .editorconfig file that is closest to DIRECTORY."
- (let ((handle (car (last (editorconfig-core--get-handles directory
- ".editorconfig")))))
- (when handle
- (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.
-Give CONFNAME for basename of config file other than .editorconfig.
-If need to specify config format version, give CONFVERSION.
-
-This functions returns alist of properties. Each element will look like
-'(KEY . VALUE) ."
- (let ((hash (editorconfig-core-get-properties-hash file confname confversion))
- (result nil))
- (maphash (lambda (key value)
- (add-to-list 'result
- (cons (symbol-name key)
- value)))
- hash)
- result))
-
-(defun editorconfig-core--hash-merge (into update)
- "Merge to hashes INTO and UPDATE.
-
-This is a destructive function, hash INTO will be modified.
-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.
-Give CONFNAME for basename of config file other than .editorconfig.
-If need to specify config format version, give CONFVERSION.
-
-This function is almost same as `editorconfig-core-get-properties', but returns
-hash object instead."
- (setq file
- (expand-file-name (or file
- buffer-file-name
- (error "FILE is not given and `buffer-file-name' is nil"))))
- (setq confname (or confname
- ".editorconfig"))
- (setq confversion (or confversion
- "0.12.0"))
- (let ((result (make-hash-table)))
- (dolist (handle (editorconfig-core--get-handles (file-name-directory file)
- confname))
- (editorconfig-core--hash-merge result
- (editorconfig-core-handle-get-properties-hash handle
- file)))
-
- ;; Downcase known boolean values
- (dolist (key '(
- end_of_line indent_style indent_size insert_final_newline
- trim_trailing_whitespace charset
- ))
- (let ((val (gethash key
- result)))
- (when val
- (puthash key
- (downcase val)
- result))))
-
- ;; Add indent_size property
- (let ((v-indent-size (gethash 'indent_size result))
- (v-indent-style (gethash 'indent_style result)))
- (when (and (not v-indent-size)
- (string= v-indent-style "tab")
- ;; If VERSION < 0.9.0, indent_size should have no default value
- (version<= "0.9.0"
- confversion))
- (puthash 'indent_size
- "tab"
- result)))
- ;; Add tab_width property
- (let ((v-indent-size (gethash 'indent_size result))
- (v-tab-width (gethash 'tab_width result)))
- (when (and v-indent-size
- (not v-tab-width)
- (not (string= v-indent-size "tab")))
- (puthash 'tab_width
- v-indent-size
- result)))
- ;; Update indent-size property
- (let ((v-indent-size (gethash 'indent_size result))
- (v-tab-width (gethash 'tab_width result)))
- (when (and v-indent-size
- v-tab-width
- (string= v-indent-size "tab"))
- (puthash 'indent_size
- v-tab-width
- result)))
-
- result))
-
-(provide 'editorconfig-core)
-
-;;; editorconfig-core.el ends here
+++ /dev/null
-;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*-
-
-;; Copyright (C) 2011-2019 EditorConfig Team
-
-;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
-
-;; See
-;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
-;; or the CONTRIBUTORS file for the list of contributors.
-
-;; This file is part of EditorConfig Emacs Plugin.
-
-;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at your
-;; option) any later version.
-
-;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU General Public License along with
-;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; editorconfig-fnmatch.el provides a fnmatch implementation with a few
-;; extensions.
-;; The main usage of this library is glob pattern matching for EditorConfig, but
-;; it can also act solely.
-
-;; editorconfig-fnmatch-p (name pattern)
-
-;; Test whether NAME match PATTERN.
-
-;; PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings
-;; can be used:
-
-;; * Matches any string of characters, except path separators (/)
-;; ** Matches any string of characters
-;; ? Matches any single character
-;; [name] Matches any single character in name
-;; [^name] Matches any single character not in name
-;; {s1,s2,s3} Matches any of the strings given (separated by commas)
-;; {min..max} Matches any number between min and max
-
-
-;; This library is a port from editorconfig-core-py library.
-;; https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/fnmatch.py
-
-;;; Code:
-
-(require 'cl-lib)
-
-(defvar editorconfig-fnmatch--cache-hashtable
- nil
- "Cache of shell pattern and its translation.")
-;; Clear cache on file reload
-(setq editorconfig-fnmatch--cache-hashtable
- (make-hash-table :test 'equal))
-
-
-(defconst editorconfig-fnmatch--left-brace-regexp
- "\\(^\\|[^\\]\\){"
- "Regular expression for left brace ({).")
-
-(defconst editorconfig-fnmatch--right-brace-regexp
- "\\(^\\|[^\\]\\)}"
- "Regular expression for right brace (}).")
-
-
-(defconst editorconfig-fnmatch--numeric-range-regexp
- "\\([+-]?[0-9]+\\)\\.\\.\\([+-]?[0-9]+\\)"
- "Regular expression for numaric range (like {-3..+3}).")
-
-(defun editorconfig-fnmatch--match-num (regexp string)
- "Return how many times REGEXP is found in STRING."
- (let ((num 0))
- ;; 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))))
- num))
-
-;;;###autoload
-(defun editorconfig-fnmatch-p (string pattern)
- "Test whether STRING match PATTERN.
-
-Matching ignores case if `case-fold-search' is non-nil.
-
-PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can
-be used:
-
-* Matches any string of characters, except path separators (/)
-** Matches any string of characters
-? Matches any single character
-[name] Matches any single character in name
-[^name] Matches any single character not in name
-{s1,s2,s3} Matches any of the strings given (separated by commas)
-{min..max} Matches any number between min and max"
- (string-match (editorconfig-fnmatch-translate pattern)
- string))
-
-;;(editorconfig-fnmatch-translate "{a,{-3..3}}.js")
-;;(editorconfig-fnmatch-p "1.js" "{a,{-3..3}}.js")
-
-(defun editorconfig-fnmatch-translate (pattern)
- "Translate a shell PATTERN to a regular expression.
-
-Translation result will be cached, so same translation will not be done twice."
- (let ((cached (gethash pattern
- editorconfig-fnmatch--cache-hashtable)))
- (or cached
- (puthash pattern
- (editorconfig-fnmatch--do-translate pattern)
- editorconfig-fnmatch--cache-hashtable))))
-
-
-(defun editorconfig-fnmatch--do-translate (pattern &optional nested)
- "Translate a shell PATTERN to a regular expression.
-
-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)
- (editorconfig-fnmatch--match-num
- editorconfig-fnmatch--right-brace-regexp
- pattern)))
-
- 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)
-
- (setq current-char (aref pattern 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 result `(,@result "[^/]")))
-
- (?\[
- (if in-brackets
- (setq result `(,@result "\\["))
- (if (= (aref pattern index) ?/)
- ;; Slash after an half-open bracket
- (setq result `(,@result "\\[/")
- index (+ index 1))
- (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 "\\-"))))
-
- (?\]
- (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
- (let ((number-start (string-to-number (match-string 1
- pattern-sub)))
- (number-end (string-to-number (match-string 2
- pattern-sub))))
- (setq result `(,@result ,(concat "\\(?:"
- (mapconcat 'number-to-string
- (cl-loop for i from number-start to number-end
- collect i)
- "\\|")
- "\\)"))))
- (let ((inner (editorconfig-fnmatch--do-translate pattern-sub t)))
- (setq result `(,@result ,(format "{%s}"
- 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 "\\)")
- 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 "/"))))
-
- (t
- (unless (= 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)))
- (setq is-escaped nil))))
- (unless nested
- (setq result `("^" ,@result "\\'")))
- (apply 'concat result)))
-
-(provide 'editorconfig-fnmatch)
-
-;;; editorconfig-fnmatch.el ends here
+++ /dev/null
-(define-package "editorconfig" "20191025.806" "EditorConfig Emacs Plugin"
- '((cl-lib "0.5")
- (emacs "24"))
- :authors
- '(("EditorConfig Team" . "editorconfigNOSPAMgooglegroups.com"))
- :maintainer
- '("EditorConfig Team" . "editorconfigNOSPAMgooglegroups.com")
- :url "https://github.com/editorconfig/editorconfig-emacs#readme")
-;; Local Variables:
-;; no-byte-compile: t
-;; End:
+++ /dev/null
-;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*-
-
-;; Copyright (C) 2011-2019 EditorConfig Team
-
-;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
-;; Version: 0.8.1
-;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Package-Requires: ((cl-lib "0.5") (emacs "24"))
-
-;; See
-;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
-;; or the CONTRIBUTORS file for the list of contributors.
-
-;; This file is part of EditorConfig Emacs Plugin.
-
-;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or (at your
-;; option) any later version.
-
-;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU General Public License along with
-;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; EditorConfig helps developers define and maintain consistent
-;; coding styles between different editors and IDEs.
-
-;; The EditorConfig project consists of a file format for defining
-;; coding styles and a collection of text editor plugins that enable
-;; editors to read the file format and adhere to defined styles.
-;; EditorConfig files are easily readable and they work nicely with
-;; version control systems.
-
-;;; Code:
-(require 'cl-lib)
-(eval-when-compile
- (require 'rx)
- (defvar tex-indent-basic)
- (defvar tex-indent-item)
- (defvar tex-indent-arg)
- (defvar evil-shift-width))
-
-(declare-function editorconfig-core-get-properties-hash
- "editorconfig-core"
- nil)
-
-(defgroup editorconfig nil
- "EditorConfig Emacs Plugin.
-
-EditorConfig helps developers define and maintain consistent
-coding styles between different editors and IDEs."
- :tag "EditorConfig"
- :prefix "editorconfig-"
- :group 'tools)
-
-(defcustom editorconfig-exec-path
- "editorconfig"
- "Path to EditorConfig executable.
-
-Used by `editorconfig-call-editorconfig-exec'."
- :type 'string
- :group 'editorconfig)
-(define-obsolete-variable-alias
- 'edconf-exec-path
- 'editorconfig-exec-path
- "0.5")
-
-(defcustom editorconfig-get-properties-function
- 'editorconfig-get-properties
- "A function which gets EditorConofig properties for current buffer.
-
-This function will be called with no argument and should return a
-hash object containing properties, or nil if any core program is
-not available. Keys of this hash should be symbols of properties, and values
-should be strings of their values.
-
-
-For example, if you always want to use built-in core library instead
-of any EditorConfig executable to get properties, add following to
-your init.el:
-
- (set-variable 'editorconfig-get-properties-function
- #'editorconfig-core-get-properties-hash)
-
-Possible known values are:
-
-* `editorconfig-get-properties' (default)
- * Use `editorconfig-get-properties-from-exec' when
- `editorconfig-exec-path' executable executable is found, otherwise
- use `editorconfig-core-get-properties-hash'
-* `editorconfig-get-properties-from-exec'
- * Get properties by executing EditorConfig executable
-* `editorconfig-core-get-properties-hash'
- * Always use built-in Emacs-Lisp implementation to get properties"
- :type 'function
- :group 'editorconfig)
-(define-obsolete-variable-alias
- 'edconf-get-properties-function
- 'editorconfig-get-properties-function
- "0.5")
-
-(defcustom editorconfig-mode-lighter " EditorConfig"
- "`editorconfig-mode' lighter string."
- :type 'string
- :group 'editorconfig)
-
-(defcustom editorconfig-after-apply-functions ()
- "A list of functions after loading common EditorConfig settings.
-
-Each element in this list is a hook function. This hook function
-takes one parameter, which is a property hash table. The value
-of properties can be obtained through gethash function.
-
-The hook does not have to be coding style related; you can add
-whatever functionality you want. For example, the following is
-an example to add a new property emacs_linum to decide whether to
-show line numbers on the left:
-
- (add-hook 'editorconfig-after-apply-functions
- '(lambda (props)
- (let ((show-line-num (gethash 'emacs_linum props)))
- (cond ((equal show-line-num \"true\") (linum-mode 1))
- ((equal show-line-num \"false\") (linum-mode 0))))))"
- :type 'hook
- :group 'editorconfig)
-(define-obsolete-variable-alias
- 'edconf-custom-hooks
- 'editorconfig-after-apply-functions
- "0.5")
-(define-obsolete-variable-alias
- 'editorconfig-custom-hooks
- 'editorconfig-after-apply-functions
- "0.7.14")
-
-(defcustom editorconfig-hack-properties-functions ()
- "A list of function to alter property values before applying them.
-
-These functions will be run after loading \".editorconfig\" files and before
-applying them to current buffer, so that you can alter some properties from
-\".editorconfig\" before they take effect.
-
-For example, Makefiles always use tab characters for indentation: you can
-overwrite \"indent_style\" property when current `major-mode' is a
-`makefile-mode' with following code:
-
- (add-hook 'editorconfig-hack-properties-functions
- '(lambda (props)
- (when (derived-mode-p 'makefile-mode)
- (puthash 'indent_style \"tab\" props))))"
- :type 'hook
- :group 'editorconfig)
-
-(defcustom editorconfig-indentation-alist
- ;; For contributors: Sort modes in alphabetical order
- '((apache-mode apache-indent-level)
- (awk-mode c-basic-offset)
- (bpftrace-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)
- (crystal-mode crystal-indent-level)
- (csharp-mode c-basic-offset)
- (css-mode css-indent-offset)
- (emacs-lisp-mode lisp-indent-offset)
- (enh-ruby-mode enh-ruby-indent-level)
- (erlang-mode erlang-indent-level)
- (ess-mode ess-indent-offset)
- (f90-mode f90-associate-indent
- f90-continuation-indent
- f90-critical-indent
- f90-do-indent
- f90-if-indent
- f90-program-indent
- f90-type-indent)
- (feature-mode feature-indent-offset
- feature-indent-level)
- (fsharp-mode fsharp-continuation-offset
- fsharp-indent-level
- fsharp-indent-offset)
- (groovy-mode groovy-indent-offset)
- (haskell-mode haskell-indent-spaces
- haskell-indent-offset
- haskell-indentation-layout-offset
- haskell-indentation-left-offset
- haskell-indentation-starter-offset
- haskell-indentation-where-post-offset
- haskell-indentation-where-pre-offset
- shm-indent-spaces)
- (haxor-mode haxor-tab-width)
- (idl-mode c-basic-offset)
- (jade-mode jade-tab-width)
- (java-mode c-basic-offset)
- (js-mode js-indent-level)
- (js-jsx-mode js-indent-level sgml-basic-offset)
- (js2-mode js2-basic-offset)
- (js2-jsx-mode js2-basic-offset sgml-basic-offset)
- (js3-mode js3-indent-level)
- (json-mode js-indent-level)
- (julia-mode julia-indent-offset)
- (kotlin-mode kotlin-tab-width)
- (latex-mode . editorconfig-set-indentation-latex-mode)
- (lisp-mode lisp-indent-offset)
- (livescript-mode livescript-tab-width)
- (lua-mode lua-indent-level)
- (matlab-mode matlab-indent-level)
- (mips-mode mips-tab-width)
- (mustache-mode mustache-basic-offset)
- (nasm-mode nasm-basic-offset)
- (nginx-mode nginx-indent-level)
- (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
- (objc-mode c-basic-offset)
- (octave-mode octave-block-offset)
- (perl-mode perl-indent-level)
- ;; No need to change `php-mode-coding-style' value for php-mode
- ;; since we run editorconfig later than it resets `c-basic-offset'.
- ;; See https://github.com/editorconfig/editorconfig-emacs/issues/116
- ;; for details.
- (php-mode c-basic-offset)
- (pike-mode c-basic-offset)
- (ps-mode ps-mode-tab)
- (pug-mode pug-tab-width)
- (puppet-mode puppet-indent-level)
- (python-mode . editorconfig-set-indentation-python-mode)
- (ruby-mode ruby-indent-level)
- (rust-mode rust-indent-offset)
- (rustic-mode rustic-indent-offset)
- (scala-mode scala-indent:step)
- (scss-mode css-indent-offset)
- (sgml-mode sgml-basic-offset)
- (sh-mode sh-basic-offset sh-indentation)
- (slim-mode slim-indent-offset)
- (tcl-mode tcl-indent-level
- tcl-continued-indent-level)
- (terra-mode terra-indent-level)
- (typescript-mode typescript-indent-level)
- (verilog-mode verilog-indent-level
- verilog-indent-level-behavioral
- verilog-indent-level-declaration
- verilog-indent-level-module
- verilog-cexp-indent
- verilog-case-indent)
- (web-mode (web-mode-indent-style . (lambda (size) 2))
- web-mode-attr-indent-offset
- web-mode-attr-value-indent-offset
- web-mode-code-indent-offset
- web-mode-css-indent-offset
- web-mode-markup-indent-offset
- web-mode-sql-indent-offset
- web-mode-block-padding
- 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).
-
-If FUNCTION is provided, it will be called when setting the
-indentation. The indent size will be passed.
-
-If INDENT-SPEC-LIST is provided, each element of it must have one of the
-following forms:
-
- 1. VARIABLE
- It means (VARIABLE . 1).
-
- 2. (VARIABLE . SPEC)
- Setting VARIABLE according to the type of SPEC:
-
- - Integer
- The value is (* SPEC INDENT-SIZE);
-
- - Function
- The value is (funcall SPEC INDENT-SIZE);
-
- - Any other type.
- The value is SPEC.
-
-NOTE: Only the **buffer local** value of VARIABLE will be set."
- :type '(alist :key-type symbol :value-type sexp)
- :risky t
- :group 'editorconfig)
-(define-obsolete-variable-alias
- 'edconf-indentation-alist
- 'editorconfig-indentation-alist
- "0.5")
-
-(defcustom editorconfig-exclude-modes ()
- "Modes in which `editorconfig-mode-apply' will not run."
- :type '(repeat (symbol :tag "Major Mode"))
- :group 'editorconfig)
-
-(defcustom editorconfig-exclude-regexps
- (list (eval-when-compile
- (rx string-start (or "http" "https" "ftp" "sftp" "rsync") ":")))
- "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)
-
-(defcustom editorconfig-trim-whitespaces-mode nil
- "Buffer local minor-mode to use to trim trailing whitespaces.
-
-If set, enable that mode when `trim_trailing_whitespace` is set to true.
-Otherwise, use `delete-trailing-whitespace'."
- :type 'symbol
- :group 'editorconfig)
-
-(defvar editorconfig-properties-hash nil
- "Hash object of EditorConfig properties that was enabled for current buffer.
-Set by `editorconfig-apply' and nil if that is not invoked in
-current buffer yet.")
-(make-variable-buffer-local 'editorconfig-properties-hash)
-(put 'editorconfig-properties-hash
- 'permanent-local
- t)
-
-(defvar editorconfig-lisp-use-default-indent nil
- "Selectively ignore the value of indent_sizefor Lisp files.
-Prevents `lisp-indent-offset' from being set selectively.
-
-nil - `lisp-indent-offset' is always set normally.
-t - `lisp-indent-offset' is never set normally
- (always use default indent for lisps).
-number - `lisp-indent-offset' is not set only if indent_size is
- equal to this number. For example, if this is set to 2,
- `lisp-indent-offset'will not be set only if indent_size is 2.")
-
-(defconst editorconfig-unset-value "unset"
- "String of value used to unset properties in .editorconfig .")
-
-(defun editorconfig-string-integer-p (string)
- "Return non-nil if STRING represents integer."
- (and (stringp string)
- (string-match-p "\\`[0-9]+\\'" string)))
-
-(defun editorconfig-set-indentation-python-mode (size)
- "Set `python-mode' indent size to SIZE."
- (set (make-local-variable (if (or (> emacs-major-version 24)
- (and (= emacs-major-version 24)
- (>= emacs-minor-version 3)))
- 'python-indent-offset
- 'python-indent))
- size)
- ;; For https://launchpad.net/python-mode
- (when (boundp 'py-indent-offset)
- (set (make-local-variable 'py-indent-offset) size)))
-
-(defun editorconfig-set-indentation-latex-mode (size)
- "Set `latex-mode' indent size to SIZE."
- (set (make-local-variable 'tex-indent-basic) size)
- (set (make-local-variable 'tex-indent-item) size)
- (set (make-local-variable 'tex-indent-arg) (* 2 size))
- ;; For AUCTeX
- (when (boundp 'TeX-brace-indent-level)
- (set (make-local-variable 'TeX-brace-indent-level) size))
- (when (boundp 'LaTeX-indent-level)
- (set (make-local-variable 'LaTeX-indent-level) size))
- (when (boundp 'LaTeX-item-indent)
- (set (make-local-variable 'LaTeX-item-indent) (- size))))
-
-(defun editorconfig--should-set (size symbol)
- "Determines if editorconfig should set SYMBOL using SIZE."
- (if (eq symbol 'lisp-indent-offset)
- (cond
- ((eql nil editorconfig-lisp-use-default-indent)
- t)
- ((eql t editorconfig-lisp-use-default-indent)
- nil)
- ((numberp editorconfig-lisp-use-default-indent)
- (not (eql size editorconfig-lisp-use-default-indent)))
- (t t))
- t))
-
-(defun editorconfig-set-indentation (style &optional size tab_width)
- "Set indentation type from STYLE, SIZE and TAB_WIDTH."
- (make-local-variable 'indent-tabs-mode)
- (make-local-variable 'tab-width)
- (if (editorconfig-string-integer-p size)
- (setq size (string-to-number size))
- (when (not (equal size "tab")) (setq size nil)))
- (setq tab-width (cond (tab_width (string-to-number tab_width))
- ((numberp size) size)
- (t tab-width)))
- (when (equal size "tab")
- (setq size tab-width))
- (cond ((equal style "space")
- (setq indent-tabs-mode nil))
- ((equal style "tab")
- (setq indent-tabs-mode t)))
- (when size
- (when (featurep 'evil)
- (set (make-local-variable 'evil-shift-width) size))
- (let ((parent major-mode)
- entry)
- ;; Find the closet parent mode of `major-mode' in
- ;; `editorconfig-indentation-alist'.
- (while (and (not (setq entry (assoc parent editorconfig-indentation-alist)))
- (setq parent (get parent 'derived-mode-parent))))
- (when entry
- (let ((fn-or-list (cdr entry)))
- (cond ((functionp fn-or-list) (funcall fn-or-list size))
- ((listp fn-or-list)
- (dolist (elem fn-or-list)
- (cond ((and (symbolp elem)
- (editorconfig--should-set size elem))
- (set (make-local-variable elem) size))
- ((and (consp elem)
- (editorconfig--should-set size (car elem)))
- (let ((spec (cdr elem)))
- (set (make-local-variable (car elem))
- (cond ((functionp spec) (funcall spec size))
- ((integerp spec) (* spec size))
- (t spec))))))))))))))
-
-(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-with-signature)
- ((equal charset "utf-16le") 'utf-16le-with-signature)
- (t 'undecided))))
- (unless (and (eq eol 'undecided)
- (eq cs 'undecided))
- (set-buffer-file-coding-system (merge-coding-systems
- cs
- eol)
- nil t))))
-
-(defun editorconfig-set-trailing-nl (final-newline)
- "Set up requiring final newline by FINAL-NEWLINE.
-
-This function will set `require-final-newline' and `mode-require-final-newline'
-to non-nil when FINAL-NEWLINE is true."
- (cond
- ((equal final-newline "true")
- ;; keep prefs around how/when the nl is added, if set - otherwise add on save
- (set (make-local-variable 'require-final-newline) (or require-final-newline t))
- (set (make-local-variable 'mode-require-final-newline) (or mode-require-final-newline t)))
- ((equal final-newline "false")
- ;; FIXME: Add functionality for actually REMOVING any trailing newlines here!
- ;; (rather than just making sure we don't automagically ADD a new one)
- (set (make-local-variable 'require-final-newline) nil)
- (set (make-local-variable 'mode-require-final-newline) nil))))
-
-(defun editorconfig-set-trailing-ws (trim-trailing-ws)
- "Set up trimming of trailing whitespace at end of lines by TRIM-TRAILING-WS."
- (make-local-variable 'write-file-functions) ;; just current buffer
- (when (and (equal trim-trailing-ws "true")
- (not buffer-read-only))
- ;; when true we push delete-trailing-whitespace (emacs > 21)
- ;; to write-file-functions
- (if editorconfig-trim-whitespaces-mode
- (funcall editorconfig-trim-whitespaces-mode 1)
- (add-to-list
- 'write-file-functions
- 'delete-trailing-whitespace)))
- (when (or (equal trim-trailing-ws "false")
- buffer-read-only)
- ;; when false we remove every delete-trailing-whitespace
- ;; from write-file-functions
- (when editorconfig-trim-whitespaces-mode
- (funcall editorconfig-trim-whitespaces-mode 0))
- (setq
- write-file-functions
- (delete
- 'delete-trailing-whitespace
- write-file-functions))))
-
-(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))
- (setq fill-column (string-to-number length))))
-
-(defvar editorconfig-file-type-emacs-whitelist
- (append (mapcar 'car
- editorconfig-indentation-alist)
- '(conf-mode))
- "List of known `major-mode' that can be used for file_type_emacs value.")
-
-;; Emacs<26 does not have provided-mode-derived-p
-(defun editorconfig--provided-mode-derived-p (mode &rest modes)
- "Non-nil if MODE is derived from one of MODES.
-Uses the `derived-mode-parent' property of the symbol to trace backwards.
-If you just want to check `major-mode', use `derived-mode-p'."
- (if (fboundp 'provided-mode-derived-p)
- (apply 'provided-mode-derived-p mode modes)
- (while (and (not (memq mode modes))
- (setq mode (get mode 'derived-mode-parent))))
- mode))
-
-
-(defun editorconfig-set-major-mode-from-name (filetype)
- "Set buffer `major-mode' by FILETYPE.
-
-FILETYPE should be s string like `\"ini\"`, if not nil or empty string."
- (let ((mode (and filetype
- (not (string= filetype
- ""))
- (intern (concat filetype
- "-mode")))))
- (when mode
- (if (fboundp mode)
- (if (apply 'editorconfig--provided-mode-derived-p mode
- editorconfig-file-type-emacs-whitelist)
- (editorconfig-apply-major-mode-safely mode)
- (display-warning :error (format "Major-mode `%S' is not listed in `%S'"
- mode
- 'editorconfig-file-type-emacs-whitelist)))
- (display-warning :error (format "Major-mode `%S' not found"
- mode))
- nil))))
-
-(defvar editorconfig--apply-major-mode-currently nil
- "Used internally.")
-(make-variable-buffer-local 'editorconfig--apply-major-mode-currently)
-(put 'editorconfig--apply-major-mode-currently
- 'permanent-local
- t)
-
-(defun editorconfig-apply-major-mode-safely (mode)
- "Set `major-mode' to MODE.
-Normally `editorconfig-apply' will be hooked so that it runs when changing
-`major-mode', so there is a possibility that MODE is called infinitely if
-MODE is called naively from inside of `editorconfig-apply'.
-This funcion will avoid such cases and set `major-mode' safely.
-
-Just checking current `major-mode' value is not enough, because it can be
-different from MODE value (for example, `conf-mode' will set `major-mode' to
-`conf-unix-mode' or another conf mode)."
- (cl-assert mode)
- (when (and (not (eq mode
- editorconfig--apply-major-mode-currently))
- (not (eq mode
- major-mode))
- (not (derived-mode-p mode)))
- (unwind-protect
- (progn
- (setq editorconfig--apply-major-mode-currently
- mode)
- (funcall mode))
- (setq editorconfig--apply-major-mode-currently
- nil))))
-
-(defun editorconfig--find-mode-from-ext (ext &optional filename)
- "Get suitable `major-mode' from EXT and FILENAME.
-If FILENAME is omitted filename of current buffer is used."
- (cl-assert ext)
- (cl-assert (not (string= ext "")))
- (let* ((name (concat (or filename
- buffer-file-name)
- "."
- ext)))
- (assoc-default name
- auto-mode-alist
- 'string-match)))
-
-(defun editorconfig-set-major-mode-from-ext (ext)
- "Set buffer `major-mode' by EXT.
-
-EXT should be a string like `\"ini\"`, if not nil or empty string."
- (cl-assert buffer-file-name)
- (when (and ext
- (not (string= ext ""))
- (not (string= ext editorconfig-unset-value)))
-
- (let ((mode (editorconfig--find-mode-from-ext ext
- buffer-file-name)))
- (if mode
- (editorconfig-apply-major-mode-safely mode)
- (display-warning :error (format "Major-mode for `%s' not found"
- ext))
- nil))))
-
-(defun editorconfig-call-editorconfig-exec ()
- "Call EditorConfig core and return output."
- (let* ((filename (buffer-file-name))
- (filename (and filename (expand-file-name filename))))
- (if filename
- (with-temp-buffer
- (setq default-directory "/")
- (if (eq 0
- (call-process editorconfig-exec-path nil t nil filename))
- (buffer-string)
- (error (buffer-string))))
- "")))
-
-(defun editorconfig-parse-properties (props-string)
- "Create properties hash table from PROPS-STRING."
- (let (props-list properties)
- (setq props-list (split-string props-string "\n")
- properties (make-hash-table :test 'equal))
- (dolist (prop props-list properties)
- (let ((key-val (split-string prop " *= *")))
- (when (> (length key-val) 1)
- (let ((key (intern (car key-val)))
- (val (mapconcat 'identity (cdr key-val) "")))
- (puthash key val properties)))))))
-
-(defun editorconfig-get-properties-from-exec ()
- "Get EditorConfig properties of current buffer.
-
-This function uses value of `editorconfig-exec-path' to get properties."
- (if (executable-find editorconfig-exec-path)
- (editorconfig-parse-properties (editorconfig-call-editorconfig-exec))
- (error "Unable to find editorconfig executable")))
-
-(defun editorconfig-get-properties ()
- "Get EditorConfig properties of current buffer.
-
-It calls `editorconfig-get-properties-from-exec' if
-`editorconfig-exec-path' is found, otherwise
-`editorconfig-core-get-properties-hash'."
- (if (and (executable-find editorconfig-exec-path)
- (not (file-remote-p buffer-file-name)))
- (editorconfig-get-properties-from-exec)
- (require 'editorconfig-core)
- (editorconfig-core-get-properties-hash)))
-
-;;;###autoload
-(defun editorconfig-apply ()
- "Get and apply EditorConfig properties to current buffer.
-This function ignores `editorconfig-exclude-modes' and
-`editorconfig-exclude-regexps', and always applies available 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
- (condition-case err
- (run-hook-with-args 'editorconfig-hack-properties-functions props)
- (error
- (display-warning 'editorconfig-hack-properties-functions
- (concat (error-message-string err)
- ". Abort running hook.")
- :warning)))
- (setq editorconfig-properties-hash props)
- (editorconfig-set-indentation (gethash 'indent_style props)
- (gethash 'indent_size props)
- (gethash 'tab_width props))
- (editorconfig-set-coding-system
- (gethash 'end_of_line props)
- (gethash 'charset props))
- (editorconfig-set-trailing-nl (gethash 'insert_final_newline props))
- (editorconfig-set-trailing-ws (gethash 'trim_trailing_whitespace props))
- (editorconfig-set-line-length (gethash 'max_line_length props))
- (editorconfig-set-major-mode-from-name (gethash 'file_type_emacs props))
- (editorconfig-set-major-mode-from-ext (gethash 'file_type_ext props))
- (condition-case err
- (run-hook-with-args 'editorconfig-after-apply-functions props)
- (error
- (display-warning 'editorconfig-after-apply-functions
- (concat (error-message-string err)
- ". Stop running hook.")
- :warning))))))
- (error
- (display-warning 'editorconfig
- (concat (error-message-string err)
- ". Styles will not be applied.")
- :error)))))
-
-(defun editorconfig-mode-apply ()
- "Get and apply EditorConfig properties to current buffer.
-This function does nothing when the major mode is listed in
-`editorconfig-exclude-modes', or variable `buffer-file-name' matches
-any of regexps in `editorconfig-exclude-regexps'."
- (when (and major-mode
- (not (memq major-mode
- editorconfig-exclude-modes))
- buffer-file-name
- (not (cl-loop for regexp in editorconfig-exclude-regexps
- if (string-match regexp buffer-file-name) return t
- finally return nil)))
- (editorconfig-apply)))
-
-;;;###autoload
-(define-minor-mode editorconfig-mode
- "Toggle EditorConfig feature.
-
-To disable EditorConfig in some buffers, modify
-`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'."
- :global t
- :lighter editorconfig-mode-lighter
- ;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for why
- ;; not `after-change-major-mode-hook'
- (dolist (hook '(change-major-mode-after-body-hook
- read-only-mode-hook
- ;; Some modes call `kill-all-local-variables' in their init
- ;; code, which clears some values set by editorconfig.
- ;; For those modes, editorconfig-apply need to be called
- ;; explicitly through their hooks.
- rpm-spec-mode-hook
- ))
- (if editorconfig-mode
- (add-hook hook 'editorconfig-mode-apply)
- (remove-hook hook 'editorconfig-mode-apply))))
-
-
-;; Tools
-;; Some useful commands for users, not required for EditorConfig to work
-
-;;;###autoload
-(defun editorconfig-find-current-editorconfig ()
- "Find the closest .editorconfig file for current file."
- (interactive)
- (eval-and-compile (require 'editorconfig-core))
- (let ((file (editorconfig-core-get-nearest-editorconfig
- default-directory)))
- (when file
- (find-file file))))
-
-;;;###autoload
-(defun editorconfig-display-current-properties ()
- "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))
- (message "Properties are not applied to current buffer yet.")
- nil))
-;;;###autoload
-(defalias 'describe-editorconfig-properties
- 'editorconfig-display-current-properties)
-
-;;;###autoload
-(defun editorconfig-format-buffer()
- "Format buffer according to .editorconfig indent_style and indent_width."
- (interactive)
- (if (string= (gethash 'indent_style editorconfig-properties-hash) "tab")
- (tabify (point-min) (point-max)))
- (if (string= (gethash 'indent_style editorconfig-properties-hash) "space")
- (untabify (point-min) (point-max)))
- (indent-region (point-min) (point-max)))
-
-
-
-;; (defconst editorconfig--version
-;; (eval-when-compile
-;; (require 'lisp-mnt)
-;; (declare-function lm-version "lisp-mnt" nil)
-;; (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.
-
-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 (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)))
- (when show-version
- (message "EditorConfig Emacs v%s"
- version-full))
- version-full))
-
-(provide 'editorconfig)
-
-;;; editorconfig.el ends here
-
-;; Local Variables:
-;; sentence-end-double-space: t
-;; End:
+++ /dev/null
-This is editorconfig.info, produced by makeinfo version 6.5 from
-editorconfig.texi.
-
-INFO-DIR-SECTION Emacs
-START-INFO-DIR-ENTRY
-* EditorConfig: (editorconfig). EditorConfig Emacs Plugin.
-END-INFO-DIR-ENTRY
-
-\1f
-File: editorconfig.info, Node: Top, Next: Installation, Up: (dir)
-
-1 EditorConfig Emacs Plugin
-***************************
-
-This is an EditorConfig (https://editorconfig.org) plugin for Emacs
-(https://www.gnu.org/software/emacs/).
-* Menu:
-
-* Installation::
-* Supported properties::
-* Customize::
-* Testing::
-* Submitting Bugs and Feature Requests::
-* License::
-
-\1f
-File: editorconfig.info, Node: Installation, Next: Supported properties, Prev: Top, Up: Top
-
-1.1 Installation
-================
-
-Download the EditorConfig C Core
-(https://github.com/editorconfig/editorconfig-core-c) and follow the
-instructions in the README and INSTALL files to install it.
-
- This plugin also has a built-in core library implemented in
-Emacs-Lisp, and fallback to it when no core executable is found.
-
- In either case, copy '.el' files in this repository to
-'~/.emacs.d/lisp' and add the following to your '~/.emacs' file:
-
-(add-to-list 'load-path "~/.emacs.d/lisp")
-(require 'editorconfig)
-(editorconfig-mode 1)
-
- Alternatively, you can find the package available on MELPA
-(https://melpa.org/#/editorconfig) and MELPA Stable
-(https://stable.melpa.org/#/editorconfig) (The Marmalade package
-(http://marmalade-repo.org/packages/editorconfig) is deprecated).
-
- Or if you use *use-package*
-(https://www.emacswiki.org/emacs/UsePackage):
-
-(use-package editorconfig
- :ensure t
- :config
- (editorconfig-mode 1))
-
-\1f
-File: editorconfig.info, Node: Supported properties, Next: Customize, Prev: Installation, Up: Top
-
-1.2 Supported properties
-========================
-
-Current Emacs plugin coverage for EditorConfig's properties
-(https://editorconfig.org/#supported-properties):
-
- * 'indent_style'
- * 'indent_size'
- * 'tab_width'
- * 'end_of_line'
- * 'charset'
- * 'trim_trailing_whitespace'
- * 'insert_final_newline = true' is supported
- * 'insert_final_newline = false' is not enforced (as in trailing
- newlines actually being removed automagically), we just
- buffer-locally override any preferences that would auto-add them to
- files '.editorconfig' marks as trailing-newline-free
- * 'max_line_length'
- * 'file_type_ext' (Experimental)
- * 'file_type_emacs' (Experimental)
- * 'root' (only used by EditorConfig core)
-
- Not yet covered properties marked with over-strike - pull requests
-implementing missing features warmly welcomed! Typically, you will want
-to tie these to native functionality, or the configuration of existing
-packages handling the feature.
-
- As several packages have their own handling of, say, indention, we
-might not yet cover some mode you use, but we try to add the ones that
-show up on our radar. Similarly, we don't yet hook in to all different
-packages for whitespace trimming to inform them about editorconfig
-settings, but aim for better coverage of things like ws-trim
-(ftp://ftp.lysator.liu.se/pub/emacs/ws-trim.el).
-* Menu:
-
-* File Type::
-
-\1f
-File: editorconfig.info, Node: File Type, Up: Supported properties
-
-1.2.1 File Type
----------------
-
-This plugin has experimental supports for 'file_type_ext' and
-'file_type_emacs', which specify "file types" for files. As for Emacs,
-it means 'major-mode' can be set.
-
- *file_type_ext* When it is set to 'md' for 'a.txt', for example,
-'major-mode' will be decided as if the file name would be 'a.txt.md'
-(and thus 'markdown-mode' is likely to be used).
-
- *file_type_emacs* When it is set to 'markdown' for 'a.txt',
-'markdown-mode' will be enabled when opening 'a.txt'.
-
- These property are experimental and their meanings might change in
-the future updates. When both are specified, 'file_type_ext' takes
-precedence.
-
-\1f
-File: editorconfig.info, Node: Customize, Next: Testing, Prev: Supported properties, Up: Top
-
-1.3 Customize
-=============
-
-* Menu:
-
-* editorconfig-after-apply-functions::
-* editorconfig-hack-properties-functions::
-* editorconfig-indentation-alist::
-* editorconfig-exec-path::
-* editorconfig-get-properties-function::
-
-\1f
-File: editorconfig.info, Node: editorconfig-after-apply-functions, Next: editorconfig-hack-properties-functions, Up: Customize
-
-1.3.1 'editorconfig-after-apply-functions'
-------------------------------------------
-
-(Formerly 'editorconfig-custom-hooks')
-
- A list of functions after loading common EditorConfig settings, where
-you can set some custom variables or overwrite existing properties.
-
- For example, 'web-mode' has several variables for indentation offset
-size and EditorConfig sets them at once by 'indent_size'. You may want
-to stop indenting only blocks of 'web-mode': it can be achieved by
-adding following to your init.el:
-
-(add-hook 'editorconfig-after-apply-functions
- (lambda (hash) (setq web-mode-block-padding 0)))
-
- You can also define your own custom properties and enable them here.
-
-\1f
-File: editorconfig.info, Node: editorconfig-hack-properties-functions, Next: editorconfig-indentation-alist, Prev: editorconfig-after-apply-functions, Up: Customize
-
-1.3.2 'editorconfig-hack-properties-functions'
-----------------------------------------------
-
-A list of function to alter property values before applying them.
-
- These functions will be run after loading ".editorconfig" files and
-before applying them to current buffer, so that you can alter some
-properties from ".editorconfig" before they take effect.
-
- For example, Makefiles always use tab characters for indentation: you
-can overwrite "indent_style" property when current 'major-mode' is a
-'makefile-mode' with following code:
-
-(add-hook 'editorconfig-hack-properties-functions
- '(lambda (props)
- (when (derived-mode-p 'makefile-mode)
- (puthash 'indent_style "tab" props))))
-
-\1f
-File: editorconfig.info, Node: editorconfig-indentation-alist, Next: editorconfig-exec-path, Prev: editorconfig-hack-properties-functions, Up: Customize
-
-1.3.3 'editorconfig-indentation-alist'
---------------------------------------
-
-Alist of indentation setting methods by modes.
-
- For the easiest case to add a new support for a major-mode, you just
-need to add a pair of major-mode symbol and its indentation variables:
-
-(add-to-list 'editorconfig-indentation-alist
- ;; Just an example, of course EditorConfig has already included this setting!
- '(c-mode c-basic-offset))
-
- You can also modify this variable with the command M-x
-customize-variable [RET] editorconfig-indentation-alist [RET]. For a bit
-more complicated cases please take a look at the docstring of this
-variable.
-
-\1f
-File: editorconfig.info, Node: editorconfig-exec-path, Next: editorconfig-get-properties-function, Prev: editorconfig-indentation-alist, Up: Customize
-
-1.3.4 'editorconfig-exec-path'
-------------------------------
-
-String of 'editorconfig' executable name (command name or full path to
-the executable).
-
-\1f
-File: editorconfig.info, Node: editorconfig-get-properties-function, Prev: editorconfig-exec-path, Up: Customize
-
-1.3.5 'editorconfig-get-properties-function'
---------------------------------------------
-
-Function to use to get EditorConfig properties.
-
- For example, if you always want to use built-in core library instead
-of any EditorConfig executable to get properties, add following to your
-init.el:
-
-(set-variable 'editorconfig-get-properties-function
- #'editorconfig-core-get-properties-hash)
-
- Possible known values are:
-
- * 'editorconfig-get-properties' (default)
- * Use 'editorconfig-get-properties-from-exec' when
- 'editorconfig-exec-path' executable is found, otherwise use
- 'editorconfig-core-get-properties-hash'
-
- * 'editorconfig-get-properties-from-exec'
- * Get properties by executing EditorConfig executable specified
- in 'editorconfig-exec-path'
-
- * 'editorconfig-core-get-properties-hash'
- * Always use built-in Emacs-Lisp implementation to get
- properties
-
-\1f
-File: editorconfig.info, Node: Testing, Next: Submitting Bugs and Feature Requests, Prev: Customize, Up: Top
-
-1.4 Testing
-===========
-
-Make and CMake (https://cmake.org) must be installed to run the tests.
-
- To run the tests:
-
-$ make test
-
-\1f
-File: editorconfig.info, Node: Submitting Bugs and Feature Requests, Next: License, Prev: Testing, Up: Top
-
-1.5 Submitting Bugs and Feature Requests
-========================================
-
-Bugs, feature requests, and other issues should be submitted to the
-issue tracker: https://github.com/editorconfig/editorconfig-emacs/issues
-
-\1f
-File: editorconfig.info, Node: License, Prev: Submitting Bugs and Feature Requests, Up: Top
-
-1.6 License
-===========
-
-EditorConfig Emacs Plugin is free software: you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-Public License for more details.
-
- You should have received a copy of the GNU General Public License
-along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-
-\1f
-Tag Table:
-Node: Top\7f208
-Ref: #editorconfig-emacs-plugin\7f337
-Node: Installation\7f575
-Ref: #installation\7f709
-Node: Supported properties\7f1613
-Ref: #supported-properties\7f1769
-Node: File Type\7f3113
-Ref: #file-type\7f3218
-Node: Customize\7f3843
-Ref: #customize\7f3972
-Node: editorconfig-after-apply-functions\7f4167
-Ref: #editorconfig-after-apply-functions\7f4387
-Node: editorconfig-hack-properties-functions\7f4986
-Ref: #editorconfig-hack-properties-functions\7f5253
-Node: editorconfig-indentation-alist\7f5879
-Ref: #editorconfig-indentation-alist\7f6118
-Node: editorconfig-exec-path\7f6673
-Ref: #editorconfig-exec-path\7f6894
-Node: editorconfig-get-properties-function\7f6983
-Ref: #editorconfig-get-properties-function\7f7193
-Node: Testing\7f8046
-Ref: #testing\7f8187
-Node: Submitting Bugs and Feature Requests\7f8294
-Ref: #submitting-bugs-and-feature-requests\7f8491
-Node: License\7f8633
-Ref: #license\7f8756
-\1f
-End Tag Table
--- /dev/null
+This is the file .../info/dir, which contains the
+topmost node of the Info hierarchy, called (dir)Top.
+The first time you invoke Info you start off looking at this node.
+\1f
+File: dir, Node: Top This is the top of the INFO tree
+
+ This (the Directory node) gives a menu of major topics.
+ Typing "q" exits, "H" lists all Info commands, "d" returns here,
+ "h" gives a primer for first-timers,
+ "mEmacs<Return>" visits the Emacs manual, etc.
+
+ In Emacs, you can click mouse button 2 on a menu item or cross reference
+ to select it.
+
+* Menu:
+
+Emacs
+* EditorConfig: (editorconfig). EditorConfig Emacs Plugin.
--- /dev/null
+;;; editorconfig-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+ (or (file-name-directory #$) (car load-path))))
+
+\f
+;;;### (autoloads nil "editorconfig" "editorconfig.el" (0 0 0 0))
+;;; Generated autoloads from editorconfig.el
+
+(autoload 'editorconfig-apply "editorconfig" "\
+Get and apply EditorConfig properties to current buffer.
+This function ignores `editorconfig-exclude-modes' and
+`editorconfig-exclude-regexps', and always applies available properties.
+
+\(fn)" t nil)
+
+(defvar editorconfig-mode nil "\
+Non-nil if Editorconfig mode is enabled.
+See the `editorconfig-mode' command
+for a description of this minor mode.
+Setting this variable directly does not take effect;
+either customize it (see the info node `Easy Customization')
+or call the function `editorconfig-mode'.")
+
+(custom-autoload 'editorconfig-mode "editorconfig" nil)
+
+(autoload 'editorconfig-mode "editorconfig" "\
+Toggle EditorConfig feature.
+
+To disable EditorConfig in some buffers, modify
+`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'.
+
+\(fn &optional ARG)" t nil)
+
+(autoload 'editorconfig-find-current-editorconfig "editorconfig" "\
+Find the closest .editorconfig file for current file.
+
+\(fn)" t nil)
+
+(autoload 'editorconfig-display-current-properties "editorconfig" "\
+Display EditorConfig properties extracted for current buffer.
+
+\(fn)" t nil)
+
+(defalias 'describe-editorconfig-properties 'editorconfig-display-current-properties)
+
+(autoload 'editorconfig-format-buffer "editorconfig" "\
+Format buffer according to .editorconfig indent_style and indent_width.
+
+\(fn)" t nil)
+
+(autoload 'editorconfig-version "editorconfig" "\
+Get EditorConfig version as string.
+
+If called interactively or if SHOW-VERSION is non-nil, show the
+version in the echo area and the messages buffer.
+
+\(fn &optional SHOW-VERSION)" t nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig" '("editorconfig-")))
+
+;;;***
+\f
+;;;### (autoloads nil "editorconfig-conf-mode" "editorconfig-conf-mode.el"
+;;;;;; (0 0 0 0))
+;;; Generated autoloads from editorconfig-conf-mode.el
+
+(autoload 'editorconfig-conf-mode "editorconfig-conf-mode" "\
+Major mode for editing .editorconfig files.
+
+\(fn)" t nil)
+
+(add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode))
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-conf-mode" '("editorconfig-conf-mode-syntax-table")))
+
+;;;***
+\f
+;;;### (autoloads nil "editorconfig-core" "editorconfig-core.el"
+;;;;;; (0 0 0 0))
+;;; Generated autoloads from editorconfig-core.el
+
+(autoload 'editorconfig-core-get-nearest-editorconfig "editorconfig-core" "\
+Return path to .editorconfig file that is closest to DIRECTORY.
+
+\(fn DIRECTORY)" nil nil)
+
+(autoload 'editorconfig-core-get-properties "editorconfig-core" "\
+Get EditorConfig properties for FILE.
+If FILE is not given, use currently visiting file.
+Give CONFNAME for basename of config file other than .editorconfig.
+If need to specify config format version, give CONFVERSION.
+
+This functions returns alist of properties. Each element will look like
+'(KEY . VALUE) .
+
+\(fn &optional FILE CONFNAME CONFVERSION)" nil nil)
+
+(autoload 'editorconfig-core-get-properties-hash "editorconfig-core" "\
+Get EditorConfig properties for FILE.
+If FILE is not given, use currently visiting file.
+Give CONFNAME for basename of config file other than .editorconfig.
+If need to specify config format version, give CONFVERSION.
+
+This function is almost same as `editorconfig-core-get-properties', but returns
+hash object instead.
+
+\(fn &optional FILE CONFNAME CONFVERSION)" nil nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-core" '("editorconfig-core--")))
+
+;;;***
+\f
+;;;### (autoloads nil "editorconfig-core-handle" "editorconfig-core-handle.el"
+;;;;;; (0 0 0 0))
+;;; Generated autoloads from editorconfig-core-handle.el
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-core-handle" '("editorconfig-core-handle")))
+
+;;;***
+\f
+;;;### (autoloads nil "editorconfig-fnmatch" "editorconfig-fnmatch.el"
+;;;;;; (0 0 0 0))
+;;; Generated autoloads from editorconfig-fnmatch.el
+
+(autoload 'editorconfig-fnmatch-p "editorconfig-fnmatch" "\
+Test whether STRING match PATTERN.
+
+Matching ignores case if `case-fold-search' is non-nil.
+
+PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can
+be used:
+
+* Matches any string of characters, except path separators (/)
+** Matches any string of characters
+? Matches any single character
+\[name] Matches any single character in name
+\[^name] Matches any single character not in name
+{s1,s2,s3} Matches any of the strings given (separated by commas)
+{min..max} Matches any number between min and max
+
+\(fn STRING PATTERN)" nil nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-fnmatch" '("editorconfig-fnmatch-")))
+
+;;;***
+\f
+;;;### (autoloads nil nil ("editorconfig-pkg.el") (0 0 0 0))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; editorconfig-autoloads.el ends here
--- /dev/null
+;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2020 EditorConfig Team
+
+;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
+
+;; See
+;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
+;; or the CONTRIBUTORS file for the list of contributors.
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at your
+;; option) any later version.
+
+;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Major mode for editing .editorconfig files.
+
+;;; Code:
+
+(require 'conf-mode)
+
+(defvar editorconfig-conf-mode-syntax-table
+ (let ((table (make-syntax-table conf-unix-mode-syntax-table)))
+ (modify-syntax-entry ?\; "<" table)
+ table)
+ "Syntax table in use in `editorconfig-conf-mode' buffers.")
+
+;;;###autoload
+(define-derived-mode editorconfig-conf-mode conf-unix-mode "Conf[EditorConfig]"
+ "Major mode for editing .editorconfig files."
+ (set-variable 'indent-line-function 'indent-relative)
+ (let ((key-property-list
+ '("charset"
+ "end_of_line"
+ "file_type_emacs"
+ "file_type_ext"
+ "indent_size"
+ "indent_style"
+ "insert_final_newline"
+ "max_line_length"
+ "root"
+ "tab_width"
+ "trim_trailing_whitespace"))
+ (key-value-list
+ '("unset"
+ "true"
+ "false"
+ "lf"
+ "cr"
+ "crlf"
+ "space"
+ "tab"
+ "latin1"
+ "utf-8"
+ "utf-8-bom"
+ "utf-16be"
+ "utf-16le"))
+ (font-lock-value
+ '(("^[ \t]*\\[\\(.+?\\)\\]" 1 font-lock-type-face)
+ ("^[ \t]*\\(.+?\\)[ \t]*[=:]" 1 font-lock-variable-name-face))))
+
+ ;; Highlight all key values
+ (dolist (key-value key-value-list)
+ (push
+ `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value)
+ 1 font-lock-constant-face)
+ font-lock-value
+ ))
+ ;; Highlight all key properties
+ (dolist (key-property key-property-list)
+ (push
+ `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property)
+ 1 font-lock-builtin-face)
+ font-lock-value
+ ))
+
+ (conf-mode-initialize "#" font-lock-value)))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist
+ '("\\.editorconfig\\'" . editorconfig-conf-mode))
+
+(provide 'editorconfig-conf-mode)
+
+;;; editorconfig-conf-mode.el ends here
--- /dev/null
+;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2020 EditorConfig Team
+
+;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
+
+;; See
+;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
+;; or the CONTRIBUTORS file for the list of contributors.
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at your
+;; option) any later version.
+
+;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Handle structures for EditorConfig config file. This library is used
+;; internally from editorconfig-core.el .
+
+;;; Code:
+
+(require 'cl-lib)
+
+(require 'editorconfig-fnmatch)
+
+(defvar editorconfig-core-handle--cache-hash
+ (make-hash-table :test 'equal)
+ "Hash of EditorConfig filename and its `editorconfig-core-handle' instance.")
+
+(cl-defstruct editorconfig-core-handle-section
+ "Structure representing one section in a .editorconfig file.
+
+Slots:
+
+`name'
+ String of section name (glob string).
+
+`props'
+ Alist of properties: (KEY . VALUE)."
+ (name nil)
+ (props nil))
+
+(defun editorconfig-core-handle-section-get-properties (section file dir)
+ "Return properties alist when SECTION name match FILE.
+
+DIR should be the directory where .editorconfig file which has SECTION lives.
+IF not match, return nil."
+ (when (editorconfig-core-handle--fnmatch-p
+ file
+ (editorconfig-core-handle-section-name section)
+ dir)
+ (editorconfig-core-handle-section-props section)))
+
+(cl-defstruct editorconfig-core-handle
+ "Structure representing an .editorconfig file.
+
+Slots:
+`top-props'
+ Alist of top propetties like ((\"root\" . \"true\"))
+
+`sections'
+ List of `editorconfig-core-hadnle-section' strucure object.
+
+`mtime'
+ Last modified time of .editorconfig file.
+
+`path'
+ Absolute path to .editorconfig file.'
+"
+ (top-props nil)
+ (sections nil)
+ (mtime nil)
+ (path nil))
+
+
+(defun editorconfig-core-handle (conf)
+ "Return EditorConfig handle for CONF, which should be a file path.
+
+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))))
+ (if (and cached
+ (equal (editorconfig-core-handle-mtime cached)
+ mtime))
+ cached
+ (let ((parsed (editorconfig-core-handle--parse-file conf)))
+ (puthash conf
+ (make-editorconfig-core-handle :top-props (plist-get parsed :top-props)
+ :sections (plist-get parsed :sections)
+ :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.
+
+If HANDLE is nil return nil."
+ (when handle
+ (string-equal "true"
+ (downcase (or (cdr (assoc "root"
+ (editorconfig-core-handle-top-props handle)))
+ "")))))
+
+(defun editorconfig-core-handle-get-properties (handle file)
+ "Return list of alist of properties from HANDLE for FILE.
+The list returned will be ordered by the lines they appear.
+
+If HANDLE is nil return nil."
+ (when handle
+ (let ((dir (file-name-directory (editorconfig-core-handle-path handle))))
+ (cl-loop for section in (editorconfig-core-handle-sections handle)
+ for props = (editorconfig-core-handle-section-get-properties section
+ file
+ dir)
+ when props collect (copy-alist props)))))
+(make-obsolete 'editorconfig-core-handle-get-properties
+ 'editorconfig-core-handle-get-properties-hash
+ "0.8.0")
+
+
+(defun editorconfig-core-handle-get-properties-hash (handle file)
+ "Return hash of properties from HANDLE for FILE.
+
+If HANDLE is nil return nil."
+ (when handle
+ (let ((hash (make-hash-table))
+ (dir (file-name-directory (editorconfig-core-handle-path
+ handle))))
+ (dolist (section (editorconfig-core-handle-sections handle))
+ (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir)
+ do (puthash (intern key) value hash)))
+ hash)))
+
+(defun editorconfig-core-handle--fnmatch-p (name pattern dir)
+ "Return non-nil if NAME match PATTERN.
+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)))
+ (editorconfig-fnmatch-p name
+ (concat "**/"
+ pattern))))
+
+(defsubst editorconfig-core-handle--string-trim (str)
+ "Remove leading and trailing whitespaces from STR."
+ (replace-regexp-in-string "[[:space:]]+\\'"
+ ""
+ (replace-regexp-in-string "\\`[[:space:]]+"
+ ""
+ str)))
+
+(defun editorconfig-core-handle--parse-file (conf)
+ "Parse EditorConfig file CONF.
+
+This function returns cons of its top properties alist and
+alist of patterns and its properties alist.
+The list returned will be ordered by the lines they appear.
+
+If CONF is not found return nil."
+ (when (file-readable-p conf)
+ (with-temp-buffer
+ ;; NOTE: Use this instead of insert-file-contents-literally to enable
+ ;; code conversion
+ (insert-file-contents conf)
+ (goto-char (point-min))
+ (let ((point-max (point-max))
+ (sections ())
+ (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 ())
+
+ ;; Current line num
+ (current-line-number 1)
+ )
+ (while (not (eq (point) point-max))
+ (setq line
+ (buffer-substring-no-properties (point-at-bol)
+ (point-at-eol)))
+ (setq line
+ (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$"
+ ""
+ (editorconfig-core-handle--string-trim line)))
+
+ (cond
+ ((string-equal "" line)
+ nil)
+
+ ;; Start of section
+ ((string-match "^\\[\\(.*\\)\\]$"
+ line)
+ (when pattern
+ (setq sections
+ `(,@sections ,(make-editorconfig-core-handle-section
+ :name pattern
+ :props props)))
+ (setq pattern nil)
+ (setq props nil))
+ (setq pattern (match-string 1 line)))
+
+ (t
+ (let ((idx (string-match "=\\|:"
+ line)))
+ (unless idx
+ (error "Error while reading config file: %s:%d:\n %s\n"
+ conf
+ current-line-number
+ line))
+ (let (
+ (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))))))))
+ )
+ (setq current-line-number
+ (1+ current-line-number))
+ (goto-char (point-min))
+ (forward-line (1- current-line-number))
+ )
+ (when pattern
+ (setq sections
+ `(,@sections ,(make-editorconfig-core-handle-section
+ :name pattern
+ :props props))))
+ (list :top-props top-props
+ :sections sections)))))
+
+(provide 'editorconfig-core-handle)
+
+;;; editorconfig-core-handle.el ends here
--- /dev/null
+;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2020 EditorConfig Team
+
+;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
+
+;; See
+;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
+;; or the CONTRIBUTORS file for the list of contributors.
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at your
+;; option) any later version.
+
+;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This library is one implementation of EditorConfig Core, which parses
+;; .editorconfig files and returns properties for given files.
+;; This can be used in place of, for example, editorconfig-core-c.
+
+
+;; Use from EditorConfig Emacs Plugin
+
+;; Emacs plugin (v0.5 or later) can utilize this implementation.
+;; By default, the plugin first search for any EditorConfig executable,
+;; and fallback to this library if not found.
+;; If you always want to use this library, add following lines to your init.el:
+
+;; (setq editorconfig-get-properties-function
+;; 'editorconfig-core-get-properties-hash)
+
+
+;; Functions
+
+;; editorconfig-core-get-properties (&optional file confname confversion)
+
+;; Get EditorConfig properties for FILE.
+
+;; If FILE is not given, use currently visiting file.
+;; Give CONFNAME for basename of config file other than .editorconfig.
+;; If need to specify config format version, give CONFVERSION.
+
+;; This functions returns alist of properties. Each element will look like
+;; (KEY . VALUE) .
+
+
+;; editorconfig-core-get-properties-hash (&optional file confname confversion)
+
+;; Get EditorConfig properties for FILE.
+
+;; This function is almost same as `editorconfig-core-get-properties', but
+;; returns hash object instead.
+
+;;; Code:
+
+(require 'cl-lib)
+
+(require 'editorconfig-core-handle)
+
+
+(defun editorconfig-core--get-handles (dir confname &optional result)
+ "Get list of EditorConfig handlers for DIR from CONFNAME.
+
+In the resulting list, the handle for root config file comes first, and the
+nearest comes last.
+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))))
+ (if (or (string= parent
+ dir)
+ (and handle
+ (editorconfig-core-handle-root-p handle)))
+ (cl-remove-if-not 'identity
+ (cons handle result))
+ (editorconfig-core--get-handles parent
+ confname
+ (cons handle
+ result)))))
+
+;;;###autoload
+(defun editorconfig-core-get-nearest-editorconfig (directory)
+ "Return path to .editorconfig file that is closest to DIRECTORY."
+ (let ((handle (car (last (editorconfig-core--get-handles directory
+ ".editorconfig")))))
+ (when handle
+ (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.
+Give CONFNAME for basename of config file other than .editorconfig.
+If need to specify config format version, give CONFVERSION.
+
+This functions returns alist of properties. Each element will look like
+'(KEY . VALUE) ."
+ (let ((hash (editorconfig-core-get-properties-hash file confname confversion))
+ (result nil))
+ (maphash (lambda (key value)
+ (add-to-list 'result
+ (cons (symbol-name key)
+ value)))
+ hash)
+ result))
+
+(defun editorconfig-core--hash-merge (into update)
+ "Merge to hashes INTO and UPDATE.
+
+This is a destructive function, hash INTO will be modified.
+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.
+Give CONFNAME for basename of config file other than .editorconfig.
+If need to specify config format version, give CONFVERSION.
+
+This function is almost same as `editorconfig-core-get-properties', but returns
+hash object instead."
+ (setq file
+ (expand-file-name (or file
+ buffer-file-name
+ (error "FILE is not given and `buffer-file-name' is nil"))))
+ (setq confname (or confname
+ ".editorconfig"))
+ (setq confversion (or confversion
+ "0.12.0"))
+ (let ((result (make-hash-table)))
+ (dolist (handle (editorconfig-core--get-handles (file-name-directory file)
+ confname))
+ (editorconfig-core--hash-merge result
+ (editorconfig-core-handle-get-properties-hash handle
+ file)))
+
+ ;; Downcase known boolean values
+ (dolist (key '(
+ end_of_line indent_style indent_size insert_final_newline
+ trim_trailing_whitespace charset
+ ))
+ (let ((val (gethash key
+ result)))
+ (when val
+ (puthash key
+ (downcase val)
+ result))))
+
+ ;; Add indent_size property
+ (let ((v-indent-size (gethash 'indent_size result))
+ (v-indent-style (gethash 'indent_style result)))
+ (when (and (not v-indent-size)
+ (string= v-indent-style "tab")
+ ;; If VERSION < 0.9.0, indent_size should have no default value
+ (version<= "0.9.0"
+ confversion))
+ (puthash 'indent_size
+ "tab"
+ result)))
+ ;; Add tab_width property
+ (let ((v-indent-size (gethash 'indent_size result))
+ (v-tab-width (gethash 'tab_width result)))
+ (when (and v-indent-size
+ (not v-tab-width)
+ (not (string= v-indent-size "tab")))
+ (puthash 'tab_width
+ v-indent-size
+ result)))
+ ;; Update indent-size property
+ (let ((v-indent-size (gethash 'indent_size result))
+ (v-tab-width (gethash 'tab_width result)))
+ (when (and v-indent-size
+ v-tab-width
+ (string= v-indent-size "tab"))
+ (puthash 'indent_size
+ v-tab-width
+ result)))
+
+ result))
+
+(provide 'editorconfig-core)
+
+;;; editorconfig-core.el ends here
--- /dev/null
+;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2020 EditorConfig Team
+
+;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
+
+;; See
+;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
+;; or the CONTRIBUTORS file for the list of contributors.
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at your
+;; option) any later version.
+
+;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; editorconfig-fnmatch.el provides a fnmatch implementation with a few
+;; extensions.
+;; The main usage of this library is glob pattern matching for EditorConfig, but
+;; it can also act solely.
+
+;; editorconfig-fnmatch-p (name pattern)
+
+;; Test whether NAME match PATTERN.
+
+;; PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings
+;; can be used:
+
+;; * Matches any string of characters, except path separators (/)
+;; ** Matches any string of characters
+;; ? Matches any single character
+;; [name] Matches any single character in name
+;; [^name] Matches any single character not in name
+;; {s1,s2,s3} Matches any of the strings given (separated by commas)
+;; {min..max} Matches any number between min and max
+
+
+;; This library is a port from editorconfig-core-py library.
+;; https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/fnmatch.py
+
+;;; Code:
+
+(require 'cl-lib)
+
+(defvar editorconfig-fnmatch--cache-hashtable
+ nil
+ "Cache of shell pattern and its translation.")
+;; Clear cache on file reload
+(setq editorconfig-fnmatch--cache-hashtable
+ (make-hash-table :test 'equal))
+
+
+(defconst editorconfig-fnmatch--left-brace-regexp
+ "\\(^\\|[^\\]\\){"
+ "Regular expression for left brace ({).")
+
+(defconst editorconfig-fnmatch--right-brace-regexp
+ "\\(^\\|[^\\]\\)}"
+ "Regular expression for right brace (}).")
+
+
+(defconst editorconfig-fnmatch--numeric-range-regexp
+ "\\([+-]?[0-9]+\\)\\.\\.\\([+-]?[0-9]+\\)"
+ "Regular expression for numaric range (like {-3..+3}).")
+
+(defun editorconfig-fnmatch--match-num (regexp string)
+ "Return how many times REGEXP is found in STRING."
+ (let ((num 0))
+ ;; 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))))
+ num))
+
+;;;###autoload
+(defun editorconfig-fnmatch-p (string pattern)
+ "Test whether STRING match PATTERN.
+
+Matching ignores case if `case-fold-search' is non-nil.
+
+PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can
+be used:
+
+* Matches any string of characters, except path separators (/)
+** Matches any string of characters
+? Matches any single character
+[name] Matches any single character in name
+[^name] Matches any single character not in name
+{s1,s2,s3} Matches any of the strings given (separated by commas)
+{min..max} Matches any number between min and max"
+ (string-match (editorconfig-fnmatch-translate pattern)
+ string))
+
+;;(editorconfig-fnmatch-translate "{a,{-3..3}}.js")
+;;(editorconfig-fnmatch-p "1.js" "{a,{-3..3}}.js")
+
+(defun editorconfig-fnmatch-translate (pattern)
+ "Translate a shell PATTERN to a regular expression.
+
+Translation result will be cached, so same translation will not be done twice."
+ (let ((cached (gethash pattern
+ editorconfig-fnmatch--cache-hashtable)))
+ (or cached
+ (puthash pattern
+ (editorconfig-fnmatch--do-translate pattern)
+ editorconfig-fnmatch--cache-hashtable))))
+
+
+(defun editorconfig-fnmatch--do-translate (pattern &optional nested)
+ "Translate a shell PATTERN to a regular expression.
+
+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)
+ (editorconfig-fnmatch--match-num
+ editorconfig-fnmatch--right-brace-regexp
+ pattern)))
+
+ 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)
+
+ (setq current-char (aref pattern 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 result `(,@result "[^/]")))
+
+ (?\[
+ (if in-brackets
+ (setq result `(,@result "\\["))
+ (if (= (aref pattern index) ?/)
+ ;; Slash after an half-open bracket
+ (setq result `(,@result "\\[/")
+ index (+ index 1))
+ (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 "\\-"))))
+
+ (?\]
+ (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
+ (let ((number-start (string-to-number (match-string 1
+ pattern-sub)))
+ (number-end (string-to-number (match-string 2
+ pattern-sub))))
+ (setq result `(,@result ,(concat "\\(?:"
+ (mapconcat 'number-to-string
+ (cl-loop for i from number-start to number-end
+ collect i)
+ "\\|")
+ "\\)"))))
+ (let ((inner (editorconfig-fnmatch--do-translate pattern-sub t)))
+ (setq result `(,@result ,(format "{%s}"
+ 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 "\\)")
+ 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 "/"))))
+
+ (t
+ (unless (= 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)))
+ (setq is-escaped nil))))
+ (unless nested
+ (setq result `("^" ,@result "\\'")))
+ (apply 'concat result)))
+
+(provide 'editorconfig-fnmatch)
+
+;;; editorconfig-fnmatch.el ends here
--- /dev/null
+(define-package "editorconfig" "20200116.902" "EditorConfig Emacs Plugin"
+ '((cl-lib "0.5")
+ (emacs "24"))
+ :authors
+ '(("EditorConfig Team" . "editorconfigNOSPAMgooglegroups.com"))
+ :maintainer
+ '("EditorConfig Team" . "editorconfigNOSPAMgooglegroups.com")
+ :url "https://github.com/editorconfig/editorconfig-emacs#readme")
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
--- /dev/null
+;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2020 EditorConfig Team
+
+;; Author: EditorConfig Team <editorconfigNOSPAMgooglegroups.com>
+;; Version: 0.8.1
+;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
+;; Package-Requires: ((cl-lib "0.5") (emacs "24"))
+
+;; See
+;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
+;; or the CONTRIBUTORS file for the list of contributors.
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at your
+;; option) any later version.
+
+;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU General Public License along with
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; EditorConfig helps developers define and maintain consistent
+;; coding styles between different editors and IDEs.
+
+;; The EditorConfig project consists of a file format for defining
+;; coding styles and a collection of text editor plugins that enable
+;; editors to read the file format and adhere to defined styles.
+;; EditorConfig files are easily readable and they work nicely with
+;; version control systems.
+
+;;; Code:
+(require 'cl-lib)
+(eval-when-compile
+ (require 'rx)
+ (defvar tex-indent-basic)
+ (defvar tex-indent-item)
+ (defvar tex-indent-arg)
+ (defvar evil-shift-width))
+
+(declare-function editorconfig-core-get-properties-hash
+ "editorconfig-core"
+ nil)
+
+(defgroup editorconfig nil
+ "EditorConfig Emacs Plugin.
+
+EditorConfig helps developers define and maintain consistent
+coding styles between different editors and IDEs."
+ :tag "EditorConfig"
+ :prefix "editorconfig-"
+ :group 'tools)
+
+(defcustom editorconfig-exec-path
+ "editorconfig"
+ "Path to EditorConfig executable.
+
+Used by `editorconfig-call-editorconfig-exec'."
+ :type 'string
+ :group 'editorconfig)
+(define-obsolete-variable-alias
+ 'edconf-exec-path
+ 'editorconfig-exec-path
+ "0.5")
+
+(defcustom editorconfig-get-properties-function
+ 'editorconfig-get-properties
+ "A function which gets EditorConofig properties for current buffer.
+
+This function will be called with no argument and should return a
+hash object containing properties, or nil if any core program is
+not available. Keys of this hash should be symbols of properties, and values
+should be strings of their values.
+
+
+For example, if you always want to use built-in core library instead
+of any EditorConfig executable to get properties, add following to
+your init.el:
+
+ (set-variable 'editorconfig-get-properties-function
+ #'editorconfig-core-get-properties-hash)
+
+Possible known values are:
+
+* `editorconfig-get-properties' (default)
+ * Use `editorconfig-get-properties-from-exec' when
+ `editorconfig-exec-path' executable executable is found, otherwise
+ use `editorconfig-core-get-properties-hash'
+* `editorconfig-get-properties-from-exec'
+ * Get properties by executing EditorConfig executable
+* `editorconfig-core-get-properties-hash'
+ * Always use built-in Emacs-Lisp implementation to get properties"
+ :type 'function
+ :group 'editorconfig)
+(define-obsolete-variable-alias
+ 'edconf-get-properties-function
+ 'editorconfig-get-properties-function
+ "0.5")
+
+(defcustom editorconfig-mode-lighter " EditorConfig"
+ "`editorconfig-mode' lighter string."
+ :type 'string
+ :group 'editorconfig)
+
+(defcustom editorconfig-after-apply-functions ()
+ "A list of functions after loading common EditorConfig settings.
+
+Each element in this list is a hook function. This hook function
+takes one parameter, which is a property hash table. The value
+of properties can be obtained through gethash function.
+
+The hook does not have to be coding style related; you can add
+whatever functionality you want. For example, the following is
+an example to add a new property emacs_linum to decide whether to
+show line numbers on the left:
+
+ (add-hook 'editorconfig-after-apply-functions
+ '(lambda (props)
+ (let ((show-line-num (gethash 'emacs_linum props)))
+ (cond ((equal show-line-num \"true\") (linum-mode 1))
+ ((equal show-line-num \"false\") (linum-mode 0))))))"
+ :type 'hook
+ :group 'editorconfig)
+(define-obsolete-variable-alias
+ 'edconf-custom-hooks
+ 'editorconfig-after-apply-functions
+ "0.5")
+(define-obsolete-variable-alias
+ 'editorconfig-custom-hooks
+ 'editorconfig-after-apply-functions
+ "0.7.14")
+
+(defcustom editorconfig-hack-properties-functions ()
+ "A list of function to alter property values before applying them.
+
+These functions will be run after loading \".editorconfig\" files and before
+applying them to current buffer, so that you can alter some properties from
+\".editorconfig\" before they take effect.
+
+For example, Makefiles always use tab characters for indentation: you can
+overwrite \"indent_style\" property when current `major-mode' is a
+`makefile-mode' with following code:
+
+ (add-hook 'editorconfig-hack-properties-functions
+ '(lambda (props)
+ (when (derived-mode-p 'makefile-mode)
+ (puthash 'indent_style \"tab\" props))))"
+ :type 'hook
+ :group 'editorconfig)
+
+(defcustom editorconfig-indentation-alist
+ ;; For contributors: Sort modes in alphabetical order
+ '((apache-mode apache-indent-level)
+ (awk-mode c-basic-offset)
+ (bpftrace-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)
+ (crystal-mode crystal-indent-level)
+ (csharp-mode c-basic-offset)
+ (css-mode css-indent-offset)
+ (emacs-lisp-mode lisp-indent-offset)
+ (enh-ruby-mode enh-ruby-indent-level)
+ (erlang-mode erlang-indent-level)
+ (ess-mode ess-indent-offset)
+ (f90-mode f90-associate-indent
+ f90-continuation-indent
+ f90-critical-indent
+ f90-do-indent
+ f90-if-indent
+ f90-program-indent
+ f90-type-indent)
+ (feature-mode feature-indent-offset
+ feature-indent-level)
+ (fsharp-mode fsharp-continuation-offset
+ fsharp-indent-level
+ fsharp-indent-offset)
+ (groovy-mode groovy-indent-offset)
+ (haskell-mode haskell-indent-spaces
+ haskell-indent-offset
+ haskell-indentation-layout-offset
+ haskell-indentation-left-offset
+ haskell-indentation-starter-offset
+ haskell-indentation-where-post-offset
+ haskell-indentation-where-pre-offset
+ shm-indent-spaces)
+ (haxor-mode haxor-tab-width)
+ (idl-mode c-basic-offset)
+ (jade-mode jade-tab-width)
+ (java-mode c-basic-offset)
+ (js-mode js-indent-level)
+ (js-jsx-mode js-indent-level sgml-basic-offset)
+ (js2-mode js2-basic-offset)
+ (js2-jsx-mode js2-basic-offset sgml-basic-offset)
+ (js3-mode js3-indent-level)
+ (json-mode js-indent-level)
+ (julia-mode julia-indent-offset)
+ (kotlin-mode kotlin-tab-width)
+ (latex-mode . editorconfig-set-indentation-latex-mode)
+ (lisp-mode lisp-indent-offset)
+ (livescript-mode livescript-tab-width)
+ (lua-mode lua-indent-level)
+ (matlab-mode matlab-indent-level)
+ (mips-mode mips-tab-width)
+ (mustache-mode mustache-basic-offset)
+ (nasm-mode nasm-basic-offset)
+ (nginx-mode nginx-indent-level)
+ (nxml-mode nxml-child-indent (nxml-attribute-indent . 2))
+ (objc-mode c-basic-offset)
+ (octave-mode octave-block-offset)
+ (perl-mode perl-indent-level)
+ ;; No need to change `php-mode-coding-style' value for php-mode
+ ;; since we run editorconfig later than it resets `c-basic-offset'.
+ ;; See https://github.com/editorconfig/editorconfig-emacs/issues/116
+ ;; for details.
+ (php-mode c-basic-offset)
+ (pike-mode c-basic-offset)
+ (ps-mode ps-mode-tab)
+ (pug-mode pug-tab-width)
+ (puppet-mode puppet-indent-level)
+ (python-mode . editorconfig-set-indentation-python-mode)
+ (ruby-mode ruby-indent-level)
+ (rust-mode rust-indent-offset)
+ (rustic-mode rustic-indent-offset)
+ (scala-mode scala-indent:step)
+ (scss-mode css-indent-offset)
+ (sgml-mode sgml-basic-offset)
+ (sh-mode sh-basic-offset sh-indentation)
+ (slim-mode slim-indent-offset)
+ (tcl-mode tcl-indent-level
+ tcl-continued-indent-level)
+ (terra-mode terra-indent-level)
+ (typescript-mode typescript-indent-level)
+ (verilog-mode verilog-indent-level
+ verilog-indent-level-behavioral
+ verilog-indent-level-declaration
+ verilog-indent-level-module
+ verilog-cexp-indent
+ verilog-case-indent)
+ (web-mode (web-mode-indent-style . (lambda (size) 2))
+ web-mode-attr-indent-offset
+ web-mode-attr-value-indent-offset
+ web-mode-code-indent-offset
+ web-mode-css-indent-offset
+ web-mode-markup-indent-offset
+ web-mode-sql-indent-offset
+ web-mode-block-padding
+ 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).
+
+If FUNCTION is provided, it will be called when setting the
+indentation. The indent size will be passed.
+
+If INDENT-SPEC-LIST is provided, each element of it must have one of the
+following forms:
+
+ 1. VARIABLE
+ It means (VARIABLE . 1).
+
+ 2. (VARIABLE . SPEC)
+ Setting VARIABLE according to the type of SPEC:
+
+ - Integer
+ The value is (* SPEC INDENT-SIZE);
+
+ - Function
+ The value is (funcall SPEC INDENT-SIZE);
+
+ - Any other type.
+ The value is SPEC.
+
+NOTE: Only the **buffer local** value of VARIABLE will be set."
+ :type '(alist :key-type symbol :value-type sexp)
+ :risky t
+ :group 'editorconfig)
+(define-obsolete-variable-alias
+ 'edconf-indentation-alist
+ 'editorconfig-indentation-alist
+ "0.5")
+
+(defcustom editorconfig-exclude-modes ()
+ "Modes in which `editorconfig-mode-apply' will not run."
+ :type '(repeat (symbol :tag "Major Mode"))
+ :group 'editorconfig)
+
+(defcustom editorconfig-exclude-regexps
+ (list (eval-when-compile
+ (rx string-start (or "http" "https" "ftp" "sftp" "rsync") ":")))
+ "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)
+
+(defcustom editorconfig-trim-whitespaces-mode nil
+ "Buffer local minor-mode to use to trim trailing whitespaces.
+
+If set, enable that mode when `trim_trailing_whitespace` is set to true.
+Otherwise, use `delete-trailing-whitespace'."
+ :type 'symbol
+ :group 'editorconfig)
+
+(defvar editorconfig-properties-hash nil
+ "Hash object of EditorConfig properties that was enabled for current buffer.
+Set by `editorconfig-apply' and nil if that is not invoked in
+current buffer yet.")
+(make-variable-buffer-local 'editorconfig-properties-hash)
+(put 'editorconfig-properties-hash
+ 'permanent-local
+ t)
+
+(defvar editorconfig-lisp-use-default-indent nil
+ "Selectively ignore the value of indent_sizefor Lisp files.
+Prevents `lisp-indent-offset' from being set selectively.
+
+nil - `lisp-indent-offset' is always set normally.
+t - `lisp-indent-offset' is never set normally
+ (always use default indent for lisps).
+number - `lisp-indent-offset' is not set only if indent_size is
+ equal to this number. For example, if this is set to 2,
+ `lisp-indent-offset'will not be set only if indent_size is 2.")
+
+(defconst editorconfig-unset-value "unset"
+ "String of value used to unset properties in .editorconfig .")
+
+(defun editorconfig-string-integer-p (string)
+ "Return non-nil if STRING represents integer."
+ (and (stringp string)
+ (string-match-p "\\`[0-9]+\\'" string)))
+
+(defun editorconfig-set-indentation-python-mode (size)
+ "Set `python-mode' indent size to SIZE."
+ (set (make-local-variable (if (or (> emacs-major-version 24)
+ (and (= emacs-major-version 24)
+ (>= emacs-minor-version 3)))
+ 'python-indent-offset
+ 'python-indent))
+ size)
+ ;; For https://launchpad.net/python-mode
+ (when (boundp 'py-indent-offset)
+ (set (make-local-variable 'py-indent-offset) size)))
+
+(defun editorconfig-set-indentation-latex-mode (size)
+ "Set `latex-mode' indent size to SIZE."
+ (set (make-local-variable 'tex-indent-basic) size)
+ (set (make-local-variable 'tex-indent-item) size)
+ (set (make-local-variable 'tex-indent-arg) (* 2 size))
+ ;; For AUCTeX
+ (when (boundp 'TeX-brace-indent-level)
+ (set (make-local-variable 'TeX-brace-indent-level) size))
+ (when (boundp 'LaTeX-indent-level)
+ (set (make-local-variable 'LaTeX-indent-level) size))
+ (when (boundp 'LaTeX-item-indent)
+ (set (make-local-variable 'LaTeX-item-indent) (- size))))
+
+(defun editorconfig--should-set (size symbol)
+ "Determines if editorconfig should set SYMBOL using SIZE."
+ (if (eq symbol 'lisp-indent-offset)
+ (cond
+ ((eql nil editorconfig-lisp-use-default-indent)
+ t)
+ ((eql t editorconfig-lisp-use-default-indent)
+ nil)
+ ((numberp editorconfig-lisp-use-default-indent)
+ (not (eql size editorconfig-lisp-use-default-indent)))
+ (t t))
+ t))
+
+(defun editorconfig-set-indentation (style &optional size tab_width)
+ "Set indentation type from STYLE, SIZE and TAB_WIDTH."
+ (make-local-variable 'indent-tabs-mode)
+ (make-local-variable 'tab-width)
+ (if (editorconfig-string-integer-p size)
+ (setq size (string-to-number size))
+ (when (not (equal size "tab")) (setq size nil)))
+ (setq tab-width (cond (tab_width (string-to-number tab_width))
+ ((numberp size) size)
+ (t tab-width)))
+ (when (equal size "tab")
+ (setq size tab-width))
+ (cond ((equal style "space")
+ (setq indent-tabs-mode nil))
+ ((equal style "tab")
+ (setq indent-tabs-mode t)))
+ (when size
+ (when (featurep 'evil)
+ (set (make-local-variable 'evil-shift-width) size))
+ (let ((parent major-mode)
+ entry)
+ ;; Find the closet parent mode of `major-mode' in
+ ;; `editorconfig-indentation-alist'.
+ (while (and (not (setq entry (assoc parent editorconfig-indentation-alist)))
+ (setq parent (get parent 'derived-mode-parent))))
+ (when entry
+ (let ((fn-or-list (cdr entry)))
+ (cond ((functionp fn-or-list) (funcall fn-or-list size))
+ ((listp fn-or-list)
+ (dolist (elem fn-or-list)
+ (cond ((and (symbolp elem)
+ (editorconfig--should-set size elem))
+ (set (make-local-variable elem) size))
+ ((and (consp elem)
+ (editorconfig--should-set size (car elem)))
+ (let ((spec (cdr elem)))
+ (set (make-local-variable (car elem))
+ (cond ((functionp spec) (funcall spec size))
+ ((integerp spec) (* spec size))
+ (t spec))))))))))))))
+
+(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-with-signature)
+ ((equal charset "utf-16le") 'utf-16le-with-signature)
+ (t 'undecided))))
+ (unless (and (eq eol 'undecided)
+ (eq cs 'undecided))
+ (set-buffer-file-coding-system (merge-coding-systems
+ cs
+ eol)
+ nil t))))
+
+(defun editorconfig-set-trailing-nl (final-newline)
+ "Set up requiring final newline by FINAL-NEWLINE.
+
+This function will set `require-final-newline' and `mode-require-final-newline'
+to non-nil when FINAL-NEWLINE is true."
+ (cond
+ ((equal final-newline "true")
+ ;; keep prefs around how/when the nl is added, if set - otherwise add on save
+ (set (make-local-variable 'require-final-newline) (or require-final-newline t))
+ (set (make-local-variable 'mode-require-final-newline) (or mode-require-final-newline t)))
+ ((equal final-newline "false")
+ ;; FIXME: Add functionality for actually REMOVING any trailing newlines here!
+ ;; (rather than just making sure we don't automagically ADD a new one)
+ (set (make-local-variable 'require-final-newline) nil)
+ (set (make-local-variable 'mode-require-final-newline) nil))))
+
+(defun editorconfig-set-trailing-ws (trim-trailing-ws)
+ "Set up trimming of trailing whitespace at end of lines by TRIM-TRAILING-WS."
+ (make-local-variable 'write-file-functions) ;; just current buffer
+ (when (and (equal trim-trailing-ws "true")
+ (not buffer-read-only))
+ ;; when true we push delete-trailing-whitespace (emacs > 21)
+ ;; to write-file-functions
+ (if editorconfig-trim-whitespaces-mode
+ (funcall editorconfig-trim-whitespaces-mode 1)
+ (add-to-list
+ 'write-file-functions
+ 'delete-trailing-whitespace)))
+ (when (or (equal trim-trailing-ws "false")
+ buffer-read-only)
+ ;; when false we remove every delete-trailing-whitespace
+ ;; from write-file-functions
+ (when editorconfig-trim-whitespaces-mode
+ (funcall editorconfig-trim-whitespaces-mode 0))
+ (setq
+ write-file-functions
+ (delete
+ 'delete-trailing-whitespace
+ write-file-functions))))
+
+(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))
+ (setq fill-column (string-to-number length))))
+
+(defvar editorconfig-file-type-emacs-whitelist
+ (append (mapcar 'car
+ editorconfig-indentation-alist)
+ '(conf-mode))
+ "List of known `major-mode' that can be used for file_type_emacs value.")
+
+;; Emacs<26 does not have provided-mode-derived-p
+(defun editorconfig--provided-mode-derived-p (mode &rest modes)
+ "Non-nil if MODE is derived from one of MODES.
+Uses the `derived-mode-parent' property of the symbol to trace backwards.
+If you just want to check `major-mode', use `derived-mode-p'."
+ (if (fboundp 'provided-mode-derived-p)
+ (apply 'provided-mode-derived-p mode modes)
+ (while (and (not (memq mode modes))
+ (setq mode (get mode 'derived-mode-parent))))
+ mode))
+
+
+(defun editorconfig-set-major-mode-from-name (filetype)
+ "Set buffer `major-mode' by FILETYPE.
+
+FILETYPE should be s string like `\"ini\"`, if not nil or empty string."
+ (let ((mode (and filetype
+ (not (string= filetype
+ ""))
+ (intern (concat filetype
+ "-mode")))))
+ (when mode
+ (if (fboundp mode)
+ (if (apply 'editorconfig--provided-mode-derived-p mode
+ editorconfig-file-type-emacs-whitelist)
+ (editorconfig-apply-major-mode-safely mode)
+ (display-warning :error (format "Major-mode `%S' is not listed in `%S'"
+ mode
+ 'editorconfig-file-type-emacs-whitelist)))
+ (display-warning :error (format "Major-mode `%S' not found"
+ mode))
+ nil))))
+
+(defvar editorconfig--apply-major-mode-currently nil
+ "Used internally.")
+(make-variable-buffer-local 'editorconfig--apply-major-mode-currently)
+(put 'editorconfig--apply-major-mode-currently
+ 'permanent-local
+ t)
+
+(defun editorconfig-apply-major-mode-safely (mode)
+ "Set `major-mode' to MODE.
+Normally `editorconfig-apply' will be hooked so that it runs when changing
+`major-mode', so there is a possibility that MODE is called infinitely if
+MODE is called naively from inside of `editorconfig-apply'.
+This function will avoid such cases and set `major-mode' safely.
+
+Just checking current `major-mode' value is not enough, because it can be
+different from MODE value (for example, `conf-mode' will set `major-mode' to
+`conf-unix-mode' or another conf mode)."
+ (cl-assert mode)
+ (when (and (not (eq mode
+ editorconfig--apply-major-mode-currently))
+ (not (eq mode
+ major-mode))
+ (not (derived-mode-p mode)))
+ (unwind-protect
+ (progn
+ (setq editorconfig--apply-major-mode-currently
+ mode)
+ (funcall mode))
+ (setq editorconfig--apply-major-mode-currently
+ nil))))
+
+(defun editorconfig--find-mode-from-ext (ext &optional filename)
+ "Get suitable `major-mode' from EXT and FILENAME.
+If FILENAME is omitted filename of current buffer is used."
+ (cl-assert ext)
+ (cl-assert (not (string= ext "")))
+ (let* ((name (concat (or filename
+ buffer-file-name)
+ "."
+ ext)))
+ (assoc-default name
+ auto-mode-alist
+ 'string-match)))
+
+(defun editorconfig-set-major-mode-from-ext (ext)
+ "Set buffer `major-mode' by EXT.
+
+EXT should be a string like `\"ini\"`, if not nil or empty string."
+ (cl-assert buffer-file-name)
+ (when (and ext
+ (not (string= ext ""))
+ (not (string= ext editorconfig-unset-value)))
+
+ (let ((mode (editorconfig--find-mode-from-ext ext
+ buffer-file-name)))
+ (if mode
+ (editorconfig-apply-major-mode-safely mode)
+ (display-warning :error (format "Major-mode for `%s' not found"
+ ext))
+ nil))))
+
+(defun editorconfig-call-editorconfig-exec ()
+ "Call EditorConfig core and return output."
+ (let* ((filename (buffer-file-name))
+ (filename (and filename (expand-file-name filename))))
+ (if filename
+ (with-temp-buffer
+ (setq default-directory "/")
+ (if (eq 0
+ (call-process editorconfig-exec-path nil t nil filename))
+ (buffer-string)
+ (error (buffer-string))))
+ "")))
+
+(defun editorconfig-parse-properties (props-string)
+ "Create properties hash table from PROPS-STRING."
+ (let (props-list properties)
+ (setq props-list (split-string props-string "\n")
+ properties (make-hash-table :test 'equal))
+ (dolist (prop props-list properties)
+ (let ((key-val (split-string prop " *= *")))
+ (when (> (length key-val) 1)
+ (let ((key (intern (car key-val)))
+ (val (mapconcat 'identity (cdr key-val) "")))
+ (puthash key val properties)))))))
+
+(defun editorconfig-get-properties-from-exec ()
+ "Get EditorConfig properties of current buffer.
+
+This function uses value of `editorconfig-exec-path' to get properties."
+ (if (executable-find editorconfig-exec-path)
+ (editorconfig-parse-properties (editorconfig-call-editorconfig-exec))
+ (error "Unable to find editorconfig executable")))
+
+(defun editorconfig-get-properties ()
+ "Get EditorConfig properties of current buffer.
+
+It calls `editorconfig-get-properties-from-exec' if
+`editorconfig-exec-path' is found, otherwise
+`editorconfig-core-get-properties-hash'."
+ (if (and (executable-find editorconfig-exec-path)
+ (not (file-remote-p buffer-file-name)))
+ (editorconfig-get-properties-from-exec)
+ (require 'editorconfig-core)
+ (editorconfig-core-get-properties-hash)))
+
+;;;###autoload
+(defun editorconfig-apply ()
+ "Get and apply EditorConfig properties to current buffer.
+This function ignores `editorconfig-exclude-modes' and
+`editorconfig-exclude-regexps', and always applies available 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
+ (condition-case err
+ (run-hook-with-args 'editorconfig-hack-properties-functions props)
+ (error
+ (display-warning 'editorconfig-hack-properties-functions
+ (concat (error-message-string err)
+ ". Abort running hook.")
+ :warning)))
+ (setq editorconfig-properties-hash props)
+ (editorconfig-set-indentation (gethash 'indent_style props)
+ (gethash 'indent_size props)
+ (gethash 'tab_width props))
+ (editorconfig-set-coding-system
+ (gethash 'end_of_line props)
+ (gethash 'charset props))
+ (editorconfig-set-trailing-nl (gethash 'insert_final_newline props))
+ (editorconfig-set-trailing-ws (gethash 'trim_trailing_whitespace props))
+ (editorconfig-set-line-length (gethash 'max_line_length props))
+ (editorconfig-set-major-mode-from-name (gethash 'file_type_emacs props))
+ (editorconfig-set-major-mode-from-ext (gethash 'file_type_ext props))
+ (condition-case err
+ (run-hook-with-args 'editorconfig-after-apply-functions props)
+ (error
+ (display-warning 'editorconfig-after-apply-functions
+ (concat (error-message-string err)
+ ". Stop running hook.")
+ :warning))))))
+ (error
+ (display-warning 'editorconfig
+ (concat (error-message-string err)
+ ". Styles will not be applied.")
+ :error)))))
+
+(defun editorconfig-mode-apply ()
+ "Get and apply EditorConfig properties to current buffer.
+This function does nothing when the major mode is listed in
+`editorconfig-exclude-modes', or variable `buffer-file-name' matches
+any of regexps in `editorconfig-exclude-regexps'."
+ (when (and major-mode
+ (not (memq major-mode
+ editorconfig-exclude-modes))
+ buffer-file-name
+ (not (cl-loop for regexp in editorconfig-exclude-regexps
+ if (string-match regexp buffer-file-name) return t
+ finally return nil)))
+ (editorconfig-apply)))
+
+;;;###autoload
+(define-minor-mode editorconfig-mode
+ "Toggle EditorConfig feature.
+
+To disable EditorConfig in some buffers, modify
+`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'."
+ :global t
+ :lighter editorconfig-mode-lighter
+ ;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for why
+ ;; not `after-change-major-mode-hook'
+ (dolist (hook '(change-major-mode-after-body-hook
+ read-only-mode-hook
+ ;; Some modes call `kill-all-local-variables' in their init
+ ;; code, which clears some values set by editorconfig.
+ ;; For those modes, editorconfig-apply need to be called
+ ;; explicitly through their hooks.
+ rpm-spec-mode-hook
+ ))
+ (if editorconfig-mode
+ (add-hook hook 'editorconfig-mode-apply)
+ (remove-hook hook 'editorconfig-mode-apply))))
+
+
+;; Tools
+;; Some useful commands for users, not required for EditorConfig to work
+
+;;;###autoload
+(defun editorconfig-find-current-editorconfig ()
+ "Find the closest .editorconfig file for current file."
+ (interactive)
+ (eval-and-compile (require 'editorconfig-core))
+ (let ((file (editorconfig-core-get-nearest-editorconfig
+ default-directory)))
+ (when file
+ (find-file file))))
+
+;;;###autoload
+(defun editorconfig-display-current-properties ()
+ "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))
+ (message "Properties are not applied to current buffer yet.")
+ nil))
+;;;###autoload
+(defalias 'describe-editorconfig-properties
+ 'editorconfig-display-current-properties)
+
+;;;###autoload
+(defun editorconfig-format-buffer()
+ "Format buffer according to .editorconfig indent_style and indent_width."
+ (interactive)
+ (if (string= (gethash 'indent_style editorconfig-properties-hash) "tab")
+ (tabify (point-min) (point-max)))
+ (if (string= (gethash 'indent_style editorconfig-properties-hash) "space")
+ (untabify (point-min) (point-max)))
+ (indent-region (point-min) (point-max)))
+
+
+
+;; (defconst editorconfig--version
+;; (eval-when-compile
+;; (require 'lisp-mnt)
+;; (declare-function lm-version "lisp-mnt" nil)
+;; (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.
+
+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 (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)))
+ (when show-version
+ (message "EditorConfig Emacs v%s"
+ version-full))
+ version-full))
+
+(provide 'editorconfig)
+
+;;; editorconfig.el ends here
+
+;; Local Variables:
+;; sentence-end-double-space: t
+;; End:
--- /dev/null
+This is editorconfig.info, produced by makeinfo version 6.5 from
+editorconfig.texi.
+
+INFO-DIR-SECTION Emacs
+START-INFO-DIR-ENTRY
+* EditorConfig: (editorconfig). EditorConfig Emacs Plugin.
+END-INFO-DIR-ENTRY
+
+\1f
+File: editorconfig.info, Node: Top, Next: Installation, Up: (dir)
+
+1 EditorConfig Emacs Plugin
+***************************
+
+This is an EditorConfig (https://editorconfig.org) plugin for Emacs
+(https://www.gnu.org/software/emacs/).
+* Menu:
+
+* Installation::
+* Supported properties::
+* Customize::
+* Testing::
+* Submitting Bugs and Feature Requests::
+* License::
+
+\1f
+File: editorconfig.info, Node: Installation, Next: Supported properties, Prev: Top, Up: Top
+
+1.1 Installation
+================
+
+Download the EditorConfig C Core
+(https://github.com/editorconfig/editorconfig-core-c) and follow the
+instructions in the README and INSTALL files to install it.
+
+ This plugin also has a built-in core library implemented in
+Emacs-Lisp, and fallback to it when no core executable is found.
+
+ In either case, copy '.el' files in this repository to
+'~/.emacs.d/lisp' and add the following to your '~/.emacs' file:
+
+(add-to-list 'load-path "~/.emacs.d/lisp")
+(require 'editorconfig)
+(editorconfig-mode 1)
+
+ Alternatively, you can find the package available on MELPA
+(https://melpa.org/#/editorconfig) and MELPA Stable
+(https://stable.melpa.org/#/editorconfig) (The Marmalade package
+(http://marmalade-repo.org/packages/editorconfig) is deprecated).
+
+ Or if you use *use-package*
+(https://www.emacswiki.org/emacs/UsePackage):
+
+(use-package editorconfig
+ :ensure t
+ :config
+ (editorconfig-mode 1))
+
+\1f
+File: editorconfig.info, Node: Supported properties, Next: Customize, Prev: Installation, Up: Top
+
+1.2 Supported properties
+========================
+
+Current Emacs plugin coverage for EditorConfig's properties
+(https://editorconfig.org/#supported-properties):
+
+ * 'indent_style'
+ * 'indent_size'
+ * 'tab_width'
+ * 'end_of_line'
+ * 'charset'
+ * 'trim_trailing_whitespace'
+ * 'insert_final_newline = true' is supported
+ * 'insert_final_newline = false' is not enforced (as in trailing
+ newlines actually being removed automagically), we just
+ buffer-locally override any preferences that would auto-add them to
+ files '.editorconfig' marks as trailing-newline-free
+ * 'max_line_length'
+ * 'file_type_ext' (Experimental)
+ * 'file_type_emacs' (Experimental)
+ * 'root' (only used by EditorConfig core)
+
+ Not yet covered properties marked with over-strike - pull requests
+implementing missing features warmly welcomed! Typically, you will want
+to tie these to native functionality, or the configuration of existing
+packages handling the feature.
+
+ As several packages have their own handling of, say, indentation, we
+might not yet cover some mode you use, but we try to add the ones that
+show up on our radar. Similarly, we don't yet hook in to all different
+packages for whitespace trimming to inform them about editorconfig
+settings, but aim for better coverage of things like ws-trim
+(ftp://ftp.lysator.liu.se/pub/emacs/ws-trim.el).
+* Menu:
+
+* File Type::
+
+\1f
+File: editorconfig.info, Node: File Type, Up: Supported properties
+
+1.2.1 File Type
+---------------
+
+This plugin has experimental supports for 'file_type_ext' and
+'file_type_emacs', which specify "file types" for files. As for Emacs,
+it means 'major-mode' can be set.
+
+ *file_type_ext* When it is set to 'md' for 'a.txt', for example,
+'major-mode' will be decided as if the file name would be 'a.txt.md'
+(and thus 'markdown-mode' is likely to be used).
+
+ *file_type_emacs* When it is set to 'markdown' for 'a.txt',
+'markdown-mode' will be enabled when opening 'a.txt'.
+
+ These property are experimental and their meanings might change in
+the future updates. When both are specified, 'file_type_ext' takes
+precedence.
+
+\1f
+File: editorconfig.info, Node: Customize, Next: Testing, Prev: Supported properties, Up: Top
+
+1.3 Customize
+=============
+
+* Menu:
+
+* editorconfig-after-apply-functions::
+* editorconfig-hack-properties-functions::
+* editorconfig-indentation-alist::
+* editorconfig-exec-path::
+* editorconfig-get-properties-function::
+
+\1f
+File: editorconfig.info, Node: editorconfig-after-apply-functions, Next: editorconfig-hack-properties-functions, Up: Customize
+
+1.3.1 'editorconfig-after-apply-functions'
+------------------------------------------
+
+(Formerly 'editorconfig-custom-hooks')
+
+ A list of functions after loading common EditorConfig settings, where
+you can set some custom variables or overwrite existing properties.
+
+ For example, 'web-mode' has several variables for indentation offset
+size and EditorConfig sets them at once by 'indent_size'. You may want
+to stop indenting only blocks of 'web-mode': it can be achieved by
+adding following to your init.el:
+
+(add-hook 'editorconfig-after-apply-functions
+ (lambda (hash) (setq web-mode-block-padding 0)))
+
+ You can also define your own custom properties and enable them here.
+
+\1f
+File: editorconfig.info, Node: editorconfig-hack-properties-functions, Next: editorconfig-indentation-alist, Prev: editorconfig-after-apply-functions, Up: Customize
+
+1.3.2 'editorconfig-hack-properties-functions'
+----------------------------------------------
+
+A list of function to alter property values before applying them.
+
+ These functions will be run after loading ".editorconfig" files and
+before applying them to current buffer, so that you can alter some
+properties from ".editorconfig" before they take effect.
+
+ For example, Makefiles always use tab characters for indentation: you
+can overwrite "indent_style" property when current 'major-mode' is a
+'makefile-mode' with following code:
+
+(add-hook 'editorconfig-hack-properties-functions
+ '(lambda (props)
+ (when (derived-mode-p 'makefile-mode)
+ (puthash 'indent_style "tab" props))))
+
+\1f
+File: editorconfig.info, Node: editorconfig-indentation-alist, Next: editorconfig-exec-path, Prev: editorconfig-hack-properties-functions, Up: Customize
+
+1.3.3 'editorconfig-indentation-alist'
+--------------------------------------
+
+Alist of indentation setting methods by modes.
+
+ For the easiest case to add a new support for a major-mode, you just
+need to add a pair of major-mode symbol and its indentation variables:
+
+(add-to-list 'editorconfig-indentation-alist
+ ;; Just an example, of course EditorConfig has already included this setting!
+ '(c-mode c-basic-offset))
+
+ You can also modify this variable with the command M-x
+customize-variable [RET] editorconfig-indentation-alist [RET]. For a bit
+more complicated cases please take a look at the docstring of this
+variable.
+
+\1f
+File: editorconfig.info, Node: editorconfig-exec-path, Next: editorconfig-get-properties-function, Prev: editorconfig-indentation-alist, Up: Customize
+
+1.3.4 'editorconfig-exec-path'
+------------------------------
+
+String of 'editorconfig' executable name (command name or full path to
+the executable).
+
+\1f
+File: editorconfig.info, Node: editorconfig-get-properties-function, Prev: editorconfig-exec-path, Up: Customize
+
+1.3.5 'editorconfig-get-properties-function'
+--------------------------------------------
+
+Function to use to get EditorConfig properties.
+
+ For example, if you always want to use built-in core library instead
+of any EditorConfig executable to get properties, add following to your
+init.el:
+
+(set-variable 'editorconfig-get-properties-function
+ #'editorconfig-core-get-properties-hash)
+
+ Possible known values are:
+
+ * 'editorconfig-get-properties' (default)
+ * Use 'editorconfig-get-properties-from-exec' when
+ 'editorconfig-exec-path' executable is found, otherwise use
+ 'editorconfig-core-get-properties-hash'
+
+ * 'editorconfig-get-properties-from-exec'
+ * Get properties by executing EditorConfig executable specified
+ in 'editorconfig-exec-path'
+
+ * 'editorconfig-core-get-properties-hash'
+ * Always use built-in Emacs-Lisp implementation to get
+ properties
+
+\1f
+File: editorconfig.info, Node: Testing, Next: Submitting Bugs and Feature Requests, Prev: Customize, Up: Top
+
+1.4 Testing
+===========
+
+Make and CMake (https://cmake.org) must be installed to run the tests.
+
+ To run the tests:
+
+$ make test
+
+\1f
+File: editorconfig.info, Node: Submitting Bugs and Feature Requests, Next: License, Prev: Testing, Up: Top
+
+1.5 Submitting Bugs and Feature Requests
+========================================
+
+Bugs, feature requests, and other issues should be submitted to the
+issue tracker: https://github.com/editorconfig/editorconfig-emacs/issues
+
+\1f
+File: editorconfig.info, Node: License, Prev: Submitting Bugs and Feature Requests, Up: Top
+
+1.6 License
+===========
+
+EditorConfig Emacs Plugin is free software: you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
+\1f
+Tag Table:
+Node: Top\7f208
+Ref: #editorconfig-emacs-plugin\7f337
+Node: Installation\7f575
+Ref: #installation\7f709
+Node: Supported properties\7f1613
+Ref: #supported-properties\7f1769
+Node: File Type\7f3115
+Ref: #file-type\7f3220
+Node: Customize\7f3845
+Ref: #customize\7f3974
+Node: editorconfig-after-apply-functions\7f4169
+Ref: #editorconfig-after-apply-functions\7f4389
+Node: editorconfig-hack-properties-functions\7f4988
+Ref: #editorconfig-hack-properties-functions\7f5255
+Node: editorconfig-indentation-alist\7f5881
+Ref: #editorconfig-indentation-alist\7f6120
+Node: editorconfig-exec-path\7f6675
+Ref: #editorconfig-exec-path\7f6896
+Node: editorconfig-get-properties-function\7f6985
+Ref: #editorconfig-get-properties-function\7f7195
+Node: Testing\7f8048
+Ref: #testing\7f8189
+Node: Submitting Bugs and Feature Requests\7f8296
+Ref: #submitting-bugs-and-feature-requests\7f8493
+Node: License\7f8635
+Ref: #license\7f8758
+\1f
+End Tag Table