From 23903eb63ccfb34ba595b143a19962f9c16224fa Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sat, 21 Dec 2024 17:42:57 +0100 Subject: [PATCH] update editorconfig Signed-off-by: Andreas Gerler --- elpa/edit-indirect-readme.txt | 4 - .../editorconfig-fnmatch.el | 284 ---------- .../editorconfig-pkg.el | 15 - .../dir | 0 .../editorconfig-autoloads.el | 130 ++--- .../editorconfig-conf-mode.el | 2 +- .../editorconfig-core-handle.el | 169 +++--- .../editorconfig-core.el | 4 +- .../editorconfig-fnmatch.el | 278 ++++++++++ .../editorconfig-pkg.el | 10 + .../editorconfig-tools.el | 133 +++++ .../editorconfig.el | 508 ++++++++---------- .../editorconfig.info | 2 +- elpa/editorconfig-readme.txt | 8 - .../ejc-sql-20230702.2048/ejc-autocomplete.el | 129 ----- 15 files changed, 758 insertions(+), 918 deletions(-) delete mode 100644 elpa/edit-indirect-readme.txt delete mode 100644 elpa/editorconfig-20230526.2314/editorconfig-fnmatch.el delete mode 100644 elpa/editorconfig-20230526.2314/editorconfig-pkg.el rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/dir (100%) rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig-autoloads.el (60%) rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig-conf-mode.el (98%) rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig-core-handle.el (50%) rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig-core.el (98%) create mode 100644 elpa/editorconfig-20241027.1815/editorconfig-fnmatch.el create mode 100644 elpa/editorconfig-20241027.1815/editorconfig-pkg.el create mode 100644 elpa/editorconfig-20241027.1815/editorconfig-tools.el rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig.el (68%) rename elpa/{editorconfig-20230526.2314 => editorconfig-20241027.1815}/editorconfig.info (99%) delete mode 100644 elpa/editorconfig-readme.txt delete mode 100644 elpa/ejc-sql-20230702.2048/ejc-autocomplete.el diff --git a/elpa/edit-indirect-readme.txt b/elpa/edit-indirect-readme.txt deleted file mode 100644 index a5978aca..00000000 --- a/elpa/edit-indirect-readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -Edit regions in separate buffers, like `org-edit-src-code' but for arbitrary -regions. - -See the docstring of `edit-indirect-region' for details. diff --git a/elpa/editorconfig-20230526.2314/editorconfig-fnmatch.el b/elpa/editorconfig-20230526.2314/editorconfig-fnmatch.el deleted file mode 100644 index 5432197b..00000000 --- a/elpa/editorconfig-20230526.2314/editorconfig-fnmatch.el +++ /dev/null @@ -1,284 +0,0 @@ -;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- - -;; Copyright (C) 2011-2023 EditorConfig Team - -;; Author: EditorConfig Team - -;; 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 . - -;;; 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 numeric 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 diff --git a/elpa/editorconfig-20230526.2314/editorconfig-pkg.el b/elpa/editorconfig-20230526.2314/editorconfig-pkg.el deleted file mode 100644 index e85a4690..00000000 --- a/elpa/editorconfig-20230526.2314/editorconfig-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "editorconfig" "20230526.2314" "EditorConfig Emacs Plugin" - '((emacs "26.1") - (nadvice "0.3")) - :commit "d4111f65c68f18f0dfb3072ee0d9b1d4cee80b52" :authors - '(("EditorConfig Team" . "editorconfig@googlegroups.com")) - :maintainers - '(("EditorConfig Team" . "editorconfig@googlegroups.com")) - :maintainer - '("EditorConfig Team" . "editorconfig@googlegroups.com") - :keywords - '("convenience" "editorconfig") - :url "https://github.com/editorconfig/editorconfig-emacs#readme") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/editorconfig-20230526.2314/dir b/elpa/editorconfig-20241027.1815/dir similarity index 100% rename from elpa/editorconfig-20230526.2314/dir rename to elpa/editorconfig-20241027.1815/dir diff --git a/elpa/editorconfig-20230526.2314/editorconfig-autoloads.el b/elpa/editorconfig-20241027.1815/editorconfig-autoloads.el similarity index 60% rename from elpa/editorconfig-20230526.2314/editorconfig-autoloads.el rename to elpa/editorconfig-20241027.1815/editorconfig-autoloads.el index d04e0b53..11375dc9 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig-autoloads.el +++ b/elpa/editorconfig-20241027.1815/editorconfig-autoloads.el @@ -1,21 +1,16 @@ -;;; editorconfig-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; editorconfig-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (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 does not respect the values of `editorconfig-exclude-modes' and -`editorconfig-exclude-regexps' and always applies available properties. -Use `editorconfig-mode-apply' instead to make use of these variables." t nil) - (defvar editorconfig-mode nil "\ Non-nil if Editorconfig mode is enabled. See the `editorconfig-mode' command @@ -23,78 +18,54 @@ 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. -This is a minor mode. If called interactively, toggle the -`Editorconfig mode' mode. If the prefix argument is positive, -enable the mode, and if it is zero or negative, disable the mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. - -To check whether the minor mode is enabled in the current buffer, -evaluate `(default-value \\='editorconfig-mode)'. - -The mode's hook is called both when the mode is enabled and when -it is disabled. - 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." t nil) +This is a global minor mode. If called interactively, toggle the +`Editorconfig mode' mode. If the prefix argument is positive, enable +the mode, and if it is zero or negative, disable the mode. -(autoload 'editorconfig-display-current-properties "editorconfig" "\ -Display EditorConfig properties extracted for current buffer." t nil) +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. -(defalias 'describe-editorconfig-properties 'editorconfig-display-current-properties) +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='editorconfig-mode)'. -(autoload 'editorconfig-format-buffer "editorconfig" "\ -Format buffer according to .editorconfig indent_style and indent_width." t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (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) - +(fn &optional SHOW-VERSION)" t) (register-definition-prefixes "editorconfig" '("editorconfig-")) -;;;*** -;;;### (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) - +(fn)" t) (add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode)) - (register-definition-prefixes "editorconfig-conf-mode" '("editorconfig-conf-mode-")) -;;;*** -;;;### (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) - +(fn DIRECTORY)") (autoload 'editorconfig-core-get-properties "editorconfig-core" "\ Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. @@ -104,8 +75,7 @@ If need to specify config format version, give CONFVERSION. This function returns an alist of properties. Each element will look like (KEY . VALUE). -\(fn &optional FILE CONFNAME CONFVERSION)" nil nil) - +(fn &optional FILE CONFNAME CONFVERSION)") (autoload 'editorconfig-core-get-properties-hash "editorconfig-core" "\ Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. @@ -115,54 +85,52 @@ 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) - +(fn &optional FILE CONFNAME CONFVERSION)") (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 (register-definition-prefixes "editorconfig-core-handle" '("editorconfig-core-handle")) -;;;*** -;;;### (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: +(register-definition-prefixes "editorconfig-fnmatch" '("editorconfig-fnmatch-")) -* 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 + +;;; Generated autoloads from editorconfig-tools.el -\(fn STRING PATTERN)" nil nil) +(autoload 'editorconfig-apply "editorconfig-tools" "\ +Get and apply EditorConfig properties to current buffer. -(register-definition-prefixes "editorconfig-fnmatch" '("editorconfig-fnmatch-")) +This function does not respect the values of `editorconfig-exclude-modes' and +`editorconfig-exclude-regexps' and always applies available properties. +Use `editorconfig-mode-apply' instead to make use of these variables." t) +(autoload 'editorconfig-mode-apply "editorconfig-tools" "\ +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'." t) +(autoload 'editorconfig-find-current-editorconfig "editorconfig-tools" "\ +Find the closest .editorconfig file for current file." t) +(autoload 'editorconfig-display-current-properties "editorconfig-tools" "\ +Display EditorConfig properties extracted for current buffer." t) +(defalias 'describe-editorconfig-properties #'editorconfig-display-current-properties) +(autoload 'editorconfig-format-buffer "editorconfig-tools" "\ +Format buffer according to .editorconfig indent_style and indent_width." t) -;;;### (autoloads nil nil ("editorconfig-pkg.el") (0 0 0 0)) +;;; End of scraped data + +(provide 'editorconfig-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; editorconfig-autoloads.el ends here diff --git a/elpa/editorconfig-20230526.2314/editorconfig-conf-mode.el b/elpa/editorconfig-20241027.1815/editorconfig-conf-mode.el similarity index 98% rename from elpa/editorconfig-20230526.2314/editorconfig-conf-mode.el rename to elpa/editorconfig-20241027.1815/editorconfig-conf-mode.el index e582c3f1..2b4ddd44 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig-conf-mode.el +++ b/elpa/editorconfig-20241027.1815/editorconfig-conf-mode.el @@ -1,6 +1,6 @@ ;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*- -;; Copyright (C) 2011-2023 EditorConfig Team +;; Copyright (C) 2011-2024 EditorConfig Team ;; Author: EditorConfig Team diff --git a/elpa/editorconfig-20230526.2314/editorconfig-core-handle.el b/elpa/editorconfig-20241027.1815/editorconfig-core-handle.el similarity index 50% rename from elpa/editorconfig-20230526.2314/editorconfig-core-handle.el rename to elpa/editorconfig-20241027.1815/editorconfig-core-handle.el index 2659a8be..69eb45f0 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig-core-handle.el +++ b/elpa/editorconfig-20241027.1815/editorconfig-core-handle.el @@ -1,27 +1,29 @@ ;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*- -;; Copyright (C) 2011-2023 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team +;; Package: editorconfig ;; See -;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors -;; or the CONTRIBUTORS file for the list of contributors. +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors or +;; https://github.com/editorconfig/editorconfig-emacs/blob/master/CONTRIBUTORS +;; 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. +;; 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. +;; 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 . +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -51,13 +53,14 @@ Slots: (name nil) (props nil)) -(defun editorconfig-core-handle-section-get-properties (section file dir) +(defun editorconfig-core-handle-section-get-properties (section file) "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." +FILE should be a relative file name, relative to the directory where +the `.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) + file (editorconfig-core-handle-section-name section)) (editorconfig-core-handle-section-props section))) (cl-defstruct editorconfig-core-handle @@ -74,8 +77,7 @@ Slots: Last modified time of .editorconfig file. `path' - Absolute path to .editorconfig file.' -" + Absolute path to .editorconfig file." (top-props nil) (sections nil) (mtime nil) @@ -93,12 +95,7 @@ If CONF does not exist return nil." (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)))))) + (puthash conf parsed editorconfig-core-handle--cache-hash)))))) (defun editorconfig-core-handle-root-p (handle) "Return non-nil if HANDLE represent root EditorConfig file. @@ -115,16 +112,14 @@ If HANDLE is nil return nil." The list returned will be ordered by the lines they appear. If HANDLE is nil return nil." + (declare (obsolete editorconfig-core-handle-get-properties-hash "0.8.0")) (when handle - (let ((dir (file-name-directory (editorconfig-core-handle-path handle)))) + (let* ((dir (file-name-directory (editorconfig-core-handle-path handle))) + (file (file-relative-name file dir))) (cl-loop for section in (editorconfig-core-handle-sections handle) - for props = (editorconfig-core-handle-section-get-properties section - file - dir) + for props = (editorconfig-core-handle-section-get-properties + section file) 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) @@ -132,40 +127,32 @@ If HANDLE is nil return nil." If HANDLE is nil return nil." (when handle - (let ((hash (make-hash-table)) - (dir (file-name-directory (editorconfig-core-handle-path - handle)))) + (let* ((hash (make-hash-table)) + (dir (file-name-directory (editorconfig-core-handle-path handle))) + (file (file-relative-name file dir))) (dolist (section (editorconfig-core-handle-sections handle)) - (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir) + (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file) do (puthash (intern key) value hash))) hash))) -(defun editorconfig-core-handle--fnmatch-p (name pattern dir) +(defun editorconfig-core-handle--fnmatch-p (name pattern) "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))) + (let ((pattern (replace-regexp-in-string "\\`/" "" pattern))) + (editorconfig-fnmatch-p name pattern)) + ;; The match is not "anchored" so it can be either in the current dir or + ;; in a subdir. Contrary to Zsh patterns, editorconfig's `**/foo' does + ;; not match `foo', so we need to split the problem into two matches. + (or (editorconfig-fnmatch-p name pattern) + (editorconfig-fnmatch-p name (concat "**/" pattern))))) (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. - +This function returns a `editorconfig-core-handle'. If CONF is not found return nil." (when (file-readable-p conf) (with-temp-buffer @@ -173,12 +160,9 @@ If CONF is not found return nil." ;; code conversion (insert-file-contents conf) (goto-char (point-min)) - (let ((point-max (point-max)) - (sections ()) + (let ((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 @@ -186,58 +170,49 @@ If CONF is not found return nil." ;; Current line num (current-line-number 1)) - (while (not (eq (point) point-max)) - (setq line - (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - (setq line - (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$" - "" - (editorconfig-core-handle--string-trim line))) - + (while (not (eobp)) + (skip-chars-forward " \t\f") (cond - ((string-equal "" line) + ((looking-at "\\(?:[#;].*\\)?$") 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))))))))) + ((looking-at "\\[\\(.*\\)\\][ \t]*$") + (let ((newpattern (match-string 1))) + (when pattern + (push (make-editorconfig-core-handle-section + :name pattern + :props (nreverse props)) + sections)) + (setq props nil) + (setq pattern newpattern))) + + ((looking-at "\\([^=: \t]+\\)[ \t]*[=:][ \t]*\\(.*?\\)[ \t]*$") + (let ((key (downcase (match-string 1))) + (value (match-string 2))) + (if pattern + (push `(,key . ,value) + props) + (push `(,key . ,value) + top-props)))) + + (t (error "Error while reading config file: %s:%d:\n %s\n" + conf current-line-number + (buffer-substring-no-properties (line-beginning-position) + (line-end-position))))) (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))))) + (push (make-editorconfig-core-handle-section + :name pattern + :props (nreverse props)) + sections)) + (make-editorconfig-core-handle + :top-props (nreverse top-props) + :sections (nreverse sections) + :mtime (nth 5 (file-attributes conf)) + :path conf))))) (provide 'editorconfig-core-handle) ;;; editorconfig-core-handle.el ends here diff --git a/elpa/editorconfig-20230526.2314/editorconfig-core.el b/elpa/editorconfig-20241027.1815/editorconfig-core.el similarity index 98% rename from elpa/editorconfig-20230526.2314/editorconfig-core.el rename to elpa/editorconfig-20241027.1815/editorconfig-core.el index 999af2c1..905084d0 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig-core.el +++ b/elpa/editorconfig-20241027.1815/editorconfig-core.el @@ -1,6 +1,6 @@ ;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- -;; Copyright (C) 2011-2023 EditorConfig Team +;; Copyright (C) 2011-2024 EditorConfig Team ;; Author: EditorConfig Team @@ -112,7 +112,7 @@ look like (KEY . VALUE)." (maphash (lambda (key value) (add-to-list 'result (cons (symbol-name key) value))) hash) - result)) + (sort result (lambda (x y) (string< (car x) (car y)))))) (defun editorconfig-core--hash-merge (into update) "Merge two hashes INTO and UPDATE. diff --git a/elpa/editorconfig-20241027.1815/editorconfig-fnmatch.el b/elpa/editorconfig-20241027.1815/editorconfig-fnmatch.el new file mode 100644 index 00000000..a3edfc3c --- /dev/null +++ b/elpa/editorconfig-20241027.1815/editorconfig-fnmatch.el @@ -0,0 +1,278 @@ +;;; editorconfig-fnmatch.el --- Glob pattern matching -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. + +;; Author: EditorConfig Team +;; Package: editorconfig + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors or +;; https://github.com/editorconfig/editorconfig-emacs/blob/master/CONTRIBUTORS +;; 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 GNU Emacs. If not, see . + +;;; 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 numeric 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)) + +(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, in reverse order. + (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))) + (progn + (push (regexp-quote (match-string 0 pattern)) result) + (setq index (match-end 0) + is-escaped nil)) + + (setq current-char (aref pattern index) + index (1+ index)) + + (push + (cl-case current-char + (?* + (setq pos index) + (if (and (< pos length) + (= (aref pattern pos) ?*)) + ".*" + "[^/]*")) + + (?? "[^/]") + + (?\[ + (if in-brackets + "\\[" + (if (= (aref pattern index) ?/) + ;; Slash after an half-open bracket + (progn + (setq 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 + (let ((content (substring pattern index (1+ pos)))) + (setq index (+ pos 2)) + (concat "\\[" content "\\]")) + (setq in-brackets t) + (if (and (< index length) + (memq (aref pattern index) + '(?! ?^))) + (progn + (setq index (1+ index)) + "[^") + "["))))) + + (?- (if in-brackets "-" "\\-")) + + (?\] (setq 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)) + (setq index (1+ pos)) + (if num-range + (let ((number-start (string-to-number + (match-string 1 pattern-sub))) + (number-end (string-to-number + (match-string 2 pattern-sub)))) + (regexp-opt + (mapcar #'number-to-string + (cl-loop for i from number-start to number-end + collect i)))) + (let ((inner (editorconfig-fnmatch--do-translate + pattern-sub t))) + (format "{%s}" inner)))) + (if matching-braces + (progn + (setq brace-level (1+ brace-level)) + "\\(?:") + "{"))) + + (?, + (if (and (> brace-level 0) + (not is-escaped)) + "\\|" "\\,")) + + (?\} + (if (and (> brace-level 0) + (not is-escaped)) + (progn + (setq brace-level (- brace-level 1)) + "\\)") + "}")) + + (?/ + (if (and (<= (+ index 3) (length pattern)) + (string= (substring pattern index (+ index 3)) "**/")) + (progn + (setq index (+ index 3)) + "\\(?:/\\|/.*/\\)") + "/")) + + (?\\ (when is-escaped "\\\\")) + (t (regexp-quote (char-to-string current-char)))) + result) + + (setq is-escaped (and (= current-char ?\\) (not is-escaped))))) + (unless nested + (setq result `("\\'" ,@result "\\`"))) + (apply #'concat (reverse result)))) + +(provide 'editorconfig-fnmatch) +;;; editorconfig-fnmatch.el ends here diff --git a/elpa/editorconfig-20241027.1815/editorconfig-pkg.el b/elpa/editorconfig-20241027.1815/editorconfig-pkg.el new file mode 100644 index 00000000..1d2ff3ab --- /dev/null +++ b/elpa/editorconfig-20241027.1815/editorconfig-pkg.el @@ -0,0 +1,10 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "editorconfig" "20241027.1815" + "EditorConfig Emacs Plugin." + '((emacs "26.1")) + :url "https://github.com/editorconfig/editorconfig-emacs" + :commit "24f5b2b1cd4e37adc245fb59f7edeb6872a707a4" + :revdesc "24f5b2b1cd4e" + :keywords '("convenience" "editorconfig") + :authors '(("EditorConfig Team" . "editorconfig@googlegroups.com")) + :maintainers '(("EditorConfig Team" . "editorconfig@googlegroups.com"))) diff --git a/elpa/editorconfig-20241027.1815/editorconfig-tools.el b/elpa/editorconfig-20241027.1815/editorconfig-tools.el new file mode 100644 index 00000000..16808894 --- /dev/null +++ b/elpa/editorconfig-20241027.1815/editorconfig-tools.el @@ -0,0 +1,133 @@ +;;; editorconfig-tools.el --- Editorconfig tools -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2024 EditorConfig Team + +;; Author: EditorConfig Team + +;; 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 . + +;;; Commentary: + +;; Some utility commands for users, not used from editorconfig-mode. + +;;; Code: + +(require 'cl-lib) + +(eval-when-compile + (require 'subr-x)) + + +(require 'editorconfig) + +;;;###autoload +(defun editorconfig-apply () + "Get and apply EditorConfig properties to current buffer. + +This function does not respect the values of `editorconfig-exclude-modes' and +`editorconfig-exclude-regexps' and always applies available properties. +Use `editorconfig-mode-apply' instead to make use of these variables." + (interactive) + (when buffer-file-name + (condition-case err + (progn + (let ((props (editorconfig-call-get-properties-function buffer-file-name))) + (condition-case err + (run-hook-with-args 'editorconfig-hack-properties-functions props) + (error + (display-warning '(editorconfig editorconfig-hack-properties-functions) + (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" + err) + :warning))) + (setq editorconfig-properties-hash props) + (editorconfig-set-local-variables props) + (editorconfig-set-coding-system-revert + (gethash 'end_of_line props) + (gethash 'charset props)) + (condition-case err + (run-hook-with-args 'editorconfig-after-apply-functions props) + (error + (display-warning '(editorconfig editorconfig-after-apply-functions) + (format "Error while running editorconfig-after-apply-functions, abort running hook: %S" + err) + :warning))))) + (error + (display-warning '(editorconfig editorconfig-apply) + (format "Error in editorconfig-apply, styles will not be applied: %S" err) + :error))))) + +;;;###autoload +(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'." + (interactive) + (when (and major-mode + (not (editorconfig--disabled-for-majormode major-mode)) + buffer-file-name + (not (editorconfig--disabled-for-filename buffer-file-name))) + (editorconfig-apply))) + + +;;;###autoload +(defun editorconfig-find-current-editorconfig () + "Find the closest .editorconfig file for current file." + (interactive) + (eval-and-compile (require 'editorconfig-core)) + (when-let* ((file (editorconfig-core-get-nearest-editorconfig + default-directory))) + (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) + (when (string= (gethash 'indent_style editorconfig-properties-hash) "tab") + (tabify (point-min) (point-max))) + (when (string= (gethash 'indent_style editorconfig-properties-hash) "space") + (untabify (point-min) (point-max))) + (indent-region (point-min) (point-max))) + + +(provide 'editorconfig-tools) +;;; editorconfig-tools.el ends here diff --git a/elpa/editorconfig-20230526.2314/editorconfig.el b/elpa/editorconfig-20241027.1815/editorconfig.el similarity index 68% rename from elpa/editorconfig-20230526.2314/editorconfig.el rename to elpa/editorconfig-20241027.1815/editorconfig.el index 377e9187..fb2be8e0 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig.el +++ b/elpa/editorconfig-20241027.1815/editorconfig.el @@ -1,11 +1,12 @@ ;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- -;; Copyright (C) 2011-2023 EditorConfig Team +;; Copyright (C) 2011-2024 EditorConfig Team ;; Author: EditorConfig Team -;; Version: 0.10.1 +;; Package-Version: 20241027.1815 +;; Package-Revision: 24f5b2b1cd4e ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme -;; Package-Requires: ((emacs "26.1") (nadvice "0.3")) +;; Package-Requires: ((emacs "26.1")) ;; Keywords: convenience editorconfig ;; See @@ -41,17 +42,12 @@ ;;; Code: (require 'cl-lib) -(require 'pcase) -(require 'nadvice) - -(eval-when-compile - (require 'rx) - (require 'subr-x) - (defvar tex-indent-basic) - (defvar tex-indent-item) - (defvar tex-indent-arg) - (defvar evil-shift-width)) +(eval-when-compile (require 'subr-x)) +(defvar tex-indent-basic) +(defvar tex-indent-item) +(defvar tex-indent-arg) +(defvar evil-shift-width) (require 'editorconfig-core) @@ -73,8 +69,7 @@ coding styles between different editors and IDEs." "Path to EditorConfig executable. Used by `editorconfig--execute-editorconfig-exec'." - :type 'string - :group 'editorconfig) + :type 'string) (define-obsolete-variable-alias 'edconf-get-properties-function @@ -107,13 +102,11 @@ Possible known values are: use `editorconfig-core-get-properties-hash' * `editorconfig-get-properties-from-exec' * Get properties by executing EditorConfig executable" - :type 'function - :group 'editorconfig) + :type 'function) (defcustom editorconfig-mode-lighter " EditorConfig" "Command `editorconfig-mode' lighter string." - :type 'string - :group 'editorconfig) + :type 'string) (define-obsolete-variable-alias 'edconf-custom-hooks @@ -143,8 +136,7 @@ show line numbers on the left: This hook will be run even when there are no matching sections in \".editorconfig\", or no \".editorconfig\" file was found at all." - :type 'hook - :group 'editorconfig) + :type 'hook) (defcustom editorconfig-hack-properties-functions () "A list of function to alter property values before applying them. @@ -166,8 +158,7 @@ overwrite \"indent_style\" property when current `major-mode' is a This hook will be run even when there are no matching sections in \".editorconfig\", or no \".editorconfig\" file was found at all." - :type 'hook - :group 'editorconfig) + :type 'hook) (make-obsolete-variable 'editorconfig-hack-properties-functions "Using `editorconfig-after-apply-functions' instead is recommended, because since 2021/08/30 (v0.9.0) this variable cannot support all properties: @@ -180,8 +171,12 @@ This hook will be run even when there are no matching sections in "0.5") (defcustom editorconfig-indentation-alist ;; For contributors: Sort modes in alphabetical order - '((apache-mode apache-indent-level) + '((ada-mode ada-indent) + (ada-ts-mode ada-ts-mode-indent-offset) + (apache-mode apache-indent-level) (awk-mode c-basic-offset) + (bash-ts-mode sh-basic-offset + sh-indentation) (bpftrace-mode c-basic-offset) (c++-mode c-basic-offset) (c++-ts-mode c-basic-offset @@ -201,7 +196,8 @@ This hook will be run even when there are no matching sections in (css-mode css-indent-offset) (css-ts-mode css-indent-offset) (d-mode c-basic-offset) - (emacs-lisp-mode lisp-indent-offset) + (elixir-ts-mode elixir-ts-indent-offset) + (emacs-lisp-mode . editorconfig-set-indentation-lisp-mode) (enh-ruby-mode enh-ruby-indent-level) (erlang-mode erlang-indent-level) (ess-mode ess-indent-offset) @@ -218,8 +214,11 @@ This hook will be run even when there are no matching sections in fsharp-indent-level fsharp-indent-offset) (gdscript-mode gdscript-indent-offset) - (groovy-mode groovy-indent-offset) (go-ts-mode go-ts-mode-indent-offset) + (gpr-mode gpr-indent) + (gpr-ts-mode gpr-ts-mode-indent-offset) + (graphql-mode graphql-indent-level) + (groovy-mode groovy-indent-offset) (haskell-mode haskell-indent-spaces haskell-indent-offset haskell-indentation-layout-offset @@ -229,6 +228,7 @@ This hook will be run even when there are no matching sections in haskell-indentation-where-pre-offset shm-indent-spaces) (haxor-mode haxor-tab-width) + (hcl-mode hcl-indent-level) (html-ts-mode html-ts-mode-indent-offset) (idl-mode c-basic-offset) (jade-mode jade-tab-width) @@ -243,13 +243,17 @@ This hook will be run even when there are no matching sections in (js3-mode js3-indent-level) (json-mode js-indent-level) (json-ts-mode json-ts-mode-indent-offset) + (jsonian-mode jsonian-default-indentation) (julia-mode julia-indent-offset) (kotlin-mode kotlin-tab-width) (kotlin-ts-mode kotlin-ts-mode-indent-offset) (latex-mode . editorconfig-set-indentation-latex-mode) - (lisp-mode lisp-indent-offset) + (lisp-mode . editorconfig-set-indentation-lisp-mode) (livescript-mode livescript-tab-width) (lua-mode lua-indent-level) + (lua-ts-mode lua-ts-indent-offset) + (magik-mode magik-indent-level) + (magik-ts-mode magik-indent-level) (matlab-mode matlab-indent-level) (meson-mode meson-indent-basic) (mips-mode mips-tab-width) @@ -265,7 +269,9 @@ This hook will be run even when there are no matching sections in ;; See https://github.com/editorconfig/editorconfig-emacs/issues/116 ;; for details. (php-mode c-basic-offset) + (php-ts-mode php-ts-mode-indent-offset) (pike-mode c-basic-offset) + (protobuf-mode c-basic-offset) (ps-mode ps-mode-tab) (pug-mode pug-tab-width) (puppet-mode puppet-indent-level) @@ -282,12 +288,13 @@ This hook will be run even when there are no matching sections in (scss-mode css-indent-offset) (sgml-mode sgml-basic-offset) (sh-mode sh-basic-offset sh-indentation) - (bash-ts-mode sh-basic-offset sh-indentation) (slim-mode slim-indent-offset) (sml-mode sml-indent-level) + (svelte-mode svelte-basic-offset) + (swift-mode swift-mode:basic-offset) + (terra-mode terra-indent-level) (tcl-mode tcl-indent-level tcl-continued-indent-level) - (terra-mode terra-indent-level) (toml-ts-mode toml-ts-mode-indent-offset) (typescript-mode typescript-indent-level) (typescript-ts-base-mode typescript-ts-mode-indent-offset) @@ -308,7 +315,8 @@ This hook will be run even when there are no matching sections in web-mode-script-padding web-mode-style-padding) (yaml-mode yaml-indent-offset) - (yaml-ts-mode yaml-indent-offset)) + (yaml-ts-mode yaml-indent-offset) + (zig-mode zig-indent-offset)) "Alist of indentation setting methods by modes. Each element looks like (MODE . FUNCTION) or (MODE . INDENT-SPEC-LIST). @@ -336,21 +344,18 @@ following forms: NOTE: Only the **buffer local** value of VARIABLE will be set." :type '(alist :key-type symbol :value-type sexp) - :risky t - :group 'editorconfig) + :risky t) (defcustom editorconfig-exclude-modes () "Modes in which `editorconfig-mode-apply' will not run." - :type '(repeat (symbol :tag "Major Mode")) - :group 'editorconfig) + :type '(repeat (symbol :tag "Major Mode"))) (defcustom editorconfig-exclude-regexps () "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) + :type '(repeat string)) (with-eval-after-load 'recentf (add-to-list 'editorconfig-exclude-regexps (rx-to-string '(seq string-start @@ -362,8 +367,7 @@ When variable `buffer-file-name' matches any of the regexps, then If set, enable that mode when `trim_trailing_whitespace` is set to true. Otherwise, use `delete-trailing-whitespace'." - :type 'symbol - :group 'editorconfig) + :type 'symbol) (defvar editorconfig-properties-hash nil "Hash object of EditorConfig properties that was enabled for current buffer. @@ -385,6 +389,14 @@ 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.") +(defcustom editorconfig-override-file-local-variables t + "Non-nil means editorconfig will override file local variable values." + :type 'boolean) + +(defcustom editorconfig-override-dir-local-variables t + "Non-nil means editorconfig will override values defined in dir-locals.el ." + :type 'boolean) + (define-error 'editorconfig-error "Error thrown from editorconfig lib") @@ -436,34 +448,63 @@ Make a message by passing ARGS to `format-message'." (when (boundp 'LaTeX-item-indent) (setq-local 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 - ((null 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-lisp-mode (size) + "Set indent size to SIZE for Lisp mode(s)." + (when (cond ((null 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)) + (setq-local lisp-indent-offset size))) + +(cl-defun editorconfig--should-set (symbol) + "Determine if editorconfig should set SYMBOL." + (display-warning '(editorconfig editorconfig--should-set) + (format "symbol: %S" + symbol) + :debug) + (when (and (not editorconfig-override-file-local-variables) + (assq symbol file-local-variables-alist)) + (cl-return-from editorconfig--should-set + nil)) + + (when (and (not editorconfig-override-dir-local-variables) + (assq symbol dir-local-variables-alist)) + (cl-return-from editorconfig--should-set + nil)) + + t) (defun editorconfig-set-indentation (style &optional size tab_width) "Set indentation type from STYLE, SIZE and TAB_WIDTH." - (if (editorconfig-string-integer-p size) - (setq size (string-to-number size)) - (unless (equal size "tab") (setq size nil))) - (cond (tab_width + (setq size + (cond ((editorconfig-string-integer-p size) + (string-to-number size)) + ((equal size "tab") + "tab") + (t + nil))) + + (cond ((not (editorconfig--should-set 'tab-width)) + nil) + (tab_width (setq tab-width (string-to-number tab_width))) ((numberp size) (setq tab-width size))) + (when (equal size "tab") (setq size tab-width)) - (cond ((equal style "space") + + (cond ((not (editorconfig--should-set 'indent-tabs-mode)) + nil) + ((equal style "space") (setq indent-tabs-mode nil)) ((equal style "tab") (setq indent-tabs-mode t))) + (when size - (when (featurep 'evil) + (when (and (featurep 'evil) + (editorconfig--should-set 'evil-shift-width)) (setq-local evil-shift-width size)) (let ((parent major-mode) entry) @@ -477,10 +518,10 @@ Make a message by passing ARGS to `format-message'." ((listp fn-or-list) (dolist (elem fn-or-list) (cond ((and (symbolp elem) - (editorconfig--should-set size elem)) + (editorconfig--should-set elem)) (set (make-local-variable elem) size)) ((and (consp elem) - (editorconfig--should-set size (car elem))) + (editorconfig--should-set (car elem))) (let ((spec (cdr elem))) (set (make-local-variable (car elem)) (cond ((functionp spec) (funcall spec size)) @@ -498,16 +539,16 @@ Make a message by passing ARGS to `format-message'." (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))) + ((equal end-of-line "crlf") 'undecided-dos))) (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)))) - (merge-coding-systems cs eol))) + ((equal charset "utf-16le") 'utf-16le-with-signature)))) + (if (and eol cs) + (merge-coding-systems cs eol) + (or eol cs)))) (cl-defun editorconfig-set-coding-system-revert (end-of-line charset) "Set buffer coding system by END-OF-LINE and CHARSET. @@ -523,7 +564,7 @@ This function will revert buffer when the coding-system has been changed." coding-system editorconfig--apply-coding-system-currently) :debug) - (when (eq coding-system 'undecided) + (when (memq coding-system '(nil undecided)) (cl-return-from editorconfig-set-coding-system-revert)) (when (and buffer-file-coding-system (memq buffer-file-coding-system @@ -535,7 +576,9 @@ This function will revert buffer when the coding-system has been changed." (cl-return-from editorconfig-set-coding-system-revert)) (unless (memq coding-system (coding-system-aliases editorconfig--apply-coding-system-currently)) - ;; Revert functions might call editorconfig-apply again + ;; Revert functions might call `editorconfig-apply' again + ;; FIXME: I suspect `editorconfig--apply-coding-system-currently' + ;; gymnastics is not needed now that we hook into `find-auto-coding'. (unwind-protect (progn (setq editorconfig--apply-coding-system-currently coding-system) @@ -544,6 +587,17 @@ This function will revert buffer when the coding-system has been changed." (revert-buffer-with-coding-system coding-system))) (setq editorconfig--apply-coding-system-currently nil))))) +(defun editorconfig--delete-final-newline () + "Ensure the buffer does not end with a newline. +Does nothing if the buffer is read-only." + (unless buffer-read-only + (save-excursion + (save-restriction + (widen) + (goto-char (point-max)) + (while (looking-at-p "^$") + (delete-char -1)))))) + (defun editorconfig-set-trailing-nl (final-newline) "Set up requiring final newline by FINAL-NEWLINE. @@ -553,31 +607,33 @@ to non-nil when FINAL-NEWLINE is true." ("true" ;; keep prefs around how/when the nl is added, if set - otherwise add on save (setq-local require-final-newline (or require-final-newline t)) - (setq-local mode-require-final-newline (or mode-require-final-newline t))) + (setq-local mode-require-final-newline (or mode-require-final-newline t)) + (remove-hook 'before-save-hook + #'editorconfig--delete-final-newline t)) + ("false" - ;; FIXME: Add functionality for actually REMOVING any trailing newlines here! - ;; (rather than just making sure we don't automagically ADD a new one) (setq-local require-final-newline nil) - (setq-local mode-require-final-newline nil)))) + (setq-local mode-require-final-newline nil) + (add-hook 'before-save-hook + #'editorconfig--delete-final-newline nil t)))) + +(defun editorconfig--delete-trailing-whitespace () + "Call `delete-trailing-whitespace' unless the buffer is read-only." + (unless buffer-read-only (delete-trailing-whitespace))) (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 - (remove 'delete-trailing-whitespace write-file-functions)))) + (pcase trim-trailing-ws + ("true" + (if editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 1) + (add-hook 'before-save-hook + #'editorconfig--delete-trailing-whitespace nil t))) + ("false" + (when editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 0)) + (remove-hook 'before-save-hook + #'editorconfig--delete-trailing-whitespace t)))) + (defun editorconfig-set-line-length (length) "Set the max line length (`fill-column') to LENGTH." @@ -624,7 +680,7 @@ to non-nil when FINAL-NEWLINE is true." (let ((key-val (split-string prop " *= *"))) (when (> (length key-val) 1) (let ((key (intern (car key-val))) - (val (mapconcat 'identity (cdr key-val) ""))) + (val (mapconcat #'identity (cdr key-val) ""))) (puthash key val properties))))))) (defun editorconfig-get-properties-from-exec (filename) @@ -677,54 +733,6 @@ This function also removes `unset' properties and calls (editorconfig-set-trailing-ws (gethash 'trim_trailing_whitespace props)) (editorconfig-set-line-length (gethash 'max_line_length props))) -;;;###autoload -(defun editorconfig-apply () - "Get and apply EditorConfig properties to current buffer. - -This function does not respect the values of `editorconfig-exclude-modes' and -`editorconfig-exclude-regexps' and always applies available properties. -Use `editorconfig-mode-apply' instead to make use of these variables." - (interactive) - (when buffer-file-name - (condition-case err - (progn - (let ((props (editorconfig-call-get-properties-function buffer-file-name))) - (condition-case err - (run-hook-with-args 'editorconfig-hack-properties-functions props) - (error - (display-warning '(editorconfig editorconfig-hack-properties-functions) - (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" - err) - :warning))) - (setq editorconfig-properties-hash props) - (editorconfig-set-local-variables props) - (editorconfig-set-coding-system-revert - (gethash 'end_of_line props) - (gethash 'charset props)) - (condition-case err - (run-hook-with-args 'editorconfig-after-apply-functions props) - (error - (display-warning '(editorconfig editorconfig-after-apply-functions) - (format "Error while running editorconfig-after-apply-functions, abort running hook: %S" - err) - :warning))))) - (error - (display-warning '(editorconfig editorconfig-apply) - (format "Error in editorconfig-apply, styles will not be applied: %S" err) - :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'." - (interactive) - (when (and major-mode - (not (editorconfig--disabled-for-majormode major-mode)) - buffer-file-name - (not (editorconfig--disabled-for-filename buffer-file-name))) - (editorconfig-apply))) (defun editorconfig-major-mode-hook () "Function to run when `major-mode' has been changed. @@ -750,38 +758,16 @@ This function also executes `editorconfig-after-apply-functions' functions." (format "Error while running `editorconfig-after-apply-functions': %S" err)))))) -(defvar editorconfig--cons-filename-codingsystem nil - "Used interally. - -`editorconfig--advice-find-file-noselect' will set this variable, and -`editorconfig--advice-insert-file-contents' will use this variable to set -`coding-system-for-read' value.") +;; This is a new var in Emacs≥30. +;; We dyn-bind it in our `editorconfig--advice-find-auto-coding' advice +;; to mimic the Emacs-30 behavior. +(defvar auto-coding-file-name) -(defun editorconfig--advice-insert-file-contents (f filename &rest args) - "Set `coding-system-for-read'. - -This function should be added as an advice function to `insert-file-contents'. -F is that function, and FILENAME and ARGS are arguments passed to F." - ;; This function uses `editorconfig--cons-filename-codingsystem' to decide what coding-system - ;; should be used, which will be set by `editorconfig--advice-find-file-noselect'. - (display-warning '(editorconfig editorconfig--advice-insert-file-contents) - (format "editorconfig--advice-insert-file-contents: filename: %S args: %S codingsystem: %S bufferfilename: %S" - filename args - editorconfig--cons-filename-codingsystem - buffer-file-name) - :debug) - (if (and (stringp filename) - (stringp (car editorconfig--cons-filename-codingsystem)) - (string= (expand-file-name filename) - (car editorconfig--cons-filename-codingsystem)) - (cdr editorconfig--cons-filename-codingsystem) - (not (eq (cdr editorconfig--cons-filename-codingsystem) - 'undecided))) - (let ((coding-system-for-read (cdr editorconfig--cons-filename-codingsystem)) - ;; (coding-system-for-read 'undecided) - ) - (apply f filename args)) - (apply f filename args))) +(defun editorconfig--advice-find-auto-coding (filename &rest _args) + "Consult `charset' setting of EditorConfig." + (let ((cs (let ((auto-coding-file-name filename)) + (editorconfig--get-coding-system)))) + (when cs (cons cs 'EditorConfig)))) (defun editorconfig--advice-find-file-noselect (f filename &rest args) "Get EditorConfig properties and apply them to buffer to be visited. @@ -789,44 +775,23 @@ F is that function, and FILENAME and ARGS are arguments passed to F." This function should be added as an advice function to `find-file-noselect'. F is that function, and FILENAME and ARGS are arguments passed to F." (let ((props nil) - (coding-system nil) (ret nil)) (condition-case err - (when (and (stringp filename) - (not (editorconfig--disabled-for-filename filename))) - (setq props (editorconfig-call-get-properties-function filename)) - (setq coding-system - (editorconfig-merge-coding-systems (gethash 'end_of_line props) - (gethash 'charset props)))) + (when (stringp filename) + (setq props (editorconfig-call-get-properties-function filename))) (error (display-warning '(editorconfig editorconfig--advice-find-file-noselect) (format "Failed to get properties, styles will not be applied: %S" err) :warning))) - (let ((editorconfig--cons-filename-codingsystem (cons (expand-file-name filename) - coding-system))) - (setq ret (apply f filename args))) + (setq ret (apply f filename args)) (condition-case err (with-current-buffer ret - (when (and props - ;; filename has already been checked - (not (editorconfig--disabled-for-majormode major-mode))) - (when (and (file-remote-p filename) - (not (local-variable-p 'buffer-file-coding-system)) - (not (file-exists-p filename)) - coding-system - (not (eq coding-system - 'undecided))) - ;; When file path indicates it is a remote file and it actually - ;; does not exists, `buffer-file-coding-system' will not be set. - ;; (Seems `insert-file-contents' will not be called) - ;; For that case, explicitly set this value so that saving will be done - ;; with expected coding system. - (set-buffer-file-coding-system coding-system)) - - ;; NOTE: When using editorconfig-2-mode, hack-properties-functions cannot affect coding-system value, + (when props + + ;; NOTE: hack-properties-functions cannot affect coding-system value, ;; because it has to be set before initializing buffers. (condition-case err (run-hook-with-args 'editorconfig-hack-properties-functions props) @@ -852,11 +817,22 @@ F is that function, and FILENAME and ARGS are arguments passed to F." (format "Error while setting variables from EditorConfig: %S" err)))) ret)) -(defvar editorconfig--legacy-version nil - "Use legacy version of editorconfig-mode. - -As of 2021/08/30, `editorconfig-mode' uses totally new implementation by -default. This flag disables this and go back to previous version.") +(defvar editorconfig--getting-coding-system nil) + +(defun editorconfig--get-coding-system (&optional _size) + "Return the coding system to use according to EditorConfig. +Meant to be used on `auto-coding-functions'." + (when (and (stringp auto-coding-file-name) + (file-name-absolute-p auto-coding-file-name) + ;; Don't recurse infinitely. + (not (member auto-coding-file-name + editorconfig--getting-coding-system))) + (let* ((editorconfig--getting-coding-system + (cons auto-coding-file-name editorconfig--getting-coding-system)) + (props (editorconfig-call-get-properties-function + auto-coding-file-name))) + (editorconfig-merge-coding-systems (gethash 'end_of_line props) + (gethash 'charset props))))) ;;;###autoload (define-minor-mode editorconfig-mode @@ -866,86 +842,27 @@ To disable EditorConfig in some buffers, modify `editorconfig-exclude-modes' or `editorconfig-exclude-regexps'." :global t :lighter editorconfig-mode-lighter - (if (not editorconfig--legacy-version) - (let ((modehooks '(prog-mode-hook - text-mode-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 - (progn - (advice-add 'find-file-noselect :around 'editorconfig--advice-find-file-noselect) - (advice-add 'insert-file-contents :around 'editorconfig--advice-insert-file-contents) - (dolist (hook modehooks) - (add-hook hook - 'editorconfig-major-mode-hook - t))) - (advice-remove 'find-file-noselect 'editorconfig--advice-find-file-noselect) - (advice-remove 'insert-file-contents 'editorconfig--advice-insert-file-contents) + (let ((modehooks '(prog-mode-hook + text-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 + (progn + (advice-add 'find-file-noselect :around #'editorconfig--advice-find-file-noselect) + (advice-add 'find-auto-coding :after-until + #'editorconfig--advice-find-auto-coding) (dolist (hook modehooks) - (remove-hook hook 'editorconfig-major-mode-hook)))) - - ;; editorconfig--legacy-version is enabled - ;; 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)) - (when-let* ((file (editorconfig-core-get-nearest-editorconfig - default-directory))) - (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) - (when (string= (gethash 'indent_style editorconfig-properties-hash) "tab") - (tabify (point-min) (point-max))) - (when (string= (gethash 'indent_style editorconfig-properties-hash) "space") - (untabify (point-min) (point-max))) - (indent-region (point-min) (point-max))) - + (add-hook hook + #'editorconfig-major-mode-hook + t))) + (advice-remove 'find-file-noselect #'editorconfig--advice-find-file-noselect) + (advice-remove 'find-auto-coding + #'editorconfig--advice-find-auto-coding) + (dolist (hook modehooks) + (remove-hook hook #'editorconfig-major-mode-hook))))) ;; (defconst editorconfig--version @@ -955,9 +872,6 @@ To disable EditorConfig in some buffers, modify ;; (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. @@ -965,27 +879,29 @@ To disable EditorConfig in some buffers, modify 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 (eval-and-compile (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))) + (let ((version-full + (if (fboundp 'package-get-version) ;Emacs≥27 + (package-get-version) + (let* ((version + (with-temp-buffer + (require 'find-func) + (declare-function find-library-name "find-func" (library)) + (insert-file-contents (find-library-name "editorconfig")) + (require 'lisp-mnt) + (declare-function lm-version "lisp-mnt" nil) + (lm-version))) + (pkg (and (eval-and-compile (require 'package nil t)) + (cadr (assq 'editorconfig + package-alist)))) + (pkg-version (and pkg (package-version-join + (package-desc-version pkg))))) + (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: diff --git a/elpa/editorconfig-20230526.2314/editorconfig.info b/elpa/editorconfig-20241027.1815/editorconfig.info similarity index 99% rename from elpa/editorconfig-20230526.2314/editorconfig.info rename to elpa/editorconfig-20241027.1815/editorconfig.info index bdcf25ec..20341ccc 100644 --- a/elpa/editorconfig-20230526.2314/editorconfig.info +++ b/elpa/editorconfig-20241027.1815/editorconfig.info @@ -1,4 +1,4 @@ -This is editorconfig.info, produced by makeinfo version 6.7 from +This is editorconfig.info, produced by makeinfo version 6.8 from editorconfig.texi. INFO-DIR-SECTION Emacs diff --git a/elpa/editorconfig-readme.txt b/elpa/editorconfig-readme.txt deleted file mode 100644 index 8f22acf7..00000000 --- a/elpa/editorconfig-readme.txt +++ /dev/null @@ -1,8 +0,0 @@ -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. diff --git a/elpa/ejc-sql-20230702.2048/ejc-autocomplete.el b/elpa/ejc-sql-20230702.2048/ejc-autocomplete.el deleted file mode 100644 index 208c0da1..00000000 --- a/elpa/ejc-sql-20230702.2048/ejc-autocomplete.el +++ /dev/null @@ -1,129 +0,0 @@ -;;; ejc-autocomplete.el -- SQL completitions at point by auto-complete (the part of ejc-sql). - -;;; Copyright © 2013-2020 - Kostafey - -;;; This program 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 2, 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, write to the Free Software Foundation, -;;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - -;;; Code: - -(require 'auto-complete) -(require 'ejc-completion-common) -(require 'ejc-flx) - -(defvar ac-source-ejc-owners - '((candidates . ejc-owners-candidates) - (symbol . "o") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-tables - '((candidates . ejc-tables-candidates) - (symbol . "t") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-views - '((candidates . ejc-views-candidates) - (symbol . "v") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-packages - '((candidates . ejc-packages-candidates) - (symbol . "p") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-tables-point - '((candidates . ejc-tables-candidates) - (symbol . "t") - (prefix . ejc-return-point) - (requires . 0) - (cache . t))) - -(defvar ac-source-ejc-colomns - '((candidates . ejc-colomns-candidates) - (symbol . "c") - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-colomns-point - '((candidates . ejc-colomns-candidates) - (symbol . "c") - (prefix . ejc-return-point) - (requires . 0) - (cache . t))) - -(defvar ac-source-ejc-ansi-sql - '((candidates . ejc-get-ansi-sql-words) - (symbol . "s") - (document . ac-ejc-documentation) - (requires . 1) - (cache . t))) - -(defvar ac-source-ejc-keywords - '((candidates . ejc-get-keywords) - (symbol . "s") - (document . ac-ejc-documentation) - (requires . 1) - (cache . t))) - -;;;###autoload -(defun ejc-ac-setup () - "Add the completion sources to the front of `ac-sources'. -This affects only the current buffer. - -Check against following cases: -prefix-2.prefix-1.# -prefix-1.# -something#" - (interactive) - (add-to-list 'ac-sources 'ac-source-ejc-ansi-sql) - (add-to-list 'ac-sources 'ac-source-ejc-keywords) - (add-to-list 'ac-sources 'ac-source-ejc-owners) - (add-to-list 'ac-sources 'ac-source-ejc-tables) - (add-to-list 'ac-sources 'ac-source-ejc-views) - (add-to-list 'ac-sources 'ac-source-ejc-packages) - (add-to-list 'ac-sources 'ac-source-ejc-tables-point) - (add-to-list 'ac-sources 'ac-source-ejc-colomns) - (add-to-list 'ac-sources 'ac-source-ejc-colomns-point)) - -(defun ejc-ac-hook () - (if ejc-use-flx - (if (require 'flx-ido nil 'noerror) - (setq-local ac-match-function 'ejc-flx-match-internal) - (error (concat "Please install flx.el and flx-ido.el " - "if you use fuzzy completion")))) - (delq 'ac-source-dictionary ac-sources) - (delq 'ac-source-abbrev ac-sources) - (delq 'ac-source-words-in-same-mode-buffers ac-sources)) - -(add-hook 'ejc-sql-minor-mode-hook 'ejc-ac-hook) - -(when (require 'yasnippet nil 'noerror) - (setq yas-snippet-dirs - (nconc yas-snippet-dirs - (list (expand-file-name "snippets" - (file-name-directory - (locate-library "ejc-sql")))))) - (defun ejc-yas-downcase-key (args) - (if ejc-sql-mode - (cl-callf downcase (nth 1 args))) - args) - (advice-add 'yas--fetch :filter-args #'ejc-yas-downcase-key)) - -(provide 'ejc-autocomplete) - -;;; ejc-autocomplete.el ends here -- 2.47.3