From fb7403fdcfc23f2076430ebc8ef60293e7df20c9 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 22 Jan 2019 15:04:33 +0100 Subject: [PATCH] Update editorconfig. Signed-off-by: Andreas Gerler --- .../dir | 0 .../editorconfig-autoloads.el | 41 ++-- .../editorconfig-conf-mode.el | 20 +- .../editorconfig-core-handle.el | 129 +++++++---- .../editorconfig-core.el | 161 +++++++------- .../editorconfig-fnmatch.el | 6 +- .../editorconfig-pkg.el | 5 +- .../editorconfig.el | 210 +++++++++++------- .../editorconfig.info | 26 +-- 9 files changed, 348 insertions(+), 250 deletions(-) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/dir (100%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-autoloads.el (88%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-conf-mode.el (90%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-core-handle.el (69%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-core.el (65%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-fnmatch.el (98%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig-pkg.el (72%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig.el (86%) rename elpa/{editorconfig-20181025.421 => editorconfig-20190118.401}/editorconfig.info (95%) diff --git a/elpa/editorconfig-20181025.421/dir b/elpa/editorconfig-20190118.401/dir similarity index 100% rename from elpa/editorconfig-20181025.421/dir rename to elpa/editorconfig-20190118.401/dir diff --git a/elpa/editorconfig-20181025.421/editorconfig-autoloads.el b/elpa/editorconfig-20190118.401/editorconfig-autoloads.el similarity index 88% rename from elpa/editorconfig-20181025.421/editorconfig-autoloads.el rename to elpa/editorconfig-20190118.401/editorconfig-autoloads.el index 2f4d561c..3409b855 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-autoloads.el +++ b/elpa/editorconfig-20190118.401/editorconfig-autoloads.el @@ -9,20 +9,10 @@ ;;;### (autoloads nil "editorconfig" "editorconfig.el" (0 0 0 0)) ;;; Generated autoloads from editorconfig.el -(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) - (autoload 'editorconfig-apply "editorconfig" "\ -Apply EditorConfig properties for current buffer. -This function ignores `editorconfig-exclude-modes' and always -applies available properties. +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) @@ -38,13 +28,30 @@ or call the function `editorconfig-mode'.") (autoload 'editorconfig-mode "editorconfig" "\ Toggle EditorConfig feature. -When enabled EditorConfig properties will be applied to buffers -when first visiting files or changing major modes if the major -mode is not listed in `editorconfig-exclude-modes'. + +To disable EditorConfig in some buffers, modify +`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'. \(fn &optional ARG)" t nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig" '("editorcon"))) +(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) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig" '("editorconfig-"))) ;;;*** diff --git a/elpa/editorconfig-20181025.421/editorconfig-conf-mode.el b/elpa/editorconfig-20190118.401/editorconfig-conf-mode.el similarity index 90% rename from elpa/editorconfig-20181025.421/editorconfig-conf-mode.el rename to elpa/editorconfig-20190118.401/editorconfig-conf-mode.el index 1a249d3f..57d2a80f 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-conf-mode.el +++ b/elpa/editorconfig-20190118.401/editorconfig-conf-mode.el @@ -1,9 +1,11 @@ -;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files +;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*- -;; Copyright (C) 2011-2017 EditorConfig Team +;; Copyright (C) 2011-2019 EditorConfig Team ;; Author: EditorConfig Team ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Version: 0.7.14 +;; Package-Requires: ((emacs "24")) ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors @@ -74,16 +76,18 @@ ;; Highlight all key values (dolist (key-value key-value-list) - (add-to-list - 'font-lock-value + (push `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value) - 1 font-lock-constant-face))) + 1 font-lock-constant-face) + font-lock-value + )) ;; Highlight all key properties (dolist (key-property key-property-list) - (add-to-list - 'font-lock-value + (push `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property) - 1 font-lock-builtin-face))) + 1 font-lock-builtin-face) + font-lock-value + )) (conf-mode-initialize "#" font-lock-value))) diff --git a/elpa/editorconfig-20181025.421/editorconfig-core-handle.el b/elpa/editorconfig-20190118.401/editorconfig-core-handle.el similarity index 69% rename from elpa/editorconfig-20181025.421/editorconfig-core-handle.el rename to elpa/editorconfig-20190118.401/editorconfig-core-handle.el index cb2cbb9b..9685cc00 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-core-handle.el +++ b/elpa/editorconfig-20190118.401/editorconfig-core-handle.el @@ -1,9 +1,11 @@ -;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File +;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*- -;; Copyright (C) 2011-2017 EditorConfig Team +;; Copyright (C) 2011-2019 EditorConfig Team ;; Author: EditorConfig Team ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Version: 0.7.14 +;; Package-Requires: ((emacs "24")) ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors @@ -26,39 +28,62 @@ ;;; Commentary: -;; Handle class for EditorConfig config file. This library is used internally -;; from editorconfig-core.el . +;; Handle structures for EditorConfig config file. This library is used +;; internally from editorconfig-core.el . ;;; Code: -(require 'editorconfig-fnmatch) - -;; For cl-defstruct (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 - ;; Alist of top propetties - ;; e.g. (("root" . "true")) - (top-prop nil) - - ;; Alist of properties - ;; Key: Section name - ;; Value: Alist of properties for each section name - ;; e.g. - ;; ( - ;; ("*" ("end_of_line" . "lf") ("indent_style" . "space")) - ;; ("Makefile" ("indent_style" . "tab")) - ;; ) - (prop nil) - - ;; e.g. (22310 59113 203882 991000) - (mtime nil) + "Structure representing an .editorconfig file. + +Slots: +`top-props' + Alist of top propetties like ((\"root\" . \"true\")) + +`sections' + List of `editorconfig-core-hadnle-section' strucure object. - ;; e.g. "/home/a/b/.editorconfig" +`mtime' + Last modified time of .editorconfig file. + +`path' + Absolute path to .editorconfig file.' +" + (top-props nil) + (sections nil) + (mtime nil) (path nil)) @@ -77,8 +102,8 @@ If CONF does not exist return nil." cached (let ((parsed (editorconfig-core-handle--parse-file conf))) (puthash conf - (make-editorconfig-core-handle :top-prop (car parsed) - :prop (cdr parsed) + (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)))))) @@ -90,7 +115,7 @@ If HANDLE is nil return nil." (when handle (string-equal "true" (downcase (or (cdr (assoc "root" - (editorconfig-core-handle-top-prop handle))) + (editorconfig-core-handle-top-props handle))) ""))))) (defun editorconfig-core-handle-get-properties (handle file) @@ -99,12 +124,29 @@ The list returned will be ordered by the lines they appear. If HANDLE is nil return nil." (when handle - (mapcar (lambda (prop) (copy-alist (cdr prop))) - (cl-remove-if-not (lambda (prop) - (editorconfig-core-handle--fnmatch-p file - (car prop) - (file-name-directory (editorconfig-core-handle-path handle)))) - (editorconfig-core-handle-prop handle))))) + (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. @@ -146,7 +188,7 @@ If CONF is not found return nil." (insert-file-contents conf) (goto-char (point-min)) (let ((point-max (point-max)) - (all-props ()) + (sections ()) (top-props nil) ;; String of current line @@ -172,11 +214,15 @@ If CONF is not found return nil." ((string-equal "" line) nil) + ;; Start of section ((string-match "^\\[\\(.*\\)\\]$" line) (when pattern - (setq all-props - `(,@all-props (,pattern . ,props))) + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props))) + (setq pattern nil) (setq props nil)) (setq pattern (match-string 1 line))) @@ -207,15 +253,16 @@ If CONF is not found return nil." ) (setq current-line-number (1+ current-line-number)) - ;; Use this code instead of goto-line for Lisp program (goto-char (point-min)) (forward-line (1- current-line-number)) ) (when pattern - (setq all-props - `(,@all-props (,pattern . ,props)))) - (cons top-props - all-props))))) + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props)))) + (list :top-props top-props + :sections sections))))) (provide 'editorconfig-core-handle) diff --git a/elpa/editorconfig-20181025.421/editorconfig-core.el b/elpa/editorconfig-20190118.401/editorconfig-core.el similarity index 65% rename from elpa/editorconfig-20181025.421/editorconfig-core.el rename to elpa/editorconfig-20190118.401/editorconfig-core.el index 9d396f18..ca19226f 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-core.el +++ b/elpa/editorconfig-20190118.401/editorconfig-core.el @@ -1,9 +1,11 @@ -;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp +;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- -;; Copyright (C) 2011-2017 EditorConfig Team +;; Copyright (C) 2011-2019 EditorConfig Team ;; Author: EditorConfig Team ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Version: 0.7.14 +;; Package-Requires: ((emacs "24")) ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors @@ -71,31 +73,9 @@ (defconst editorconfig-core-version - "0.7.13" + "0.7.14" "EditorConfig core version.") -(defun editorconfig-core--remove-duplicate (alist) - "Remove duplicated keys in ALIST. - -If same keys are found in ALIST multiple times, the latter ones take precedence. -For example, when ALIST is - - '((a 1) (b 2) (c 3) (b 4)) - -then the result will be - - '((a 1) (b 4) (c 3)) ." - (let ((result ())) - (dolist (e alist) - (let ((pair (assoc (car e) - result))) - (if pair - (setcdr pair - (cdr e)) - (setq result - `(,@result ,e))))) - result)) - (defun editorconfig-core--get-handles (dir confname &optional result) "Get list of EditorConfig handlers for DIR from CONFNAME. @@ -135,76 +115,95 @@ If need to specify config format version, give CONFVERSION. This functions returns alist of properties. Each element will look like '(KEY . VALUE) ." - (setq file (expand-file-name (or file - buffer-file-name - (error "FILE is not given and `buffer-file-name' is nil")))) + (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 (editorconfig-core--remove-duplicate - (apply 'append - (mapcar (lambda (handle) - (apply 'append - (editorconfig-core-handle-get-properties handle - file))) - (editorconfig-core--get-handles (file-name-directory file) - confname)))))) - (dolist (key '("end_of_line" "indent_style" "indent_size" - "insert_final_newline" "trim_trailing_whitespace" "charset")) - (let ((pair (assoc key - result))) - (when pair - (setcdr pair - (downcase (cdr pair)))))) + (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 ((p-indent-size (assoc "indent_size" result)) - (p-indent-style (assoc "indent_style" result))) - (when (and (not p-indent-size) - (string= (cdr p-indent-style) "tab") + (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)) - (setq result - `(,@result ("indent_size" . "tab"))))) + (puthash 'indent_size + "tab" + result))) ;; Add tab_width property - (let ((p-indent-size (assoc "indent_size" result)) - (p-tab-width (assoc "tab_width" result))) - (when (and p-indent-size - (not p-tab-width) - (not (string= (cdr p-indent-size) "tab"))) - (setq result - `(,@result ("tab_width" . ,(cdr p-indent-size)))))) + (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 ((p-indent-size (assoc "indent_size" result)) - (p-tab-width (assoc "tab_width" result))) - (when (and p-indent-size - p-tab-width - (string= (cdr p-indent-size) "tab")) - (setcdr p-indent-size (cdr p-tab-width)))) + (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)) -;;;###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." - (let ((result (editorconfig-core-get-properties file - confname - confversion)) - (hash (make-hash-table :test 'equal))) - (dolist (prop result) - (puthash (intern (car prop)) - (cdr prop) - hash)) - hash)) - (provide 'editorconfig-core) ;;; editorconfig-core.el ends here diff --git a/elpa/editorconfig-20181025.421/editorconfig-fnmatch.el b/elpa/editorconfig-20190118.401/editorconfig-fnmatch.el similarity index 98% rename from elpa/editorconfig-20181025.421/editorconfig-fnmatch.el rename to elpa/editorconfig-20190118.401/editorconfig-fnmatch.el index 69a0c766..42dbd474 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-fnmatch.el +++ b/elpa/editorconfig-20190118.401/editorconfig-fnmatch.el @@ -1,9 +1,11 @@ -;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp +;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- -;; Copyright (C) 2011-2017 EditorConfig Team +;; Copyright (C) 2011-2019 EditorConfig Team ;; Author: EditorConfig Team ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Version: 0.7.14 +;; Package-Requires: ((emacs "24")) ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors diff --git a/elpa/editorconfig-20181025.421/editorconfig-pkg.el b/elpa/editorconfig-20190118.401/editorconfig-pkg.el similarity index 72% rename from elpa/editorconfig-20181025.421/editorconfig-pkg.el rename to elpa/editorconfig-20190118.401/editorconfig-pkg.el index 0ac19b26..254a548e 100644 --- a/elpa/editorconfig-20181025.421/editorconfig-pkg.el +++ b/elpa/editorconfig-20190118.401/editorconfig-pkg.el @@ -1,5 +1,6 @@ -(define-package "editorconfig" "20181025.421" "EditorConfig Emacs Plugin" - '((cl-lib "0.5")) +(define-package "editorconfig" "20190118.401" "EditorConfig Emacs Plugin" + '((cl-lib "0.5") + (emacs "24")) :authors '(("EditorConfig Team" . "editorconfig@googlegroups.com")) :maintainer diff --git a/elpa/editorconfig-20181025.421/editorconfig.el b/elpa/editorconfig-20190118.401/editorconfig.el similarity index 86% rename from elpa/editorconfig-20181025.421/editorconfig.el rename to elpa/editorconfig-20190118.401/editorconfig.el index fef26ccc..67d4578d 100644 --- a/elpa/editorconfig-20181025.421/editorconfig.el +++ b/elpa/editorconfig-20190118.401/editorconfig.el @@ -1,11 +1,11 @@ -;;; editorconfig.el --- EditorConfig Emacs Plugin +;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- -;; Copyright (C) 2011-2017 EditorConfig Team +;; Copyright (C) 2011-2019 EditorConfig Team ;; Author: EditorConfig Team -;; Version: 0.7.13 +;; Version: 0.7.14 ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme -;; Package-Requires: ((cl-lib "0.5")) +;; Package-Requires: ((cl-lib "0.5") (emacs "24")) ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors @@ -61,9 +61,9 @@ coding styles between different editors and IDEs." (defcustom editorconfig-exec-path "editorconfig" - "EditorConfig executable name. + "Path to EditorConfig executable. -This executable is invoked by `editorconfig-call-editorconfig-exec'." +Used by `editorconfig-call-editorconfig-exec'." :type 'string :group 'editorconfig) (define-obsolete-variable-alias @@ -77,8 +77,27 @@ This executable is invoked by `editorconfig-call-editorconfig-exec'." 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. The hash object should have symbols of property -names as keys and strings of property values as values." +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 @@ -87,8 +106,7 @@ names as keys and strings of property values as values." "0.5") (defcustom editorconfig-mode-lighter " EditorConfig" - "Lighter displayed in mode line -when `editorconfig-mode' is enabled." + "`editorconfig-mode' lighter string." :type 'string :group 'editorconfig) @@ -133,13 +151,13 @@ overwrite \"indent_style\" property when current `major-mode' is a (add-hook 'editorconfig-hack-properties-functions '(lambda (props) - (when (derived-mode-p makefile-mode) + (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, please :) + ;; For contributors: Sort modes in alphabetical order '((apache-mode apache-indent-level) (awk-mode c-basic-offset) (c++-mode c-basic-offset) @@ -177,7 +195,7 @@ overwrite \"indent_style\" property when current `major-mode' is a (js3-mode js3-indent-level) (json-mode js-indent-level) (julia-mode julia-indent-offset) - (latex-mode . editorconfig-set-indentation/latex-mode) + (latex-mode . editorconfig-set-indentation-latex-mode) (lisp-mode lisp-indent-offset) (livescript-mode livescript-tab-width) (lua-mode lua-indent-level) @@ -197,7 +215,7 @@ overwrite \"indent_style\" property when current `major-mode' is a (ps-mode ps-mode-tab) (pug-mode pug-tab-width) (puppet-mode puppet-indent-level) - (python-mode . editorconfig-set-indentation/python-mode) + (python-mode . editorconfig-set-indentation-python-mode) (ruby-mode ruby-indent-level) (rust-mode rust-indent-offset) (scala-mode scala-indent:step) @@ -236,23 +254,18 @@ 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." @@ -265,20 +278,30 @@ NOTE: Only the **buffer local** value of VARIABLE will be set." "0.5") (defcustom editorconfig-exclude-modes () - "List of major mode symbols not to apply properties." + "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 buffer filename prefix regexp patterns not to apply -properties." + "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 for current buffer. + "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) @@ -295,14 +318,14 @@ number - `lisp-indent-offset' is not set only if indent_size is `lisp-indent-offset'will not be set only if indent_size is 2.") (defconst editorconfig-unset-value "unset" - "String used to unset properties in .editorconfig .") + "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) +(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) @@ -314,7 +337,7 @@ number - `lisp-indent-offset' is not set only if indent_size is (when (boundp 'py-indent-offset) (set (make-local-variable 'py-indent-offset) size))) -(defun editorconfig-set-indentation/latex-mode (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) @@ -403,8 +426,10 @@ number - `lisp-indent-offset' is not set only if indent_size is nil t)))) (defun editorconfig-set-trailing-nl (final-newline) - "Set up requiring final newline (`require-final-newline' and -`mode-require-final-newline') by 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 @@ -417,20 +442,23 @@ number - `lisp-indent-offset' is not set only if indent_size is (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." + "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 - (add-to-list - 'write-file-functions - 'delete-trailing-whitespace)) + (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 @@ -454,7 +482,7 @@ FILETYPE should be s string like `\"ini\"`, if not nil or empty string." "-mode"))))) (when mode (if (fboundp mode) - (editorconig-apply-major-mode-safely mode) + (editorconfig-apply-major-mode-safely mode) (display-warning :error (format "Major-mode `%S' not found" mode)) nil)))) @@ -466,7 +494,7 @@ FILETYPE should be s string like `\"ini\"`, if not nil or empty string." 'permanent-local t) -(defun editorconig-apply-major-mode-safely (mode) +(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 @@ -515,7 +543,7 @@ EXT should be a string like `\"ini\"`, if not nil or empty string." (let ((mode (editorconfig--find-mode-from-ext ext buffer-file-name))) (if mode - (editorconig-apply-major-mode-safely mode) + (editorconfig-apply-major-mode-safely mode) (display-warning :error (format "Major-mode for `%s' not found" ext)) nil)))) @@ -546,8 +574,9 @@ EXT should be a string like `\"ini\"`, if not nil or empty string." (puthash key val properties))))))) (defun editorconfig-get-properties-from-exec () - "Get EditorConfig properties of current buffer by calling -`editorconfig-exec-path'." + "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"))) @@ -564,40 +593,11 @@ It calls `editorconfig-get-properties-from-exec' if (require 'editorconfig-core) (editorconfig-core-get-properties-hash))) -;;;###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 (defun editorconfig-apply () - "Apply EditorConfig properties for current buffer. -This function ignores `editorconfig-exclude-modes' and always -applies available properties." + "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 @@ -639,9 +639,10 @@ applies available properties." :error))))) (defun editorconfig-mode-apply () - "Apply EditorConfig properties for current buffer. -This function does the job only when the major mode is not listed -in `editorconfig-exclude-modes'." + "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)) @@ -651,22 +652,12 @@ in `editorconfig-exclude-modes'." finally return nil))) (editorconfig-apply))) -(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))) - - ;;;###autoload (define-minor-mode editorconfig-mode "Toggle EditorConfig feature. -When enabled EditorConfig properties will be applied to buffers -when first visiting files or changing major modes if the major -mode is not listed in `editorconfig-exclude-modes'." + +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 @@ -677,6 +668,53 @@ mode is not listed in `editorconfig-exclude-modes'." (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))) + + (provide 'editorconfig) ;;; editorconfig.el ends here diff --git a/elpa/editorconfig-20181025.421/editorconfig.info b/elpa/editorconfig-20190118.401/editorconfig.info similarity index 95% rename from elpa/editorconfig-20181025.421/editorconfig.info rename to elpa/editorconfig-20190118.401/editorconfig.info index c1a009b2..431170a9 100644 --- a/elpa/editorconfig-20181025.421/editorconfig.info +++ b/elpa/editorconfig-20190118.401/editorconfig.info @@ -170,7 +170,7 @@ can overwrite "indent_style" property when current 'major-mode' is a (add-hook 'editorconfig-hack-properties-functions '(lambda (props) - (when (derived-mode-p makefile-mode) + (when (derived-mode-p 'makefile-mode) (puthash 'indent_style "tab" props))))  @@ -289,17 +289,17 @@ Node: editorconfig-after-apply-functions4167 Ref: #editorconfig-after-apply-functions4387 Node: editorconfig-hack-properties-functions4986 Ref: #editorconfig-hack-properties-functions5253 -Node: editorconfig-indentation-alist5878 -Ref: #editorconfig-indentation-alist6117 -Node: editorconfig-exec-path6672 -Ref: #editorconfig-exec-path6893 -Node: editorconfig-get-properties-function6982 -Ref: #editorconfig-get-properties-function7192 -Node: Testing8045 -Ref: #testing8186 -Node: Submitting Bugs and Feature Requests8293 -Ref: #submitting-bugs-and-feature-requests8490 -Node: License8632 -Ref: #license8755 +Node: editorconfig-indentation-alist5879 +Ref: #editorconfig-indentation-alist6118 +Node: editorconfig-exec-path6673 +Ref: #editorconfig-exec-path6894 +Node: editorconfig-get-properties-function6983 +Ref: #editorconfig-get-properties-function7193 +Node: Testing8046 +Ref: #testing8187 +Node: Submitting Bugs and Feature Requests8294 +Ref: #submitting-bugs-and-feature-requests8491 +Node: License8633 +Ref: #license8756  End Tag Table -- 2.47.3