From b054fe34056ef0ab021d9908a34e3d44a4f8c2ea Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 13 Nov 2018 11:49:33 +0100 Subject: [PATCH] update editorconfig. Signed-off-by: Andreas Gerler --- .../editorconfig-pkg.el | 6 - elpa/editorconfig-20181025.421/dir | 18 ++ .../editorconfig-autoloads.el | 40 ++- .../editorconfig-conf-mode.el | 6 +- .../editorconfig-core-handle.el | 6 +- .../editorconfig-core.el | 2 +- .../editorconfig-fnmatch.el | 113 +++---- .../editorconfig-pkg.el | 10 + .../editorconfig.el | 187 +++++++++-- .../editorconfig.info | 305 ++++++++++++++++++ 10 files changed, 572 insertions(+), 121 deletions(-) delete mode 100644 elpa/editorconfig-20171208.2036/editorconfig-pkg.el create mode 100644 elpa/editorconfig-20181025.421/dir rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig-autoloads.el (73%) rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig-conf-mode.el (95%) rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig-core-handle.el (97%) rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig-core.el (99%) rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig-fnmatch.el (75%) create mode 100644 elpa/editorconfig-20181025.421/editorconfig-pkg.el rename elpa/{editorconfig-20171208.2036 => editorconfig-20181025.421}/editorconfig.el (76%) create mode 100644 elpa/editorconfig-20181025.421/editorconfig.info diff --git a/elpa/editorconfig-20171208.2036/editorconfig-pkg.el b/elpa/editorconfig-20171208.2036/editorconfig-pkg.el deleted file mode 100644 index 8d6d033b..00000000 --- a/elpa/editorconfig-20171208.2036/editorconfig-pkg.el +++ /dev/null @@ -1,6 +0,0 @@ -(define-package "editorconfig" "20171208.2036" "EditorConfig Emacs Plugin" - '((cl-lib "0.5")) - :url "https://github.com/editorconfig/editorconfig-emacs#readme") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/editorconfig-20181025.421/dir b/elpa/editorconfig-20181025.421/dir new file mode 100644 index 00000000..37389027 --- /dev/null +++ b/elpa/editorconfig-20181025.421/dir @@ -0,0 +1,18 @@ +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. + +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" 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. diff --git a/elpa/editorconfig-20171208.2036/editorconfig-autoloads.el b/elpa/editorconfig-20181025.421/editorconfig-autoloads.el similarity index 73% rename from elpa/editorconfig-20171208.2036/editorconfig-autoloads.el rename to elpa/editorconfig-20181025.421/editorconfig-autoloads.el index 971e732d..2f4d561c 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig-autoloads.el +++ b/elpa/editorconfig-20181025.421/editorconfig-autoloads.el @@ -1,10 +1,12 @@ ;;; editorconfig-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + -;;;### (autoloads nil "editorconfig" "editorconfig.el" (23086 39336 -;;;;;; 391577 194000)) +;;;### (autoloads nil "editorconfig" "editorconfig.el" (0 0 0 0)) ;;; Generated autoloads from editorconfig.el (autoload 'editorconfig-find-current-editorconfig "editorconfig" "\ @@ -42,10 +44,12 @@ mode is not listed in `editorconfig-exclude-modes'. \(fn &optional ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig" '("editorcon"))) + ;;;*** ;;;### (autoloads nil "editorconfig-conf-mode" "editorconfig-conf-mode.el" -;;;;;; (23086 39336 387461 476000)) +;;;;;; (0 0 0 0)) ;;; Generated autoloads from editorconfig-conf-mode.el (autoload 'editorconfig-conf-mode "editorconfig-conf-mode" "\ @@ -53,12 +57,14 @@ Major mode for editing .editorconfig files. \(fn)" t nil) -(add-to-list 'auto-mode-alist '("/\\.editorconfig\\'" . editorconfig-conf-mode)) +(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"))) ;;;*** ;;;### (autoloads nil "editorconfig-core" "editorconfig-core.el" -;;;;;; (23086 39336 386085 8000)) +;;;;;; (0 0 0 0)) ;;; Generated autoloads from editorconfig-core.el (autoload 'editorconfig-core-get-nearest-editorconfig "editorconfig-core" "\ @@ -88,14 +94,24 @@ hash object instead. \(fn &optional FILE CONFNAME CONFVERSION)" nil nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-core" '("editorconfig-core-"))) + +;;;*** + +;;;### (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"))) + ;;;*** ;;;### (autoloads nil "editorconfig-fnmatch" "editorconfig-fnmatch.el" -;;;;;; (23086 39336 384577 646000)) +;;;;;; (0 0 0 0)) ;;; Generated autoloads from editorconfig-fnmatch.el (autoload 'editorconfig-fnmatch-p "editorconfig-fnmatch" "\ -Test whether NAME match PATTERN. +Test whether STRING match PATTERN. Matching ignores case if `case-fold-search' is non-nil. @@ -110,12 +126,13 @@ be used: {s1,s2,s3} Matches any of the strings given (separated by commas) {min..max} Matches any number between min and max -\(fn NAME PATTERN)" nil nil) +\(fn STRING PATTERN)" nil nil) + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "editorconfig-fnmatch" '("editorconfig-fnmatch-"))) ;;;*** -;;;### (autoloads nil nil ("editorconfig-core-handle.el" "editorconfig-pkg.el") -;;;;;; (23086 39336 393112 626000)) +;;;### (autoloads nil nil ("editorconfig-pkg.el") (0 0 0 0)) ;;;*** @@ -123,5 +140,6 @@ be used: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; editorconfig-autoloads.el ends here diff --git a/elpa/editorconfig-20171208.2036/editorconfig-conf-mode.el b/elpa/editorconfig-20181025.421/editorconfig-conf-mode.el similarity index 95% rename from elpa/editorconfig-20171208.2036/editorconfig-conf-mode.el rename to elpa/editorconfig-20181025.421/editorconfig-conf-mode.el index 5a0a7c5c..1a249d3f 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig-conf-mode.el +++ b/elpa/editorconfig-20181025.421/editorconfig-conf-mode.el @@ -46,6 +46,7 @@ '("charset" "end_of_line" "file_type_emacs" + "file_type_ext" "indent_size" "indent_style" "insert_final_newline" @@ -54,7 +55,8 @@ "tab_width" "trim_trailing_whitespace")) (key-value-list - '("true" + '("unset" + "true" "false" "lf" "cr" @@ -87,7 +89,7 @@ ;;;###autoload (add-to-list 'auto-mode-alist - '("/\\.editorconfig\\'" . editorconfig-conf-mode)) + '("\\.editorconfig\\'" . editorconfig-conf-mode)) (provide 'editorconfig-conf-mode) diff --git a/elpa/editorconfig-20171208.2036/editorconfig-core-handle.el b/elpa/editorconfig-20181025.421/editorconfig-core-handle.el similarity index 97% rename from elpa/editorconfig-20171208.2036/editorconfig-core-handle.el rename to elpa/editorconfig-20181025.421/editorconfig-core-handle.el index 72f0eacb..cb2cbb9b 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig-core-handle.el +++ b/elpa/editorconfig-20181025.421/editorconfig-core-handle.el @@ -124,10 +124,10 @@ This function is a fnmatch with a few modification for EditorConfig usage." pattern)))) (defsubst editorconfig-core-handle--string-trim (str) - "Remove leading and trailing whitespace from STR." - (replace-regexp-in-string "[ \t\n\r]+\\'" + "Remove leading and trailing whitespaces from STR." + (replace-regexp-in-string "[[:space:]]+\\'" "" - (replace-regexp-in-string "\\`[ \t\n\r]+" + (replace-regexp-in-string "\\`[[:space:]]+" "" str))) diff --git a/elpa/editorconfig-20171208.2036/editorconfig-core.el b/elpa/editorconfig-20181025.421/editorconfig-core.el similarity index 99% rename from elpa/editorconfig-20171208.2036/editorconfig-core.el rename to elpa/editorconfig-20181025.421/editorconfig-core.el index a94dbdb1..9d396f18 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig-core.el +++ b/elpa/editorconfig-20181025.421/editorconfig-core.el @@ -71,7 +71,7 @@ (defconst editorconfig-core-version - "0.7.11" + "0.7.13" "EditorConfig core version.") (defun editorconfig-core--remove-duplicate (alist) diff --git a/elpa/editorconfig-20171208.2036/editorconfig-fnmatch.el b/elpa/editorconfig-20181025.421/editorconfig-fnmatch.el similarity index 75% rename from elpa/editorconfig-20171208.2036/editorconfig-fnmatch.el rename to elpa/editorconfig-20181025.421/editorconfig-fnmatch.el index 257c2773..69a0c766 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig-fnmatch.el +++ b/elpa/editorconfig-20181025.421/editorconfig-fnmatch.el @@ -54,9 +54,12 @@ (require 'cl-lib) -(defvar editorconfig-fnmatch--cache-hash - (make-hash-table :test 'equal) +(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 @@ -82,8 +85,8 @@ num)) ;;;###autoload -(defun editorconfig-fnmatch-p (name pattern) - "Test whether NAME match PATTERN. +(defun editorconfig-fnmatch-p (string pattern) + "Test whether STRING match PATTERN. Matching ignores case if `case-fold-search' is non-nil. @@ -97,27 +100,8 @@ be used: [^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" - (let* ((translated (editorconfig-fnmatch-translate pattern)) - (re (car translated)) - (num-groups (nth 1 translated)) - (match (string-match re name)) - (num-groups-len (length num-groups)) - (pattern-matched t)) - (when match - (let (num-group matched-num-str matched-num min-num max-num) - (dotimes (index num-groups-len) - (setq num-group (nth index num-groups)) - (setq matched-num-str (match-string (1+ index) - name) - min-num (car num-group) - max-num (nth 1 num-group)) - (setq matched-num (string-to-number matched-num-str)) - (when (or (= (aref matched-num-str 0) - ?0) - (< matched-num min-num) - (< max-num matched-num)) - (setq pattern-matched nil)))) - pattern-matched))) + (string-match (editorconfig-fnmatch-translate pattern) + string)) ;;(editorconfig-fnmatch-translate "{a,{-3..3}}.js") ;;(editorconfig-fnmatch-p "1.js" "{a,{-3..3}}.js") @@ -127,11 +111,11 @@ be used: Translation result will be cached, so same translation will not be done twice." (let ((cached (gethash pattern - editorconfig-fnmatch--cache-hash))) + editorconfig-fnmatch--cache-hashtable))) (or cached (puthash pattern (editorconfig-fnmatch--do-translate pattern) - editorconfig-fnmatch--cache-hash)))) + editorconfig-fnmatch--cache-hashtable)))) (defun editorconfig-fnmatch--do-translate (pattern &optional nested) @@ -154,7 +138,6 @@ translation is found for PATTERN." (editorconfig-fnmatch--match-num editorconfig-fnmatch--right-brace-regexp pattern))) - (numeric-groups ()) current-char pos @@ -190,29 +173,33 @@ translation is found for PATTERN." (?\[ (if in-brackets (setq result `(,@result "\\[")) - (setq pos index - has-slash nil) - (while (and (< pos length) - (not (= (aref pattern pos) ?\])) - (not has-slash)) - (if (and (= (aref pattern pos) ?/) - (not (= (aref pattern (- pos 1)) ?\\))) - (setq has-slash t) - (setq pos (1+ pos)))) - (if has-slash - (setq result `(,@result ,(concat "\\[" - (substring pattern - index - (1+ pos)) - "\\]")) - index (+ pos 2)) - (if (and (< index length) - (memq (aref pattern index) - '(?! ?^))) - (setq index (1+ index) - result `(,@result "[^")) - (setq result `(,@result "["))) - (setq in-brackets t)))) + (if (= (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 @@ -245,16 +232,19 @@ translation is found for PATTERN." (setq num-range (string-match editorconfig-fnmatch--numeric-range-regexp pattern-sub)) (if num-range - (setq numeric-groups `(,@numeric-groups ,(mapcar 'string-to-number - (list (match-string 1 - pattern-sub) - (match-string 2 - pattern-sub)))) - result `(,@result "\\([+-]?[0-9]+\\)")) + (let ((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}" - (car inner))) - numeric-groups `(,@numeric-groups ,@(nth 1 inner))))) + inner))))) (setq index (1+ pos))) (if matching-braces (setq result `(,@result "\\(?:") @@ -295,10 +285,7 @@ translation is found for PATTERN." (setq is-escaped nil)))) (unless nested (setq result `("^" ,@result "\\'"))) - (list (mapconcat 'identity - result - "") - numeric-groups))) + (apply 'concat result))) (provide 'editorconfig-fnmatch) diff --git a/elpa/editorconfig-20181025.421/editorconfig-pkg.el b/elpa/editorconfig-20181025.421/editorconfig-pkg.el new file mode 100644 index 00000000..0ac19b26 --- /dev/null +++ b/elpa/editorconfig-20181025.421/editorconfig-pkg.el @@ -0,0 +1,10 @@ +(define-package "editorconfig" "20181025.421" "EditorConfig Emacs Plugin" + '((cl-lib "0.5")) + :authors + '(("EditorConfig Team" . "editorconfig@googlegroups.com")) + :maintainer + '("EditorConfig Team" . "editorconfig@googlegroups.com") + :url "https://github.com/editorconfig/editorconfig-emacs#readme") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/editorconfig-20171208.2036/editorconfig.el b/elpa/editorconfig-20181025.421/editorconfig.el similarity index 76% rename from elpa/editorconfig-20171208.2036/editorconfig.el rename to elpa/editorconfig-20181025.421/editorconfig.el index ebde354d..fef26ccc 100644 --- a/elpa/editorconfig-20171208.2036/editorconfig.el +++ b/elpa/editorconfig-20181025.421/editorconfig.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2011-2017 EditorConfig Team ;; Author: EditorConfig Team -;; Version: 0.7.11 +;; Version: 0.7.13 ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme ;; Package-Requires: ((cl-lib "0.5")) @@ -92,8 +92,8 @@ when `editorconfig-mode' is enabled." :type 'string :group 'editorconfig) -(defcustom editorconfig-custom-hooks () - "A list of custom hooks after loading common EditorConfig settings. +(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 @@ -104,7 +104,7 @@ 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-custom-hooks + (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)) @@ -113,8 +113,30 @@ show line numbers on the left: :group 'editorconfig) (define-obsolete-variable-alias 'edconf-custom-hooks - 'editorconfig-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, please :) @@ -126,6 +148,7 @@ show line numbers on the left: (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) (erlang-mode erlang-indent-level) @@ -260,6 +283,19 @@ Set by `editorconfig-apply' and nil if that is not invoked in current buffer yet.") (make-variable-buffer-local 'editorconfig-properties-hash) +(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 used to unset properties in .editorconfig .") (defun editorconfig-string-integer-p (string) "Return non-nil if STRING represents integer." @@ -291,6 +327,19 @@ current buffer yet.") (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) @@ -321,8 +370,11 @@ current buffer yet.") (cond ((functionp fn-or-list) (funcall fn-or-list size)) ((listp fn-or-list) (dolist (elem fn-or-list) - (cond ((symbolp elem) (set (make-local-variable elem) size)) - ((consp elem) + (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)) @@ -340,8 +392,8 @@ current buffer yet.") ((equal charset "latin1") 'iso-latin-1) ((equal charset "utf-8") 'utf-8) ((equal charset "utf-8-bom") 'utf-8-with-signature) - ((equal charset "utf-16be") 'utf-16be) - ((equal charset "utf-16le") 'utf-16le) + ((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)) @@ -368,13 +420,15 @@ current buffer yet.") "Set up trimming of trailing whitespace at end of lines by TRIM-TRAILING-WS." (make-local-variable 'write-file-functions) ;; just current buffer - (when (equal trim-trailing-ws "true") + (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)) - (when (equal trim-trailing-ws "false") + (when (or (equal trim-trailing-ws "false") + buffer-read-only) ;; when false we remove every delete-trailing-whitespace ;; from write-file-functions (setq @@ -389,15 +443,7 @@ TRIM-TRAILING-WS." (> (string-to-number length) 0)) (setq fill-column (string-to-number length)))) -(defun editorconfig--is-a-mode-p (current want) - "Return non-nil if major mode CURRENT is a major mode WANT." - (or (eq current - want) - (let ((parent (get current 'derived-mode-parent))) - (and parent - (editorconfig--is-a-mode-p parent want))))) - -(defun editorconfig-set-major-mode (filetype) +(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." @@ -406,24 +452,86 @@ FILETYPE should be s string like `\"ini\"`, if not nil or empty string." "")) (intern (concat filetype "-mode"))))) - (when (and mode - (not (editorconfig--is-a-mode-p major-mode - mode))) + (when mode (if (fboundp mode) - (funcall mode) + (editorconig-apply-major-mode-safely mode) (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 editorconig-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 + (editorconig-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))) - (with-temp-buffer - (setq default-directory "/") - (if (eq 0 - (call-process editorconfig-exec-path nil t nil filename)) - (buffer-string) - (error (buffer-string)))))) + (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." @@ -498,6 +606,13 @@ applies available properties." (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) @@ -508,11 +623,12 @@ applies available properties." (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 (gethash 'file_type_emacs 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-custom-hooks props) + (run-hook-with-args 'editorconfig-after-apply-functions props) (error - (display-warning 'editorconfig-custom-hooks + (display-warning 'editorconfig-after-apply-functions (concat (error-message-string err) ". Stop running hook.") :warning)))))) @@ -555,7 +671,8 @@ mode is not listed in `editorconfig-exclude-modes'." :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)) + (dolist (hook '(change-major-mode-after-body-hook + read-only-mode-hook)) (if editorconfig-mode (add-hook hook 'editorconfig-mode-apply) (remove-hook hook 'editorconfig-mode-apply)))) diff --git a/elpa/editorconfig-20181025.421/editorconfig.info b/elpa/editorconfig-20181025.421/editorconfig.info new file mode 100644 index 00000000..c1a009b2 --- /dev/null +++ b/elpa/editorconfig-20181025.421/editorconfig.info @@ -0,0 +1,305 @@ +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 + + +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:: + + +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)) + + +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:: + + +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. + + +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:: + + +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. + + +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)))) + + +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. + + +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). + + +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 + + +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 + + +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 + + +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 . + + + +Tag Table: +Node: Top208 +Ref: #editorconfig-emacs-plugin337 +Node: Installation575 +Ref: #installation709 +Node: Supported properties1613 +Ref: #supported-properties1769 +Node: File Type3113 +Ref: #file-type3218 +Node: Customize3843 +Ref: #customize3972 +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 + +End Tag Table -- 2.47.3