commit 4f030834994ce06822779fe0f2c316a941ee6ea8 (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Sat Jun 22 09:01:12 2024 +0300 ; Improve documentation of EditorConfig support * doc/emacs/custom.texi (EditorConfig support): Improve wording and indexing. * doc/emacs/emacs.texi (Top): Update @detailmenu. diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 3526c586616..a385d06bb1d 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1557,25 +1557,35 @@ as Dired buffers (@pxref{Dired}). @node EditorConfig support @subsubsection Per-Directory Variables via EditorConfig @cindex EditorConfig support +@cindex directory-local variables, via EditorConfig +@cindex per-directory local variables, via EditorConfig The @uref{https://editorconfig.org/, EditorConfig standard} is an alternative to the @file{.dir-locals.el} files, which can control only a very small number of variables, but -has the advantage of being editor-neutral. Those settings are stored in -files named @file{.editorconfig}. - -If you want Emacs to obey those settings, you need to enable -the @code{editorconfig-mode} minor mode. This is usually all that is -needed: when the mode is activated, Emacs will look for @file{.editorconfig} -files whenever a file is visited, just as it does for @file{.dir-locals.el}. -When both @file{.editorconfig} and @file{.dir-locals.el} files are -found, their settings are combined, and in case of a conflict, the -setting coming from the closest file takes precedence. -If they are equally close, @file{.dir-locals.el} takes precedence. -In terms of security, those settings are subject to the same checks -as those coming from @file{.dir-locals.el} (and also honor -@code{enable-local-variables}). - +has the advantage of being editor-neutral, not specific to Emacs. Those +settings are stored in files named @file{.editorconfig}, and affect the +files in that directory and its subdirectories. + +@findex editorconfig-mode +@vindex enable-local-variables@r{, and EditorConfig settings} +If you want Emacs to obey the settings from @file{.editorconfig} files, +you need to enable the @code{editorconfig-mode} global minor mode. This +is usually all that is needed: when the mode is activated, whenever a +file is visited, Emacs will look for @file{.editorconfig} in the file's +directory and its parent directories, just as it does for +@file{.dir-locals.el}. When both @file{.editorconfig} and +@file{.dir-locals.el} files are found, their settings are combined, and +in case of a conflict, the setting coming from the file closest in the +directory hierarchy takes precedence. If they are equally close, +@file{.dir-locals.el} takes precedence. In terms of security, the +@file{.editorconfig} settings are subject to the same checks as those +coming from @file{.dir-locals.el} and from file-local variables (and +also honor @code{enable-local-variables}). @xref{Safe File Variables}. + +@cindex @code{indent_size} setting of EditorConfig +@vindex editorconfig-indent-size-vars +@vindex editorconfig-indentation-alist The @code{indent_size} setting of the EditorConfig standard does not correspond to a fixed variable in Emacs, but instead needs to set different variables depending on the major mode. Ideally all major @@ -1585,12 +1595,15 @@ effect because the major mode does not yet support it, you can customize the @code{editorconfig-indentation-alist} variable to tell Emacs which variables need to be set in that major mode. +@cindex @code{trim_trailing_whitespace} setting of EditorConfig +@vindex editorconfig-trim-whitespaces-mode +@findex delete-trailing-whitespace, and EditorConfig settings Similarly, there are several different ways to trim whitespace at the end of lines. When the EditorConfig @code{trim_trailing_whitespace} setting is used, by default @code{editorconfig-mode} simply calls -@code{delete-trailing-whitespace} every time you save your file. -If you prefer some other behavior, You can customize -@code{editorconfig-trim-whitespaces-mode} to the minor mode of +@code{delete-trailing-whitespace} (@pxref{Useless Whitespace}) every +time you save your file. If you prefer some other behavior, you can +customize @code{editorconfig-trim-whitespaces-mode} to the minor mode of your preference, such as @code{ws-butler-mode}. @node Connection Variables diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index 8246041fb95..cdc92679fcb 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi @@ -1169,6 +1169,10 @@ Local Variables in Files * Specifying File Variables:: Specifying file local variables. * Safe File Variables:: Making sure file local variables are safe. +Local Variables in Directories + +* EditorConfig support:: Per-Directory Variables via EditorConfig + Customizing Key Bindings * Keymaps:: Generalities. The global keymap. commit 60070d0d749ecd711949683108305fe50bf39d1a Author: Stefan Monnier Date: Fri Jun 21 15:54:28 2024 -0400 * doc/emacs/custom.texi (Directory Variables): Add menu diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 5dbe21f9134..3526c586616 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1550,6 +1550,10 @@ variables are handled in the same way as unsafe file-local variables do not visit a file directly but perform work within a directory, such as Dired buffers (@pxref{Dired}). +@menu +* EditorConfig support:: Per-Directory Variables via EditorConfig +@end menu + @node EditorConfig support @subsubsection Per-Directory Variables via EditorConfig @cindex EditorConfig support commit 31e3d5fe9b9ba822bcc86d444298e7cafac01d3c Author: Stefan Kangas Date: Fri Jun 21 20:04:58 2024 +0200 Fix `emacs --geometry` flag on macOS * lisp/startup.el (command-line-ns-option-alist): Fix --geometry flag on macOS. (Bug#71669) diff --git a/lisp/startup.el b/lisp/startup.el index 1ffdf52ea85..f18795ae6ac 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -260,7 +260,7 @@ and VALUE is the value which is given to that frame parameter ("--reverse-video" 0 x-handle-switch reverse t) ("--font" 1 x-handle-switch font) ("--internal-border" 1 x-handle-numeric-switch internal-border-width) - ;; ("--geometry" 1 ns-handle-geometry) + ("--geometry" 1 x-handle-geometry) ("--foreground-color" 1 x-handle-switch foreground-color) ("--background-color" 1 x-handle-switch background-color) ("--mouse-color" 1 x-handle-switch mouse-color) commit 052d2cd2582dbdd3bb4d4e68d5f4dce588ed06e2 Author: Mattias Engdegård Date: Fri Jun 21 17:20:42 2024 +0200 ; eliminate backslash duplicate in regexp * lisp/editorconfig-fnmatch.el (editorconfig-fnmatch--do-translate): Remove superfluous backslash. diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index cd040880434..397e424a6f7 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -146,7 +146,7 @@ translation is found for PATTERN." (while (< index length) (if (and (not is-escaped) - (string-match "[^]\\*?[{},/\\-]+" + (string-match "[^]\\*?[{},/-]+" ;;(string-match "[^]\\*?[{},/\\-]+" "?.a") pattern index) commit 5bc76dbc9d19b8a9f7d6fcfafb197fe398c022bd Author: Stefan Monnier Date: Fri Jun 21 10:37:55 2024 -0400 * doc/emacs/custom.texi (EditorConfig support): Add URL diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 6c33eb2019e..5dbe21f9134 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1554,7 +1554,8 @@ as Dired buffers (@pxref{Dired}). @subsubsection Per-Directory Variables via EditorConfig @cindex EditorConfig support -The EditorConfig standard is an alternative to the @file{.dir-locals.el} +The @uref{https://editorconfig.org/, EditorConfig standard} +is an alternative to the @file{.dir-locals.el} files, which can control only a very small number of variables, but has the advantage of being editor-neutral. Those settings are stored in files named @file{.editorconfig}. commit 45f6cfb89e2028a12d4849ab624f0c62d56a9300 Merge: e7123edfe7f b72826eef97 Author: Stefan Monnier Date: Fri Jun 21 10:07:09 2024 -0400 Merge remote-tracking branch 'origin/scratch/emacs-editorconfig' * doc/emacs/custom.texi (EditorConfig support): New node. * lisp/editorconfig-conf-mode.el, lisp/editorconfig-core-handle.el, * lisp/editorconfig-core.el, lisp/editorconfig-fnmatch.el, * lisp/editorconfig-tools.el, lisp/editorconfig.el: New files. commit e7123edfe7f7abc9043429dfb3f84941f83d6565 Author: Po Lu Date: Fri Jun 21 15:13:03 2024 +0800 ; * src/keyboard.c (read_char): Typo in comment. diff --git a/src/keyboard.c b/src/keyboard.c index fb4d17ea066..c75e80d2a05 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3138,7 +3138,7 @@ read_char (int commandflag, Lisp_Object map, /* Should a command call `sit-for', or another command that provides a timespec to Fread_event and co., the original event will not subsequently be entered into - this_command_keys unless Qno_record be specified below. + this_command_keys unless Qt be specified below. The same is the case in a number of other scenarios where reread is true, but if so, event recording is to be commit 0ade6348f92283e4fd0bc209f100d8fe1bb87d2a Author: Po Lu Date: Fri Jun 21 15:12:07 2024 +0800 Fix execution of tool-bar commands read within minibuffer-error-handler * src/keyboard.c (read_char): Arrange that the original event be recorded when a posn is promoted to a prefix key and an END_TIME is suppressing additions to this_command_keys. diff --git a/src/keyboard.c b/src/keyboard.c index 3551a77a9c9..fb4d17ea066 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3135,8 +3135,23 @@ read_char (int commandflag, Lisp_Object map, /* Change menu-bar to (menu-bar) as the event "position". */ POSN_SET_POSN (xevent_start (c), list1 (posn)); - also_record = c; - Vunread_command_events = Fcons (c, Vunread_command_events); + /* Should a command call `sit-for', or another command that + provides a timespec to Fread_event and co., the original + event will not subsequently be entered into + this_command_keys unless Qno_record be specified below. + + The same is the case in a number of other scenarios where + reread is true, but if so, event recording is to be + suppressed anyway. */ + + if (end_time) + Vunread_command_events = Fcons (Fcons (Qt, c), + Vunread_command_events); + else + { + also_record = c; + Vunread_command_events = Fcons (c, Vunread_command_events); + } c = posn; } } commit b72826eef971e5c0179c8b4ebca652992f33b636 (refs/remotes/origin/scratch/emacs-editorconfig) Author: Stefan Monnier Date: Wed Jun 19 22:05:36 2024 -0400 * lisp/editorconfig.el (editorconfig-version): Delete function Better use a generic command like `C-h P` or `M-x list-packages` which works uniformly for all packages. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 46b5843f99f..02186e42891 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -761,36 +761,36 @@ Meant to be used on `hack-dir-local-get-variables-functions'." ;; (lm-version)) ;; "EditorConfig version.") -;;;###autoload -(defun editorconfig-version (&optional show-version) - "Get EditorConfig version as string. - -If called interactively or if SHOW-VERSION is non-nil, show the -version in the echo area and the messages buffer." - (interactive (list t)) - (let ((version-full - (if (fboundp 'package-get-version) - (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)) +;; ;;;###autoload +;; (defun editorconfig-version (&optional show-version) +;; "Get EditorConfig version as string. +;; +;; If called interactively or if SHOW-VERSION is non-nil, show the +;; version in the echo area and the messages buffer." +;; (interactive (list t)) +;; (let ((version-full +;; (if (fboundp 'package-get-version) +;; (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 commit 8d0a7c718b4e50056645ec1cab56423f5a31ce07 Author: Stefan Monnier Date: Wed Jun 19 14:34:26 2024 -0400 Integrate feedback from Stefan Kangas and Michael Albinus * lisp/editorconfig.el, lisp/editorconfig-tools.el, lisp/editorconfig-core.el: * lisp/editorconfig-core-handle.el, lisp/editorconfig-conf-mode.el: * lisp/editorconfig-fnmatch.el: Fix the reference to CONTRIBUTORS. * doc/emacs/custom.texi (EditorConfig support): * etc/NEWS: Improve wording and markup. diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 5287a90bb71..6c33eb2019e 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1554,19 +1554,22 @@ as Dired buffers (@pxref{Dired}). @subsubsection Per-Directory Variables via EditorConfig @cindex EditorConfig support -The EditorConfig standard is an alternative to the @code{.dir-locals.el} +The EditorConfig standard is an alternative to the @file{.dir-locals.el} files, which can control only a very small number of variables, but has the advantage of being editor-neutral. Those settings are stored in -files named @code{.editorconfig}. +files named @file{.editorconfig}. If you want Emacs to obey those settings, you need to enable the @code{editorconfig-mode} minor mode. This is usually all that is -needed: when the mode is activated, Emacs will look for @code{.editorconfig} -files whenever a file is visited, just as it does for @code{.dir-locals.el}. - -When both @code{.editorconfig} and @code{.dir-locals.el} files are -encountered, the corresponding settings are combined, and in case there -is overlap, the settings coming from the nearest file take precedence. +needed: when the mode is activated, Emacs will look for @file{.editorconfig} +files whenever a file is visited, just as it does for @file{.dir-locals.el}. +When both @file{.editorconfig} and @file{.dir-locals.el} files are +found, their settings are combined, and in case of a conflict, the +setting coming from the closest file takes precedence. +If they are equally close, @file{.dir-locals.el} takes precedence. +In terms of security, those settings are subject to the same checks +as those coming from @file{.dir-locals.el} (and also honor +@code{enable-local-variables}). The @code{indent_size} setting of the EditorConfig standard does not correspond to a fixed variable in Emacs, but instead needs to set @@ -1577,7 +1580,7 @@ effect because the major mode does not yet support it, you can customize the @code{editorconfig-indentation-alist} variable to tell Emacs which variables need to be set in that major mode. -Similarly, there are several different ways to ``trim whitespace'' at +Similarly, there are several different ways to trim whitespace at the end of lines. When the EditorConfig @code{trim_trailing_whitespace} setting is used, by default @code{editorconfig-mode} simply calls @code{delete-trailing-whitespace} every time you save your file. diff --git a/etc/NEWS b/etc/NEWS index 7a5e95837cb..713bc8279bc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1965,11 +1965,11 @@ The following new XML schemas are now supported: * New Modes and Packages in Emacs 30.1 ** New package EditorConfig. -This package provides support for the EditorConfig standard that -is an editor-neutral way to provide directory local settings. +This package provides support for the EditorConfig standard, +an editor-neutral way to provide directory local (project-wide) settings. It is enabled via a new global minor mode 'editorconfig-mode' which makes Emacs obey the '.editorconfig' files. -And the package also comes with a new major mode 'editorconfig-conf-mode' +There is also a new major mode 'editorconfig-conf-mode' to edit those configuration files. +++ diff --git a/lisp/editorconfig-conf-mode.el b/lisp/editorconfig-conf-mode.el index 105ce48a9bb..3102c3d6581 100644 --- a/lisp/editorconfig-conf-mode.el +++ b/lisp/editorconfig-conf-mode.el @@ -5,8 +5,9 @@ ;; Author: EditorConfig Team ;; 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 GNU Emacs. diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el index 8857c35c62c..b8570ac5c6a 100644 --- a/lisp/editorconfig-core-handle.el +++ b/lisp/editorconfig-core-handle.el @@ -5,8 +5,9 @@ ;; Author: EditorConfig Team ;; 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 GNU Emacs. diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index 02a2b7885ec..8183ff6298c 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -1,12 +1,13 @@ -;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- +;;; editorconfig-core.el --- EditorConfig Core library -*- lexical-binding: t -*- ;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team ;; 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 GNU Emacs. diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index e614e8ef3e4..cd040880434 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -1,12 +1,13 @@ -;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- +;;; editorconfig-fnmatch.el --- Glob pattern matching -*- lexical-binding: t -*- ;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team ;; 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 GNU Emacs. diff --git a/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el index ebc6a45d7bd..512dd67f56f 100644 --- a/lisp/editorconfig-tools.el +++ b/lisp/editorconfig-tools.el @@ -5,8 +5,9 @@ ;; Author: EditorConfig Team ;; 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 GNU Emacs. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 03b949ee71d..46b5843f99f 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -9,8 +9,9 @@ ;; Keywords: convenience 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 GNU Emacs. commit 8e143a2f30068a3a017630194e550573acb31b43 Author: Stefan Monnier Date: Wed Jun 19 14:08:35 2024 -0400 (editorconfig-indentation-alist): Sync with upstream The upstream version `editorconfig-indentation-alist` is a lot more complete than what we got from the copyright-covered commits. The changes come from contributors who (may) have not signed paperwork. I have not tracked all of the corresponding commits (there are many) but from what I can tell, most of those are the sole (and "trivial") contribution of its author, and in any case there is very little creativity involved since it just lists the variables used by the corresponding mode, so I believe it's perfectly OK to include those here. Many of them would be covered by our default heuristic (which looks for vars of the form like `-basic-offset`), but it's preferable to reduce changes with upstream. * lisp/editorconfig.el (editorconfig-indentation-alist): Synchronize with upstream. Remove obsolete `sh-indentation`. (editorconfig--get-indentation-web-mode): Update based on upstream changes to `editorconfig-indentation-alist`. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index c263b744de0..03b949ee71d 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -126,53 +126,128 @@ 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) - (bash-ts-mode sh-basic-offset - sh-indentation) + '((apache-mode apache-indent-level) + (awk-mode c-basic-offset) + (bash-ts-mode sh-basic-offset) (bpftrace-mode c-basic-offset) + (c++-mode c-basic-offset) (c++-ts-mode c-basic-offset c-ts-mode-indent-offset) + (c-mode c-basic-offset) (c-ts-mode c-basic-offset c-ts-mode-indent-offset) (cmake-mode cmake-tab-width) (cmake-ts-mode cmake-tab-width cmake-ts-mode-indent-offset) + (coffee-mode coffee-tab-width) + (cperl-mode cperl-indent-level) + (crystal-mode crystal-indent-level) (csharp-mode c-basic-offset) (csharp-ts-mode c-basic-offset csharp-ts-mode-indent-offset) + (css-mode css-indent-offset) + (css-ts-mode css-indent-offset) + (d-mode c-basic-offset) + (elixir-ts-mode elixir-ts-indent-offset) (emacs-lisp-mode . editorconfig--get-indentation-lisp-mode) + (enh-ruby-mode enh-ruby-indent-level) + (erlang-mode erlang-indent-level) (ess-mode ess-indent-offset) + (f90-mode f90-associate-indent + f90-continuation-indent + f90-critical-indent + f90-do-indent + f90-if-indent + f90-program-indent + f90-type-indent) (feature-mode feature-indent-offset feature-indent-level) + (fsharp-mode fsharp-continuation-offset + fsharp-indent-level + fsharp-indent-offset) (gdscript-mode gdscript-indent-offset) (go-ts-mode go-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 + haskell-indentation-left-offset + haskell-indentation-starter-offset + haskell-indentation-where-post-offset + haskell-indentation-where-pre-offset + shm-indent-spaces) + (haxor-mode haxor-tab-width) (hcl-mode hcl-indent-level) (html-ts-mode html-ts-mode-indent-offset) + (idl-mode c-basic-offset) + (jade-mode jade-tab-width) + (java-mode c-basic-offset) (java-ts-mode c-basic-offset java-ts-mode-indent-offset) (js-mode js-indent-level) + (js-ts-mode js-indent-level) + (js-jsx-mode js-indent-level sgml-basic-offset) + (js2-mode js2-basic-offset) + (js2-jsx-mode js2-basic-offset sgml-basic-offset) + (js3-mode js3-indent-level) + (json-mode js-indent-level) + (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--get-indentation-latex-mode) (lisp-mode . editorconfig--get-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) + (mustache-mode mustache-basic-offset) + (nasm-mode nasm-basic-offset) + (nginx-mode nginx-indent-level) + (nxml-mode nxml-child-indent (nxml-attribute-indent . 2)) + (objc-mode c-basic-offset) (octave-mode octave-block-offset) + (perl-mode perl-indent-level) ;; No need to change `php-mode-coding-style' value for php-mode ;; since we run editorconfig later than it resets `c-basic-offset'. ;; See https://github.com/editorconfig/editorconfig-emacs/issues/116 ;; for details. (php-mode c-basic-offset) (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) + (python-mode . editorconfig-set-indentation-python-mode) + (python-ts-mode . editorconfig-set-indentation-python-mode) + (rjsx-mode js-indent-level sgml-basic-offset) (ruby-mode ruby-indent-level) + (ruby-ts-mode ruby-indent-level) + (rust-mode rust-indent-offset) (rust-ts-mode rust-indent-offset rust-ts-mode-indent-offset) + (rustic-mode rustic-indent-offset) + (scala-mode scala-indent:step) (scss-mode css-indent-offset) (sgml-mode sgml-basic-offset) - (sh-mode sh-indentation) + (sh-mode sh-basic-offset) + (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) (toml-ts-mode toml-ts-mode-indent-offset) + (typescript-mode typescript-indent-level) + (typescript-ts-base-mode typescript-ts-mode-indent-offset) (verilog-mode verilog-indent-level verilog-indent-level-behavioral verilog-indent-level-declaration @@ -180,6 +255,8 @@ This hook will be run even when there are no matching sections in verilog-cexp-indent verilog-case-indent) (web-mode . editorconfig--get-indentation-web-mode) + (yaml-mode yaml-indent-offset) + (yaml-ts-mode yaml-indent-offset) (zig-mode zig-indent-offset) ) "Alist of indentation setting methods by modes. @@ -235,9 +312,15 @@ Make a message by passing ARGS to `format-message'." (defun editorconfig--get-indentation-web-mode (size) `((web-mode-indent-style . 2) - (web-mode-markup-indent-offset . ,size) - (web-mode-css-indent-offset . ,size) - (web-mode-code-indent-offset . ,size))) + (web-mode-attr-indent-offset . ,size) + (web-mode-attr-value-indent-offset . ,size) + (web-mode-code-indent-offset . ,size) + (web-mode-css-indent-offset . ,size) + (web-mode-markup-indent-offset . ,size) + (web-mode-sql-indent-offset . ,size) + (web-mode-block-padding . ,size) + (web-mode-script-padding . ,size) + (web-mode-style-padding . ,size))) (defun editorconfig--get-indentation-latex-mode (size) "Vars to set `latex-mode' indent size to SIZE." commit d236b67622aa808a20b6da6e7f4eb93523acd80c Author: Stefan Monnier Date: Tue Jun 18 19:00:29 2024 -0400 Add doc for EditorConfig support Also, remove the old `editorconfig.texi` since most of it is not applicable to the (current) bundled version of the code anyway. * etc/NEWS: Add entry for EditorConfig. * doc/emacs/custom.texi (EditorConfig support): New node. diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 6bf4cbe00df..5287a90bb71 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1550,6 +1550,41 @@ variables are handled in the same way as unsafe file-local variables do not visit a file directly but perform work within a directory, such as Dired buffers (@pxref{Dired}). +@node EditorConfig support +@subsubsection Per-Directory Variables via EditorConfig +@cindex EditorConfig support + +The EditorConfig standard is an alternative to the @code{.dir-locals.el} +files, which can control only a very small number of variables, but +has the advantage of being editor-neutral. Those settings are stored in +files named @code{.editorconfig}. + +If you want Emacs to obey those settings, you need to enable +the @code{editorconfig-mode} minor mode. This is usually all that is +needed: when the mode is activated, Emacs will look for @code{.editorconfig} +files whenever a file is visited, just as it does for @code{.dir-locals.el}. + +When both @code{.editorconfig} and @code{.dir-locals.el} files are +encountered, the corresponding settings are combined, and in case there +is overlap, the settings coming from the nearest file take precedence. + +The @code{indent_size} setting of the EditorConfig standard does not +correspond to a fixed variable in Emacs, but instead needs to set +different variables depending on the major mode. Ideally all major +modes should set the corresponding @code{editorconfig-indent-size-vars}, +but if you use a major mode in which @code{indent_size} does not take +effect because the major mode does not yet support it, you can customize +the @code{editorconfig-indentation-alist} variable to tell Emacs which +variables need to be set in that major mode. + +Similarly, there are several different ways to ``trim whitespace'' at +the end of lines. When the EditorConfig @code{trim_trailing_whitespace} +setting is used, by default @code{editorconfig-mode} simply calls +@code{delete-trailing-whitespace} every time you save your file. +If you prefer some other behavior, You can customize +@code{editorconfig-trim-whitespaces-mode} to the minor mode of +your preference, such as @code{ws-butler-mode}. + @node Connection Variables @subsection Per-Connection Local Variables @cindex local variables, for all remote connections diff --git a/doc/man/editorconfig.texi b/doc/man/editorconfig.texi deleted file mode 100644 index 98bc87743a5..00000000000 --- a/doc/man/editorconfig.texi +++ /dev/null @@ -1,298 +0,0 @@ -@dircategory Emacs -@direntry -* EditorConfig: (editorconfig). EditorConfig Plugin. -@end direntry - -@node Top -@chapter EditorConfig Plugin -@anchor{#editorconfig-emacs-plugin} -This is an @uref{https://editorconfig.org,EditorConfig} plugin for -@uref{https://www.gnu.org/software/emacs/,Emacs}. - -@menu -* Getting Started:: -* Supported properties:: -* Customize:: -* Troubleshooting:: -* Submitting Bugs and Feature Requests:: -* License:: -@end menu - -@node Getting Started -@section Getting Started -@anchor{#getting-started} - -@menu -* package:: -* use-package:: -* Manual installation:: -@end menu - -@node package -@subsection package.el -@anchor{#package.el} - -This package is shipped with Emacs. More recent versions can be -installed from -@uref{http://elpa.nongnu.org/nongnu/editorconfig.html,NonGNU ELPA}. - -Install from these repositories and enable global minor-mode -@code{editorconfig-mode}: - -@verbatim -(editorconfig-mode 1) -@end verbatim - -Normally, enabling @code{editorconfig-mode} should be enough for this -plugin to work: all other configurations are optional. This mode sets up -hooks so that EditorConfig properties will be loaded and applied to the -new buffers automatically when visiting files. - -@node use-package -@subsection use-package -@anchor{#use-package} -If you use -@uref{https://www.emacswiki.org/emacs/UsePackage,@strong{use-package}}, -add the following to your @code{init.el} file: - -@verbatim -(use-package editorconfig - :ensure t - :config - (editorconfig-mode 1)) -@end verbatim - -@node Manual installation -@subsection Manual installation -@anchor{#manual-installation} -Copy all @code{.el} files in this repository to @code{~/.emacs.d/lisp} -and add the following: - -@verbatim -(add-to-list 'load-path "~/.emacs.d/lisp") -(require 'editorconfig) -(editorconfig-mode 1) -@end verbatim - -@node Supported properties -@section Supported properties -@anchor{#supported-properties} -Current Emacs plugin coverage for EditorConfig's -@uref{https://editorconfig.org/#supported-properties,properties}: - -@itemize -@item -@code{indent_style} -@item -@code{indent_size} -@item -@code{tab_width} -@item -@code{end_of_line} -@item -@code{charset} -@item -@code{trim_trailing_whitespace} -@item -@code{insert_final_newline = true} is supported -@item -@code{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 @code{.editorconfig} marks as -trailing-newline-free -@item -@code{max_line_length} -@item -@code{file_type_ext} (Experimental) -(See below) -@item -@code{file_type_emacs} (Experimental) -(See below) -@item -@code{root} (only used by EditorConfig core) -@end itemize - -Not yet covered properties marked with over-strike -- pull requests -implementing missing features warmly welcomed! Typically, you will want -to tie these to native functionality, or the configuration of existing -packages handling the feature. - -As several packages have their own handling of, say, indentation, we -might not yet cover some mode you use, but we try to add the ones that -show up on our radar. - -@menu -* File Type file_type_ext file_type_emacs:: -@end menu - -@node File Type file_type_ext file_type_emacs -@subsection File Type (file_type_ext, file_type_emacs) -@anchor{#file-type-file_type_ext-file_type_emacs} -File-type feature is currently disabled, because this package is now -undergoing big internal refactoring. For those who want this -functionality, please consider using -@uref{https://github.com/10sr/editorconfig-custom-majormode-el,editorconfig-custom-majormode}. - -@node Customize -@section Customize -@anchor{#customize} -@code{editorconfig-emacs} provides some customize variables. - -Here are some of these variables: for the full list of available -variables, type M-x customize-group [RET] editorconfig [RET]. - -@menu -* editorconfig-trim-whitespaces-mode:: -* editorconfig-after-apply-functions:: -* editorconfig-hack-properties-functions:: -@end menu - -@node editorconfig-trim-whitespaces-mode -@subsection @code{editorconfig-trim-whitespaces-mode} -@anchor{#editorconfig-trim-whitespaces-mode} -Buffer local minor-mode to use to trim trailing whitespaces. - -If set, editorconfig will enable/disable this mode in accord with -@code{trim_trailing_whitespace} property in @code{.editorconfig}. -Otherwise, use Emacs built-in @code{delete-trailing-whitespace} -function. - -One possible value is -@uref{https://github.com/lewang/ws-butler,@code{ws-butler-mode}}, with -which only lines touched get trimmed. To use it, add following to your -init.el: - -@verbatim -(setq editorconfig-trim-whitespaces-mode - 'ws-butler-mode) -@end verbatim - -@node editorconfig-after-apply-functions -@subsection @code{editorconfig-after-apply-functions} -@anchor{#editorconfig-after-apply-functions} -(Formerly @code{editorconfig-custom-hooks}) - -A list of functions which will be called after loading common -EditorConfig settings, when you can set some custom variables. - -For example, @code{web-mode} has several variables for indentation -offset size and EditorConfig sets them at once by @code{indent_size}. -You can stop indenting only blocks of @code{web-mode} by adding -following to your init.el: - -@verbatim -(add-hook 'editorconfig-after-apply-functions - (lambda (props) (setq web-mode-block-padding 0))) -@end verbatim - -@node editorconfig-hack-properties-functions -@subsection @code{editorconfig-hack-properties-functions} -@anchor{#editorconfig-hack-properties-functions} -A list of functions 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, Makefile files always use tab characters for indentation: -you can overwrite "indent_style" property when current @code{major-mode} -is @code{makefile-mode}: - -@verbatim -(add-hook 'editorconfig-hack-properties-functions - '(lambda (props) - (when (derived-mode-p 'makefile-mode) - (puthash 'indent_style "tab" props)))) -@end verbatim - -@node Troubleshooting -@section Troubleshooting -@anchor{#troubleshooting} -Enabling @code{editorconfig-mode} should be enough for normal cases. - -When EditorConfig properties are not effective for unknown reason, we -recommend first trying -@code{M-x editorconfig-display-current-properties}. - -This command will open a new buffer and display the EditorConfig -properties loaded for current buffer. You can check if EditorConfig -properties were not read for buffers at all, or they were loaded but did -not take effect for some other reasons. - -@menu -* Indentation for new major-modes:: -* Not work at all for FOO-mode!:: -@end menu - -@node Indentation for new major-modes -@subsection Indentation for new major-modes -@anchor{#indentation-for-new-major-modes} -Because most Emacs major-modes have their own indentation settings, this -plugin requires explicit support for each major-mode for -@code{indent_size} property. - -By default this plugin ships with settings for many major-modes, but, -sorry to say, it cannot be perfect. Especially it is difficult to -support brand-new major-modes. Please feel free to submit issue or -pull-request for such major-mode! - -Supported major-modes and their indentation configs are defined in the -variable @code{editorconfig-indentation-alist}. - -@node Not work at all for FOO-mode! -@subsection Not work at all for FOO-mode! -@anchor{#not-work-at-all-for-foo-mode} -Most cases properties are loaded just after visiting files when -@code{editorconfig-mode} is enabled. But it is known that there are -major-modes that this mechanism does not work for and require explicit -call of @code{editorconfig-apply}. - -Typically it will occur when the major-mode is not defined using -@code{define-derived-mode} (@code{rpm-spec-mode} is an example for -this). Please feel free to submit issues if you find such modes! - -@node Submitting Bugs and Feature Requests -@section Submitting Bugs and Feature Requests -@anchor{#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 - -@menu -* Development:: -@end menu - -@node Development -@subsection Development -@anchor{#development} -Make and @uref{https://cmake.org,CMake} must be installed to run the -tests locally: - -@verbatim -$ make check -@end verbatim - -To start a new Emacs process with current @code{*.el} and without -loading user init file, run: - -@verbatim -$ make sandbox -@end verbatim - -@node License -@section License -@anchor{#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 @url{https://www.gnu.org/licenses/}. - -@bye diff --git a/etc/NEWS b/etc/NEWS index 3b18972860f..7a5e95837cb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1964,6 +1964,14 @@ The following new XML schemas are now supported: * New Modes and Packages in Emacs 30.1 +** New package EditorConfig. +This package provides support for the EditorConfig standard that +is an editor-neutral way to provide directory local settings. +It is enabled via a new global minor mode 'editorconfig-mode' +which makes Emacs obey the '.editorconfig' files. +And the package also comes with a new major mode 'editorconfig-conf-mode' +to edit those configuration files. + +++ ** New package Track-Changes. This library is a layer of abstraction above 'before-change-functions' commit 833b500a0e788a95c189a5b2bfa95494a3a7429e Author: Stefan Monnier Date: Tue Jun 18 18:16:10 2024 -0400 editorconfig-core-handle.el: Reduce allocation in parser * lisp/editorconfig-core-handle.el (editorconfig-core-handle--parse-file): Return a `editorconfig-core-handle`. (editorconfig-core-handle): Simplify accordingly. (editorconfig-core-handle--parse-file): Push `sections` and `props` in reverse order to avoid the usual O(N²) complexity. Work directly in the buffer instead of extracting "lines" from it, so as to reduce memory allocation. Similarly, use careful regexps so we can extract trimmed strings without an explicit trim operation. Use `eobp`. (editorconfig-core-handle--string-trim): Delete function, not used any more. diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el index 38353b7deb7..8857c35c62c 100644 --- a/lisp/editorconfig-core-handle.el +++ b/lisp/editorconfig-core-handle.el @@ -93,12 +93,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. @@ -148,21 +143,10 @@ This function is a fnmatch with a few modification for EditorConfig usage." (editorconfig-fnmatch-p name pattern)) (editorconfig-fnmatch-p (file-name-nondirectory name) pattern))) -(defsubst editorconfig-core-handle--string-trim (str) - "Remove leading and trailing whitespaces from STR." - (replace-regexp-in-string "[[:space:]]+\\'" - "" - (replace-regexp-in-string "\\`[[:space:]]+" - "" - str))) - (defun editorconfig-core-handle--parse-file (conf) "Parse EditorConfig file CONF. -This function returns cons of its top properties alist and -alist of patterns and its properties alist. -The list returned will be ordered by the lines they appear. - +This function returns a `editorconfig-core-handle'. If CONF is not found return nil." (when (file-readable-p conf) (with-temp-buffer @@ -170,12 +154,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 @@ -183,58 +164,52 @@ 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))) + (when (and (< (length key) 51) + (< (length value) 256)) + (if pattern + (when (< (length pattern) 4097) ;;FIXME: 4097? + (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 commit ee309f77543ac53e407a4b3ca7001bc920099d1b Author: Stefan Monnier Date: Tue Jun 18 17:52:45 2024 -0400 editorconfig-fnmatch.el: Eliminate O(N^2) complexity * lisp/editorconfig-fnmatch.el (editorconfig-fnmatch--do-translate): Accumulate partial results in reverse order to pay a single O(N) reverse at the end instead of N times O(N) concatenations. diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index 745c3cf8a40..e614e8ef3e4 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -127,7 +127,7 @@ translation is found for PATTERN." (length (length pattern)) (brace-level 0) (in-brackets nil) - ;; List of strings of resulting regexp + ;; List of strings of resulting regexp, in reverse order. (result ()) (is-escaped nil) (matching-braces (= (editorconfig-fnmatch--match-num @@ -150,9 +150,10 @@ translation is found for PATTERN." pattern index) (eq index (match-beginning 0))) - (setq result `(,@result ,(regexp-quote (match-string 0 pattern))) - index (match-end 0) - is-escaped nil) + (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)) @@ -162,19 +163,20 @@ translation is found for PATTERN." (setq pos index) (if (and (< pos length) (= (aref pattern pos) ?*)) - (setq result `(,@result ".*")) - (setq result `(,@result "[^/]*")))) + (push ".*" result) + (push "[^/]*" result))) (?? - (setq result `(,@result "[^/]"))) + (push "[^/]" result)) (?\[ (if in-brackets - (setq result `(,@result "\\[")) + (push "\\[" result) (if (= (aref pattern index) ?/) ;; Slash after an half-open bracket - (setq result `(,@result "\\[/") - index (+ index 1)) + (progn + (push "\\[/" result) + (setq index (+ index 1))) (setq pos index has-slash nil) (while (and (< pos length) @@ -185,28 +187,31 @@ translation is found for PATTERN." (setq has-slash t) (setq pos (1+ pos)))) (if has-slash - (setq result `(,@result ,(concat "\\[" - (substring pattern - index - (1+ pos)) - "\\]")) - index (+ pos 2)) + (progn + (push (concat "\\[" + (substring pattern + index + (1+ pos)) + "\\]") + result) + (setq index (+ pos 2))) (if (and (< index length) (memq (aref pattern index) '(?! ?^))) - (setq index (1+ index) - result `(,@result "[^")) - (setq result `(,@result "["))) + (progn + (setq index (1+ index)) + (push "[^" result)) + (push "[" result)) (setq in-brackets t))))) (?- (if in-brackets - (setq result `(,@result "-")) - (setq result `(,@result "\\-")))) + (push "-" result) + (push "\\-" result))) (?\] - (setq result `(,@result "]") - in-brackets nil)) + (push "]" result) + (setq in-brackets nil)) (?{ (setq pos index @@ -232,52 +237,56 @@ translation is found for PATTERN." 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) - "\\|") - "\\)")))) + (push (concat "\\(?:" + (mapconcat #'number-to-string + (cl-loop for i from number-start to number-end + collect i) + "\\|") + "\\)") + result)) (let ((inner (editorconfig-fnmatch--do-translate pattern-sub t))) - (setq result `(,@result ,(format "{%s}" inner))))) + (push (format "{%s}" inner) result))) (setq index (1+ pos))) (if matching-braces - (setq result `(,@result "\\(?:") - brace-level (1+ brace-level)) - (setq result `(,@result "{"))))) + (progn + (push "\\(?:" result) + (setq brace-level (1+ brace-level))) + (push "{" result)))) (?, (if (and (> brace-level 0) (not is-escaped)) - (setq result `(,@result "\\|")) - (setq result `(,@result "\\,")))) + (push "\\|" result) + (push "\\," result))) (?} (if (and (> brace-level 0) (not is-escaped)) - (setq result `(,@result "\\)") - brace-level (- brace-level 1)) - (setq result `(,@result "}")))) + (progn + (push "\\)" result) + (setq brace-level (- brace-level 1))) + (push "}" result))) (?/ (if (and (<= (+ index 3) (length pattern)) (string= (substring pattern index (+ index 3)) "**/")) - (setq result `(,@result "\\(?:/\\|/.*/\\)") - index (+ index 3)) - (setq result `(,@result "/")))) + (progn + (push "\\(?:/\\|/.*/\\)" result) + (setq index (+ index 3))) + (push "/" result))) (t (unless (= current-char ?\\) - (setq result `(,@result ,(regexp-quote (char-to-string current-char))))))) + (push (regexp-quote (char-to-string current-char)) result)))) (if (= current-char ?\\) (progn (when is-escaped - (setq result `(,@result "\\\\"))) + (push "\\\\" result)) (setq is-escaped (not is-escaped))) (setq is-escaped nil)))) (unless nested - (setq result `("^" ,@result "\\'"))) - (apply #'concat result))) + (setq result `("\\'" ,@result "\\`"))) + (apply #'concat (reverse result)))) (provide 'editorconfig-fnmatch) ;;; editorconfig-fnmatch.el ends here commit 55e19499a690241828dc4fc5ce7ab6b8209fe58e Author: Stefan Monnier Date: Tue Jun 18 17:27:37 2024 -0400 editorconfig-core.el: Remove unneeded defaulting code This code risks setting `tab-width` even when it's not requested, and these rules are better handled in `editorconfig--get-indentation` in any case. * lisp/editorconfig-core.el (editorconfig-core-get-properties): Delete function, unused. (editorconfig-core-get-properties-hash): Comment out defaulting code. diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index 3dfdd5c7188..02a2b7885ec 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -43,18 +43,6 @@ ;; Functions -;; editorconfig-core-get-properties (&optional file confname confversion) - -;; Get EditorConfig properties for FILE. - -;; If FILE is not given, use currently visiting file. -;; Give CONFNAME for basename of config file other than .editorconfig. -;; If need to specify config format version, give CONFVERSION. - -;; This functions returns alist of properties. Each element will look like -;; (KEY . VALUE) . - - ;; editorconfig-core-get-properties-hash (&optional file confname confversion) ;; Get EditorConfig properties for FILE. @@ -97,21 +85,6 @@ RESULT is used internally and normally should not be used." ".editorconfig"))))) (editorconfig-core-handle-path handle))) -(defun editorconfig-core-get-properties (&optional file confname confversion) - "Get EditorConfig properties for FILE. -If FILE is not given, use currently visiting file. -Give CONFNAME for basename of config file other than .editorconfig. -If need to specify config format version, give CONFVERSION. - -This function returns an alist of properties. Each element will -look like (KEY . VALUE)." - (let ((hash (editorconfig-core-get-properties-hash file confname confversion)) - (result nil)) - (maphash (lambda (key value) - (add-to-list 'result (cons (symbol-name key) value))) - hash) - result)) - (defun editorconfig-core--hash-merge (into update) "Merge two hashes INTO and UPDATE. @@ -142,36 +115,40 @@ hash object instead." file))) ;; Downcase known boolean values + ;; FIXME: Why not do that in `editorconfig-core-handle--parse-file'? (dolist (key '( end_of_line indent_style indent_size insert_final_newline trim_trailing_whitespace charset)) (when-let* ((val (gethash key result))) (puthash key (downcase val) result))) ;; Add indent_size property - (let ((v-indent-size (gethash 'indent_size result)) - (v-indent-style (gethash 'indent_style result))) - (when (and (not v-indent-size) - (string= v-indent-style "tab") - ;; If VERSION < 0.9.0, indent_size should have no default value - (version<= "0.9.0" - confversion)) - (puthash 'indent_size - "tab" - result))) + ;; FIXME: Why? Which part of the spec requires that? + ;;(let ((v-indent-size (gethash 'indent_size result)) + ;; (v-indent-style (gethash 'indent_style result))) + ;; (when (and (not v-indent-size) + ;; (string= v-indent-style "tab") + ;; ;; If VERSION < 0.9.0, indent_size should have no default value + ;; (version<= "0.9.0" + ;; confversion)) + ;; (puthash 'indent_size + ;; "tab" + ;; result))) ;; Add tab_width property - (let ((v-indent-size (gethash 'indent_size result)) - (v-tab-width (gethash 'tab_width result))) - (when (and v-indent-size - (not v-tab-width) - (not (string= v-indent-size "tab"))) - (puthash 'tab_width v-indent-size result))) + ;; FIXME: Why? Which part of the spec requires that? + ;;(let ((v-indent-size (gethash 'indent_size result)) + ;; (v-tab-width (gethash 'tab_width result))) + ;; (when (and v-indent-size + ;; (not v-tab-width) + ;; (not (string= v-indent-size "tab"))) + ;; (puthash 'tab_width v-indent-size result))) ;; Update indent-size property - (let ((v-indent-size (gethash 'indent_size result)) - (v-tab-width (gethash 'tab_width result))) - (when (and v-indent-size - v-tab-width - (string= v-indent-size "tab")) - (puthash 'indent_size v-tab-width result))) + ;; FIXME: Why? Which part of the spec requires that? + ;;(let ((v-indent-size (gethash 'indent_size result)) + ;; (v-tab-width (gethash 'tab_width result))) + ;; (when (and v-indent-size + ;; v-tab-width + ;; (string= v-indent-size "tab")) + ;; (puthash 'indent_size v-tab-width result))) result)) commit 66d5bc292f1533b21b8fbe46291a0b4ec0b8cb53 Author: Stefan Monnier Date: Tue Jun 18 17:11:34 2024 -0400 editorconfig-core-handle.el: Don't use file names as glob pattern Match relative file names against the glob pattern instead of trying to construct a glob pattern that matches the absolute file name (where the code failed to escape the possible special chars). * lisp/editorconfig-core-handle.el (editorconfig-core-handle-section-get-properties): Delete `dir` arg. (editorconfig-core-handle-get-properties-hash) (editorconfig-core-handle-get-properties): Adjust call accordingly. Use `declare` to mark it obsolete. (editorconfig-core-handle--fnmatch-p): Delete `dir` arg. diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el index 1d7b1f61088..38353b7deb7 100644 --- a/lisp/editorconfig-core-handle.el +++ b/lisp/editorconfig-core-handle.el @@ -51,13 +51,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 @@ -114,16 +115,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,23 +131,22 @@ 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)))) + (file (file-relative-name file (editorconfig-core-handle-path + handle)))) (dolist (section (editorconfig-core-handle-sections handle)) - (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir) + (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)))) + (let ((pattern (replace-regexp-in-string "\\`/" "" pattern))) + (editorconfig-fnmatch-p name pattern)) + (editorconfig-fnmatch-p (file-name-nondirectory name) pattern))) (defsubst editorconfig-core-handle--string-trim (str) "Remove leading and trailing whitespaces from STR." commit 0f4fe99a38411bdfcd276f058880c2a49fb753e4 Author: Stefan Kangas Date: Tue Jun 18 21:17:21 2024 +0200 lisp/editorconfig: Minor cosmetic fixes diff --git a/doc/man/editorconfig.texi b/doc/man/editorconfig.texi index 5e7d3b85552..98bc87743a5 100644 --- a/doc/man/editorconfig.texi +++ b/doc/man/editorconfig.texi @@ -1,10 +1,10 @@ @dircategory Emacs @direntry -* EditorConfig: (editorconfig). EditorConfig Emacs Plugin. +* EditorConfig: (editorconfig). EditorConfig Plugin. @end direntry @node Top -@chapter EditorConfig Emacs Plugin +@chapter EditorConfig Plugin @anchor{#editorconfig-emacs-plugin} This is an @uref{https://editorconfig.org,EditorConfig} plugin for @uref{https://www.gnu.org/software/emacs/,Emacs}. @@ -23,18 +23,19 @@ This is an @uref{https://editorconfig.org,EditorConfig} plugin for @anchor{#getting-started} @menu -* packageel:: +* package:: * use-package:: * Manual installation:: @end menu -@node packageel +@node package @subsection package.el @anchor{#package.el} -This package is available from -@uref{https://melpa.org/#/editorconfig,MELPA}, -@uref{https://stable.melpa.org/#/editorconfig,MELPA Stable} and + +This package is shipped with Emacs. More recent versions can be +installed from @uref{http://elpa.nongnu.org/nongnu/editorconfig.html,NonGNU ELPA}. + Install from these repositories and enable global minor-mode @code{editorconfig-mode}: @@ -43,7 +44,7 @@ Install from these repositories and enable global minor-mode @end verbatim Normally, enabling @code{editorconfig-mode} should be enough for this -plugin to work: all other configurations are optional. This mode sets up +plugin to work: all other configurations are optional. This mode sets up hooks so that EditorConfig properties will be loaded and applied to the new buffers automatically when visiting files. @@ -129,7 +130,7 @@ show up on our radar. @subsection File Type (file_type_ext, file_type_emacs) @anchor{#file-type-file_type_ext-file_type_emacs} File-type feature is currently disabled, because this package is now -undergoing big internal refactoring. For those who want this +undergoing big internal refactoring. For those who want this functionality, please consider using @uref{https://github.com/10sr/editorconfig-custom-majormode-el,editorconfig-custom-majormode}. @@ -159,7 +160,7 @@ function. One possible value is @uref{https://github.com/lewang/ws-butler,@code{ws-butler-mode}}, with -which only lines touched get trimmed. To use it, add following to your +which only lines touched get trimmed. To use it, add following to your init.el: @verbatim @@ -215,7 +216,7 @@ recommend first trying @code{M-x editorconfig-display-current-properties}. This command will open a new buffer and display the EditorConfig -properties loaded for current buffer. You can check if EditorConfig +properties loaded for current buffer. You can check if EditorConfig properties were not read for buffers at all, or they were loaded but did not take effect for some other reasons. @@ -232,8 +233,8 @@ plugin requires explicit support for each major-mode for @code{indent_size} property. By default this plugin ships with settings for many major-modes, but, -sorry to say, it cannot be perfect. Especially it is difficult to -support brand-new major-modes. Please feel free to submit issue or +sorry to say, it cannot be perfect. Especially it is difficult to +support brand-new major-modes. Please feel free to submit issue or pull-request for such major-mode! Supported major-modes and their indentation configs are defined in the @@ -243,13 +244,13 @@ variable @code{editorconfig-indentation-alist}. @subsection Not work at all for FOO-mode! @anchor{#not-work-at-all-for-foo-mode} Most cases properties are loaded just after visiting files when -@code{editorconfig-mode} is enabled. But it is known that there are +@code{editorconfig-mode} is enabled. But it is known that there are major-modes that this mechanism does not work for and require explicit call of @code{editorconfig-apply}. Typically it will occur when the major-mode is not defined using @code{define-derived-mode} (@code{rpm-spec-mode} is an example for -this). Please feel free to submit issues if you find such modes! +this). Please feel free to submit issues if you find such modes! @node Submitting Bugs and Feature Requests @section Submitting Bugs and Feature Requests @@ -288,10 +289,10 @@ 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 +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 @url{https://www.gnu.org/licenses/}. +with this program. If not, see @url{https://www.gnu.org/licenses/}. @bye diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el index 48e7141e3b4..1d7b1f61088 100644 --- a/lisp/editorconfig-core-handle.el +++ b/lisp/editorconfig-core-handle.el @@ -74,8 +74,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) diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index a1283e23ae0..c263b744de0 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -1,4 +1,4 @@ -;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- +;;; editorconfig.el --- EditorConfig Plugin -*- lexical-binding: t -*- ;; Copyright (C) 2011-2024 Free Software Foundation, Inc. @@ -182,7 +182,7 @@ This hook will be run even when there are no matching sections in (web-mode . editorconfig--get-indentation-web-mode) (zig-mode zig-indent-offset) ) - "Alist of indentation setting methods by modes + "Alist of indentation setting methods by modes. This is a fallback used for those modes which don't set `editorconfig-indent-size-vars'. commit 57b2439cb566599c570826b141d31cdf52478f9d Author: Stefan Monnier Date: Tue Jun 18 10:51:48 2024 -0400 editorconfig.el: Miscellaneous minor changes * lisp/editorconfig.el: Drop redundant `require`s of pcase, nadvice, rx. Remove unnecessary (and incorrect) `defvar`s in `eval-when-compile`. (find-library-name, lm-version): Move declarations to right after the corresponding `require` so we have a reason to believe they're defined. (editorconfig-version): Use `package-get-version` when available. * lisp/editorconfig-core.el (editorconfig-core-get-nearest-editorconfig) (editorconfig-core-get-properties, editorconfig-core-get-properties-hash): * lisp/editorconfig-fnmatch.el (editorconfig-fnmatch-p): Remove autoload cookies. diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index bdd5f49aa6e..3dfdd5c7188 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -90,7 +90,6 @@ RESULT is used internally and normally should not be used." confname (cons handle result))))) -;;;###autoload (defun editorconfig-core-get-nearest-editorconfig (directory) "Return path to .editorconfig file that is closest to DIRECTORY." (when-let* ((handle (car (last @@ -98,7 +97,6 @@ RESULT is used internally and normally should not be used." ".editorconfig"))))) (editorconfig-core-handle-path handle))) -;;;###autoload (defun editorconfig-core-get-properties (&optional file confname confversion) "Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. @@ -122,7 +120,6 @@ When the same key exists in both two hashes, values of UPDATE takes precedence." (maphash (lambda (key value) (puthash key value into)) update) into) -;;;###autoload (defun editorconfig-core-get-properties-hash (&optional file confname confversion) "Get EditorConfig properties for FILE. If FILE is not given, use currently visiting file. diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index 4f6feb0f893..745c3cf8a40 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -83,7 +83,6 @@ string (substring string (match-end 0)))) num)) -;;;###autoload (defun editorconfig-fnmatch-p (string pattern) "Test whether STRING match PATTERN. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index c5bf08f772c..a1283e23ae0 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -5,7 +5,7 @@ ;; Author: EditorConfig Team ;; Version: 0.11.0 ;; 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 @@ -49,17 +49,8 @@ ;;; 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)) (require 'editorconfig-core) @@ -686,9 +677,6 @@ Meant to be used on `hack-dir-local-get-variables-functions'." ;; (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. @@ -696,20 +684,26 @@ Meant to be used on `hack-dir-local-get-variables-functions'." 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) + (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)) commit 0b3e688b230607b0c8571b604621b34860ebccea Author: Stefan Monnier Date: Mon Jun 17 23:25:52 2024 -0400 lisp/editorconfig: Advise `find-auto-coding` i.s.o `insert-file-contents` In Emacs<30, we can't use `auto-coding-functions`, but we can get almost the same result by advising `find-auto-coding`. * lisp/editorconfig.el (editorconfig-merge-coding-systems): Return nil if there's no setting. Don't merge if there's no need. (editorconfig-set-coding-system-revert); Adjust accordingly. (editorconfig--filename-codingsystem-hash): Delete var. (editorconfig--advice-insert-file-contents): Delete function. (editorconfig--advice-find-file-noselect); Simplify. (editorconfig--advice-find-auto-coding): New function. (editorconfig-mode): Use it. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 037d8aee0a4..c5bf08f772c 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -376,16 +376,16 @@ Major modes are expected to set this buffer-locally.") (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. @@ -401,7 +401,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 @@ -413,7 +413,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) @@ -542,35 +544,11 @@ This function also executes `editorconfig-after-apply-functions' functions." (format "Error while running `editorconfig-after-apply-functions': %S" err)))))) -(defvar editorconfig--filename-codingsystem-hash (make-hash-table :test 'equal) - "Used interally. - -`editorconfig--advice-find-file-noselect' will put value to this hash, and -`editorconfig--advice-insert-file-contents' will use the value to set -`coding-system-for-read' value.") - -(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--filename-codingsystem-hash' 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--filename-codingsystem-hash - buffer-file-name) - :debug) - (let ((coding-system (and (stringp filename) - (gethash (expand-file-name filename) - editorconfig--filename-codingsystem-hash)))) - (if (and coding-system - (not (eq coding-system - 'undecided))) - (let ((coding-system-for-read coding-system)) - (apply f filename args)) - (apply f filename args)))) +(defun editorconfig--advice-find-auto-coding (filename &rest _args) + "Consult `charset' setting of EditorConfig." + (let ((cs (dlet ((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. @@ -578,17 +556,10 @@ 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 (stringp filename) - (setq props (editorconfig-call-get-properties-function filename)) - (setq coding-system - (editorconfig-merge-coding-systems (gethash 'end_of_line props) - (gethash 'charset props))) - (puthash (expand-file-name filename) - coding-system - editorconfig--filename-codingsystem-hash)) + (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" @@ -596,25 +567,11 @@ F is that function, and FILENAME and ARGS are arguments passed to F." :warning))) (setq ret (apply f filename args)) - (clrhash editorconfig--filename-codingsystem-hash) (condition-case err (with-current-buffer ret (when props - ;; 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 this case, explicitly set this value so that saving will be done - ;; with expected coding system. - (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))) - (set-buffer-file-coding-system coding-system)) - ;; NOTE: hack-properties-functions cannot affect coding-system value, ;; because it has to be set before initializing buffers. (condition-case err @@ -709,13 +666,15 @@ Meant to be used on `hack-dir-local-get-variables-functions'." (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) + (advice-add 'find-auto-coding :after-until + #'editorconfig--advice-find-auto-coding) (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) + (advice-remove 'find-auto-coding + #'editorconfig--advice-find-auto-coding) (dolist (hook modehooks) (remove-hook hook #'editorconfig-major-mode-hook)))))) commit 624ba9fce0624fa1c82a52d9852ecd74a9f3c6c1 Author: Stefan Monnier Date: Mon Jun 10 17:18:13 2024 -0400 lisp/editorconfig: Use new Emacs-30 hooks * lisp/editorconfig.el (editorconfig--get-coding-system) (editorconfig--get-dir-local-variables): New functions. (editorconfig-mode): Use them if possible. (editorconfig-hack-properties-functions only) (editorconfig-after-apply-functions): Define only when the old advice is used, since the new hooks don't support them. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index cf55f0b3218..037d8aee0a4 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -72,16 +72,17 @@ coding styles between different editors and IDEs." :prefix "editorconfig-" :group 'tools) -(define-obsolete-variable-alias - 'edconf-custom-hooks - 'editorconfig-after-apply-functions - "0.5") -(define-obsolete-variable-alias - 'editorconfig-custom-hooks - 'editorconfig-after-apply-functions - "0.7.14") -(defcustom editorconfig-after-apply-functions () - "A list of functions after loading common EditorConfig settings. +(when (< emacs-major-version 30) + (define-obsolete-variable-alias + 'edconf-custom-hooks + 'editorconfig-after-apply-functions + "0.5") + (define-obsolete-variable-alias + 'editorconfig-custom-hooks + 'editorconfig-after-apply-functions + "0.7.14") + (defcustom editorconfig-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 @@ -100,10 +101,11 @@ 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) + :type 'hook)) -(defcustom editorconfig-hack-properties-functions () - "A list of function to alter property values before applying them. +(when (< emacs-major-version 30) + (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 @@ -122,12 +124,10 @@ 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) + :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: - charset values will be referenced before running this hook." - "v0.9.0") + 'editorconfig-get-local-variables-functions + "2024") (define-obsolete-variable-alias 'edconf-indentation-alist @@ -641,30 +641,83 @@ 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--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'." + (defvar auto-coding-file-name) ;; Emacs≥30 + (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))))) + +(defun editorconfig--get-dir-local-variables () + "Return the directory local variables specified via EditorConfig. +Meant to be used on `hack-dir-local-get-variables-functions'." + (when (stringp buffer-file-name) + (let* ((props (editorconfig-call-get-properties-function buffer-file-name)) + (alist (editorconfig--get-local-variables props))) + ;; FIXME: If there's `/foo/.editorconfig', `/foo/bar/.dir-locals.el', + ;; and `/foo/bar/baz/.editorconfig', it would be nice to return two + ;; pairs here, so that hack-dir-local can give different priorities + ;; to the `/foo/.editorconfig' settings compared to those of + ;; `/foo/bar/baz/.editorconfig', but we can't just convert the + ;; settings from each file individually and let hack-dir-local merge + ;; them because hack-dir-local doesn't have the notion of "unset", + ;; and because the conversion of `indent_size' depends on `tab_width'. + (when alist + (cons + (file-name-directory (editorconfig-core-get-nearest-editorconfig + buffer-file-name)) + alist))))) ;;;###autoload (define-minor-mode editorconfig-mode "Toggle EditorConfig feature." :global t - (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 '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) - (dolist (hook modehooks) - (remove-hook hook 'editorconfig-major-mode-hook))))) + (if (boundp 'hack-dir-local-get-variables-functions) ;Emacs≥30 + (if editorconfig-mode + (progn + (add-hook 'hack-dir-local-get-variables-functions + ;; Give them slightly lower precedence than settings from + ;; `dir-locals.el'. + #'editorconfig--get-dir-local-variables t) + ;; `auto-coding-functions' also exists in Emacs<30 but without + ;; access to the file's name via `auto-coding-file-name'. + (add-hook 'auto-coding-functions + #'editorconfig--get-coding-system)) + (remove-hook 'hack-dir-local-get-variables-functions + #'editorconfig--get-dir-local-variables) + (remove-hook 'auto-coding-functions + #'editorconfig--get-coding-system)) + ;; Emacs<30 + (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 '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) + (dolist (hook modehooks) + (remove-hook hook #'editorconfig-major-mode-hook)))))) ;; (defconst editorconfig--version commit f2803456f029f24276901c2b3115965d892a99d0 Author: Stefan Monnier Date: Mon Jun 10 16:58:27 2024 -0400 (editorconfig-set-local-variables): Get first, set later In preparation for the use of Emacs-30's `hack-dir-local-get-variables-functions`, split the job of `editorconfig-set-local-variables` into getting an alist of settings and then applying them. Rename the `editorconfig-set-*` functions to `editorconfig--get-*` and make them return an alist of settings rather than applying them (except for `editorconfig-set-coding-system-revert` which arguably belongs in `editorconfig-tools.el` anyway). * lisp/editorconfig.el (editorconfig-indentation-alist): Flesh out the doc. Use the new `editorconfig--get-indentation-*-mode` functions. (editorconfig--get-indentation-web-mode): New function extracted from `editorconfig-indentation-alist`. (editorconfig--get-indentation-*-mode): Don't `boundp`-test the vars. (editorconfig--default-indent-size-function): New function. Test `boundp` here. (editorconfig-indent-size-vars): New var. (editorconfig--get-indentation, editorconfig--get-trailing-nl): Rewrite. (editorconfig--add-hook-safe-p): New function. Add it to the `safe-local-eval-function` property of `add-hook`. (editorconfig-get-local-variables-functions): New hook. (editorconfig--get-local-variables): Rewrite using it. (editorconfig-set-local-variables): Test `editorconfig--should-set` here. Rewrite it using `editorconfig--get-local-variables`. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index a0bd0ae3e74..cf55f0b3218 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -38,6 +38,14 @@ ;; EditorConfig files are easily readable and they work nicely with ;; version control systems. +;;; News: + +;; - In `editorconfig-indentation-alist', if a mode is associated to a function +;; that function should not set the vars but should instead *return* them. +;; - New var `editorconfig-indent-size-vars' for major modes to set. +;; - New hook `editorconfig-get-local-variables-functions' to support +;; additional settings. + ;;; Code: (require 'cl-lib) @@ -141,7 +149,7 @@ This hook will be run even when there are no matching sections in (csharp-mode c-basic-offset) (csharp-ts-mode c-basic-offset csharp-ts-mode-indent-offset) - (emacs-lisp-mode . editorconfig-set-indentation-lisp-mode) + (emacs-lisp-mode . editorconfig--get-indentation-lisp-mode) (ess-mode ess-indent-offset) (feature-mode feature-indent-offset feature-indent-level) @@ -153,8 +161,8 @@ This hook will be run even when there are no matching sections in java-ts-mode-indent-offset) (js-mode js-indent-level) (jsonian-mode jsonian-default-indentation) - (latex-mode . editorconfig-set-indentation-latex-mode) - (lisp-mode . editorconfig-set-indentation-lisp-mode) + (latex-mode . editorconfig--get-indentation-latex-mode) + (lisp-mode . editorconfig--get-indentation-lisp-mode) (matlab-mode matlab-indent-level) (octave-mode octave-block-offset) ;; No need to change `php-mode-coding-style' value for php-mode @@ -180,13 +188,18 @@ This hook will be run even when there are no matching sections in verilog-indent-level-module verilog-cexp-indent verilog-case-indent) - (web-mode (web-mode-indent-style . ,(lambda (size) 2)) - web-mode-markup-indent-offset - web-mode-css-indent-offset - web-mode-code-indent-offset) + (web-mode . editorconfig--get-indentation-web-mode) (zig-mode zig-indent-offset) ) - "Alist of indentation setting methods by modes." + "Alist of indentation setting methods by modes + +This is a fallback used for those modes which don't set +`editorconfig-indent-size-vars'. + +Each element should look like (MODE . SETTING) where SETTING +should obey the same rules as `editorconfig-indent-size-vars'." + :type '(alist :key-type symbol + :value-type (choice function (repeat symbol))) :risky t) (defcustom editorconfig-trim-whitespaces-mode nil @@ -229,20 +242,30 @@ Make a message by passing ARGS to `format-message'." (and (stringp string) (string-match-p "\\`[0-9]+\\'" string))) -(defun editorconfig-set-indentation-latex-mode (size) - "Set `latex-mode' indent size to SIZE." - (setq-local LaTeX-indent-level size) - (setq-local LaTeX-item-indent size) - (setq-local TeX-brace-indent-level size)) - -(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))) +(defun editorconfig--get-indentation-web-mode (size) + `((web-mode-indent-style . 2) + (web-mode-markup-indent-offset . ,size) + (web-mode-css-indent-offset . ,size) + (web-mode-code-indent-offset . ,size))) + +(defun editorconfig--get-indentation-latex-mode (size) + "Vars to set `latex-mode' indent size to SIZE." + `((tex-indent-basic . ,size) + (tex-indent-item . ,size) + (tex-indent-arg . ,(* 2 size)) + ;; For AUCTeX + (TeX-brace-indent-level . ,size) + (LaTeX-indent-level . ,size) + (LaTeX-item-indent . ,(- size)))) + +(defun editorconfig--get-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)) + `((lisp-indent-offset . ,size)))) (cl-defun editorconfig--should-set (symbol) "Determine if editorconfig should set SYMBOL." @@ -260,26 +283,87 @@ Make a message by passing ARGS to `format-message'." t) -(defun editorconfig-set-indentation (style &optional size tab_width) - "Set indentation type from STYLE, SIZE and 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) - ) - - (cond ((not (editorconfig--should-set 'indent-tabs-mode)) - nil) - ) - - (when (editorconfig--should-set 'evil-shift-width) - ) - ) +(defvar editorconfig-indent-size-vars + #'editorconfig--default-indent-size-function + "Rule to use to set a given `indent_size'. +Can take the form of a function, in which case we call it with a single SIZE +argument (an integer) and it should return a list of (VAR . VAL) pairs. +Otherwise it can be a list of symbols (those which should be set to SIZE). +Major modes are expected to set this buffer-locally.") + +(defun editorconfig--default-indent-size-function (size) + (let ((parents (if (fboundp 'derived-mode-all-parents) ;Emacs-30 + (derived-mode-all-parents major-mode) + (let ((modes nil) + (mode major-mode)) + (while mode + (push mode modes) + (setq mode (get mode 'derived-mode--parent))) + (nreverse modes)))) + entry) + (let ((parents parents)) + (while (and parents (not entry)) + (setq entry (assq (pop parents) editorconfig-indentation-alist)))) + (or + (when entry + (let ((rule (cdr entry))) + ;; Filter out settings of unknown vars. + (delq nil + (mapcar (lambda (elem) + (let ((v (car elem))) + (cond + ((not (symbolp v)) + (message "Unsupported element in `editorconfig-indentation-alist': %S" elem)) + ((or (eq 'eval v) (boundp v)) elem)))) + (if (functionp rule) + (funcall rule size) + (mapcar (lambda (elem) `(,elem . ,size)) rule)))))) + ;; Fallback, let's try and guess. + (let ((suffixes '("-indent-level" "-basic-offset" "-indent-offset" + "-block-offset")) + (guess ())) + (while (and parents (not guess)) + (let* ((mode (pop parents)) + (modename (symbol-name mode)) + (name (substring modename 0 + (string-match "-mode\\'" modename)))) + (dolist (suffix suffixes) + (let ((sym (intern-soft (concat name suffix)))) + (when (and sym (boundp sym)) + (setq guess sym)))))) + (when guess `((,guess . ,size)))) + (and (local-variable-p 'smie-rules-function) + `((smie-indent-basic . ,size)))))) + +(defun editorconfig--get-indentation (props) + "Get indentation vars according to STYLE, SIZE, and TAB_WIDTH." + (let ((style (gethash 'indent_style props)) + (size (gethash 'indent_size props)) + (tab_width (gethash 'tab_width props))) + (when tab_width + (setq tab_width (string-to-number tab_width))) + + (setq size + (cond ((editorconfig-string-integer-p size) + (string-to-number size)) + ((equal size "tab") + (or tab_width tab-width)) + (t + nil))) + `(,@(if tab_width `((tab-width . ,tab_width))) + + ,@(pcase style + ("space" `((indent-tabs-mode . nil))) + ("tab" `((indent-tabs-mode . t)))) + + ,@(when (and size (featurep 'evil)) + `((evil-shift-width . ,size))) + + ,@(cond + ((null size) nil) + ((functionp editorconfig-indent-size-vars) + (funcall editorconfig-indent-size-vars size)) + (t (mapcar (lambda (v) `(,v . ,size)) editorconfig-indent-size-vars)))))) (defvar-local editorconfig--apply-coding-system-currently nil "Used internally.") @@ -338,39 +422,54 @@ 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-set-trailing-nl (final-newline) - "Set up requiring final newline by FINAL-NEWLINE. - -This function will set `require-final-newline' and `mode-require-final-newline' -to non-nil when FINAL-NEWLINE is true." - (pcase final-newline - ("true" - ) - ("false" - ))) +(defun editorconfig--get-trailing-nl (props) + "Get the vars to require final newline according to PROPS." + (pcase (gethash 'insert_final_newline props) + ("true" + ;; Keep prefs around how/when the nl is added, if set. + `((require-final-newline + . ,(or require-final-newline mode-require-final-newline t)))) + ("false" + `((require-final-newline . nil))))) (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) - (pcase trim-trailing-ws +;; Arrange for our (eval . (add-hook ...)) "local var" to be considered safe. +(defun editorconfig--add-hook-safe-p (exp) + (equal exp '(add-hook 'before-save-hook + #'editorconfig--delete-trailing-whitespace nil t))) +(let ((predicates (get 'add-hook 'safe-local-eval-function))) + (when (functionp predicates) + (setq predicates (list predicates))) + (unless (memq #'editorconfig--add-hook-safe-p predicates) + (put 'add-hook 'safe-local-eval-function #'editorconfig--add-hook-safe-p))) + +(defun editorconfig--get-trailing-ws (props) + "Get vars to trim of trailing whitespace according to PROPS." + (pcase (gethash 'trim_trailing_whitespace props) ("true" - (if editorconfig-trim-whitespaces-mode - (funcall editorconfig-trim-whitespaces-mode 1) - (add-hook 'before-save-hook - #'editorconfig--delete-trailing-whitespace nil t))) + `((eval + . ,(if editorconfig-trim-whitespaces-mode + `(,editorconfig-trim-whitespaces-mode 1) + '(add-hook 'before-save-hook + #'editorconfig--delete-trailing-whitespace nil t))))) ("false" + ;; Just do it right away rather than return a (VAR . VAL), which + ;; would be probably more trouble than it's worth. (when editorconfig-trim-whitespaces-mode (funcall editorconfig-trim-whitespaces-mode 0)) (remove-hook 'before-save-hook - #'editorconfig--delete-trailing-whitespace t)))) + #'editorconfig--delete-trailing-whitespace t) + nil))) -(defun editorconfig-set-line-length (length) - "Set the max line length (`fill-column') to LENGTH." - (when (and (editorconfig-string-integer-p length) - (> (string-to-number length) 0)) - (setq fill-column (string-to-number length)))) +(defun editorconfig--get-line-length (props) + "Get the max line length (`fill-column') to PROPS." + (let ((length (gethash 'max_line_length props))) + (when (and (editorconfig-string-integer-p length) + (> (string-to-number length) 0)) + `((fill-column . ,(string-to-number length)))))) (defun editorconfig-call-get-properties-function (filename) "Call `editorconfig-core-get-properties-hash' with FILENAME and return result. @@ -390,15 +489,34 @@ This function also removes `unset' properties and calls when (equal v "unset") do (remhash k props)) props)) +(defvar editorconfig-get-local-variables-functions + '(editorconfig--get-indentation + editorconfig--get-trailing-nl + editorconfig--get-trailing-ws + editorconfig--get-line-length) + "Special hook run to convert EditorConfig settings to their Emacs equivalent. +Every function is called with one argument, a hash-table indexed by +EditorConfig settings represented as symbols and whose corresponding value +is represented as a string. It should return a list of (VAR . VAL) settings +where VAR is an ELisp variable and VAL is the value to which it should be set.") + +(defun editorconfig--get-local-variables (props) + "Get variables settings according to EditorConfig PROPS." + (let ((alist ())) + (run-hook-wrapped 'editorconfig-get-local-variables-functions + (lambda (fun props) + (setq alist (append (funcall fun props) alist)) + nil) + props) + alist)) + (defun editorconfig-set-local-variables (props) "Set buffer variables according to EditorConfig PROPS." - (editorconfig-set-indentation (gethash 'indent_style props) - (gethash 'indent_size props) - (gethash 'tab_width props)) - (editorconfig-set-trailing-nl (gethash 'insert_final_newline props)) - (editorconfig-set-trailing-ws (gethash 'trim_trailing_whitespace props)) - (editorconfig-set-line-length (gethash 'max_line_length props))) - + (pcase-dolist (`(,var . ,val) (editorconfig--get-local-variables props)) + (if (eq 'eval var) + (eval val t) + (when (editorconfig--should-set var) + (set (make-local-variable var) val))))) (defun editorconfig-major-mode-hook () "Function to run when `major-mode' has been changed. commit 527a45abc37f1885652b0f29ed5eeabff6db6cda Author: Stefan Monnier Date: Wed Jun 12 18:27:15 2024 -0400 lisp/editorconfig: Don't hook into `read-only-mode-hook` Don't re-set variables just because `read-only-mode` is (de)activated, and with Emacs-30's hooks it would be even less natural to do. Also `buffer-read-only` can change without calling `read-only-mode`, so better test it dynamically when we try to trim whitespace. * lisp/editorconfig.el (editorconfig--delete-trailing-whitespace): New function. (editorconfig-set-trailing-ws): Use it. Use `pcase`. Also prefer `before-save-hook` and use `add/remove-hook` to manipulate hooks, like god intended. Don't test `buffer-read-only` any more. (editorconfig-mode): Don't hook into `read-only-mode-hook` any more. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index b8eced27807..a0bd0ae3e74 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -349,13 +349,22 @@ to non-nil when FINAL-NEWLINE is true." ("false" ))) +(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) - (if editorconfig-trim-whitespaces-mode - (funcall editorconfig-trim-whitespaces-mode 1) - ...) - (when editorconfig-trim-whitespaces-mode - (funcall editorconfig-trim-whitespaces-mode 0)) - ...) + (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." @@ -521,7 +530,6 @@ F is that function, and FILENAME and ARGS are arguments passed to F." :global t (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 commit 25523847e7931de1f0ee638d2a8847d979fdb496 Author: Stefan Monnier Date: Wed Jun 12 18:05:43 2024 -0400 (editorconfig--should-set): Eliminate `lisp-indent-offset` special case Instead of treating `lisp-indent-offset` specially in `editorconfig--should-set` (to obey `editorconfig-lisp-use-default-indent`), use a new function `editorconfig-set-indentation-lisp-mode` for Lisp modes. * lisp/editorconfig.el (editorconfig--should-set): Remove `size` argument. (editorconfig-set-indentation): Adjust calls accordingly. (editorconfig-set-indentation-lisp-mode): New function. (editorconfig-indentation-alist): Use it. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 070d6b460eb..b8eced27807 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -141,7 +141,7 @@ This hook will be run even when there are no matching sections in (csharp-mode c-basic-offset) (csharp-ts-mode c-basic-offset csharp-ts-mode-indent-offset) - (emacs-lisp-mode lisp-indent-offset) + (emacs-lisp-mode . editorconfig-set-indentation-lisp-mode) (ess-mode ess-indent-offset) (feature-mode feature-indent-offset feature-indent-level) @@ -154,7 +154,7 @@ This hook will be run even when there are no matching sections in (js-mode js-indent-level) (jsonian-mode jsonian-default-indentation) (latex-mode . editorconfig-set-indentation-latex-mode) - (lisp-mode lisp-indent-offset) + (lisp-mode . editorconfig-set-indentation-lisp-mode) (matlab-mode matlab-indent-level) (octave-mode octave-block-offset) ;; No need to change `php-mode-coding-style' value for php-mode @@ -235,15 +235,20 @@ Make a message by passing ARGS to `format-message'." (setq-local LaTeX-item-indent size) (setq-local TeX-brace-indent-level size)) -(cl-defun editorconfig--should-set (symbol &optional size) - "Determine if editorconfig should set SYMBOL. - -Optional arg SIZE is used when symbol is `lisp-indent-offset'. -See `editorconfig-lisp-use-default-indent' for details." +(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 | size: %S" - symbol - size) + (format "symbol: %S" + symbol) :debug) (when (assq symbol file-local-variables-alist) (cl-return-from editorconfig--should-set @@ -253,14 +258,6 @@ See `editorconfig-lisp-use-default-indent' for details." (cl-return-from editorconfig--should-set nil)) - (when (eq symbol 'lisp-indent-offset) - (cl-return-from editorconfig--should-set - (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 (style &optional size tab_width) commit 3da6765c9908af4eaadd98f0b048e67b3cbcb373 Author: Stefan Monnier Date: Mon Jun 17 11:04:47 2024 -0400 * lisp/editorconfig.el (editorconfig-mode): Remove `:lighter` We generally don't want to eat up modeline space with lighters for global and permanent major modes. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index df707a6644a..070d6b460eb 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -522,7 +522,6 @@ F is that function, and FILENAME and ARGS are arguments passed to F." (define-minor-mode editorconfig-mode "Toggle EditorConfig feature." :global t - :lighter editorconfig-mode-lighter (let ((modehooks '(prog-mode-hook text-mode-hook read-only-mode-hook commit 812831ee2f754277050bc15053490119d13ef958 Author: Stefan Monnier Date: Mon Jun 17 23:18:03 2024 -0400 * lisp/editorconfing.el: Cosmetic ELisp style changes Prefer #' to quote function names. Remove redundant :groups. Silence compiler warnings. * lisp/editorconfig.el: Remove post-trailer. The var is already set via `.dir-locals.el` anyway. (editorconfig-call-get-properties-function): Use condition-case-unless-debug. diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index 2f9b374e0ed..bdd5f49aa6e 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -85,7 +85,7 @@ RESULT is used internally and normally should not be used." (parent (file-name-directory (directory-file-name dir)))) (if (or (string= parent dir) (and handle (editorconfig-core-handle-root-p handle))) - (cl-remove-if-not 'identity (cons handle result)) + (cl-remove-if-not #'identity (cons handle result)) (editorconfig-core--get-handles parent confname (cons handle result))))) diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index 85eab7abc35..4f6feb0f893 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -234,7 +234,7 @@ translation is found for PATTERN." (number-end (string-to-number (match-string 2 pattern-sub)))) (setq result `(,@result ,(concat "\\(?:" - (mapconcat 'number-to-string + (mapconcat #'number-to-string (cl-loop for i from number-start to number-end collect i) "\\|") diff --git a/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el index 7364a7135c3..ebc6a45d7bd 100644 --- a/lisp/editorconfig-tools.el +++ b/lisp/editorconfig-tools.el @@ -112,7 +112,7 @@ any of regexps in `editorconfig-exclude-regexps'." nil)) ;;;###autoload (defalias 'describe-editorconfig-properties - 'editorconfig-display-current-properties) + #'editorconfig-display-current-properties) (provide 'editorconfig-tools) diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index cba4eea319c..df707a6644a 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -92,8 +92,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. @@ -115,8 +114,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: @@ -196,8 +194,7 @@ This hook will be run even when there are no matching sections in 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. @@ -378,7 +375,7 @@ This function also removes `unset' properties and calls (setq filename (expand-file-name filename)) (editorconfig-error "Invalid argument: %S" filename)) (let ((props nil)) - (condition-case err + (condition-case-unless-debug err (setq props (editorconfig-core-get-properties-hash filename)) (error (editorconfig-error "Error from editorconfig-core-get-properties-hash: %S" @@ -585,7 +582,3 @@ version in the echo area and the messages buffer." (provide 'editorconfig) ;;; editorconfig.el ends here - -;; Local Variables: -;; sentence-end-double-space: t -;; End: commit c5d86db81173100bd0303cfb2066b1a0319c2caa Author: Stefan Monnier Date: Mon Jun 17 11:02:34 2024 -0400 Remove support for `editorconfig-exclude-*` When using the new hook, we can't support `editorconfig-exclude-modes` for the `charset` property. Also there are already other ways to get similar effects (e.g. setting `auto-coding-alist` or `enable-dir-local-variables`), so it's not clear those configurations will be needed in Emacs-30. * lisp/editorconfig.el (editorconfig-exclude-modes) (editorconfig-exclude-regexps): Remove custom vars. (recentf): Remove workaround (presumably not needed thanks to the fix to issue #246). (editorconfig--disabled-for-filename) (editorconfig--disabled-for-majormode): Delete functions. (editorconfig--advice-find-file-noselect): Remove call to those functions. (editorconfig-mode): Adjust docstring accordingly. * lisp/editorconfig-tools.el (editorconfig-apply): Adjust accordingly. diff --git a/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el index c77d107052f..7364a7135c3 100644 --- a/lisp/editorconfig-tools.el +++ b/lisp/editorconfig-tools.el @@ -80,10 +80,7 @@ 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))) + (when (and major-mode buffer-file-name) (editorconfig-apply))) diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index c873700a041..cba4eea319c 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -191,24 +191,6 @@ This hook will be run even when there are no matching sections in "Alist of indentation setting methods by modes." :risky t) -(defcustom editorconfig-exclude-modes () - "Modes in which `editorconfig-mode-apply' will not run." - :type '(repeat (symbol :tag "Major Mode")) - :group 'editorconfig) - -(defcustom editorconfig-exclude-regexps () - "List 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) -(with-eval-after-load 'recentf - (add-to-list 'editorconfig-exclude-regexps - (rx-to-string '(seq string-start - (eval (expand-file-name recentf-save-file))) - t))) - (defcustom editorconfig-trim-whitespaces-mode nil "Buffer local minor-mode to use to trim trailing whitespaces. @@ -245,23 +227,6 @@ number - `lisp-indent-offset' is not set only if indent_size is Make a message by passing ARGS to `format-message'." (signal 'editorconfig-error (list (apply #'format-message args)))) -(defun editorconfig--disabled-for-filename (filename) - "Return non-nil when EditorConfig is disabled for FILENAME." - (cl-assert (stringp filename)) - (cl-loop for regexp in editorconfig-exclude-regexps - if (string-match regexp filename) return t - finally return nil)) - -(defun editorconfig--disabled-for-majormode (majormode) - "Return non-nil when Editorconfig is disabled for MAJORMODE." - (cl-assert majormode) - (or (provided-mode-derived-p majormode 'special-mode) - ;; Some special modes (like `archive-mode') are not derived from - ;; `special-mode' - (eq (get majormode 'mode-class) 'special) - (memq majormode - editorconfig-exclude-modes))) - (defun editorconfig-string-integer-p (string) "Return non-nil if STRING represents integer." (and (stringp string) @@ -495,8 +460,7 @@ F is that function, and FILENAME and ARGS are arguments passed to F." (coding-system nil) (ret nil)) (condition-case err - (when (and (stringp filename) - (not (editorconfig--disabled-for-filename filename))) + (when (stringp filename) (setq props (editorconfig-call-get-properties-function filename)) (setq coding-system (editorconfig-merge-coding-systems (gethash 'end_of_line props) @@ -515,9 +479,7 @@ F is that function, and FILENAME and ARGS are arguments passed to F." (condition-case err (with-current-buffer ret - (when (and props - ;; filename has already been checked - (not (editorconfig--disabled-for-majormode major-mode))) + (when props ;; When file path indicates it is a remote file and it actually ;; does not exists, `buffer-file-coding-system' will not be set. @@ -561,10 +523,7 @@ F is that function, and FILENAME and ARGS are arguments passed to F." ;;;###autoload (define-minor-mode editorconfig-mode - "Toggle EditorConfig feature. - -To disable EditorConfig in some buffers, modify -`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'." + "Toggle EditorConfig feature." :global t :lighter editorconfig-mode-lighter (let ((modehooks '(prog-mode-hook commit 8cfa6fe80128da62d28da37c5baedd201b796bb8 Author: Stefan Monnier Date: Mon Jun 17 10:54:25 2024 -0400 Remove support for `editorconfig-override-*-local-variables` With the Emacs-30 hooks we can't easily override file-local settings and we can't easily control whether we override dir-local settings, so we remove support for those config vars. * lisp/editorconfig.el (editorconfig-override-file-local-variables) (editorconfig-override-dir-local-variables): Remove custom vars. (editorconfig--should-set): Presume they were nil. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 5c74e35fc52..c873700a041 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -237,16 +237,6 @@ 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 - :group 'editorconfig) - -(defcustom editorconfig-override-dir-local-variables t - "Non-nil means editorconfig will override values defined in dir-locals.el ." - :type 'boolean - :group 'editorconfig) - (define-error 'editorconfig-error "Error thrown from editorconfig lib") @@ -293,13 +283,11 @@ See `editorconfig-lisp-use-default-indent' for details." symbol size) :debug) - (when (and (not editorconfig-override-file-local-variables) - (assq symbol file-local-variables-alist)) + (when (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)) + (when (assq symbol dir-local-variables-alist) (cl-return-from editorconfig--should-set nil)) commit 3f90253dae0eda0ff2fa0b2635dc8e9b6a300641 Author: Stefan Monnier Date: Mon Jun 17 10:41:31 2024 -0400 Remove support for the `editorconfig` executable Some of the code lacks copyright paperwork, so let's remove it for now, so we don't have to adapt it to the new hooks. If/when it proves useful/necessary it'll be easy enough to re-add. * editorconfig.el (editorconfig-exec-path, edconf-get-properties-function) (edconf-exec-path, editorconfig-get-properties-function): Delete variables. (editorconfig--execute-editorconfig-exec) (editorconfig--parse-properties, editorconfig-get-properties) (editorconfig-get-properties-from-exec): Delete functions. (editorconfig-call-get-properties-function): Call `editorconfig-core-get-properties-hash` directly. diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 4a873ce84db..5c74e35fc52 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -64,52 +64,6 @@ coding styles between different editors and IDEs." :prefix "editorconfig-" :group 'tools) -(define-obsolete-variable-alias - 'edconf-exec-path - 'editorconfig-exec-path - "0.5") -(defcustom editorconfig-exec-path - "editorconfig" - "Path to EditorConfig executable. - -Used by `editorconfig--execute-editorconfig-exec'." - :type 'string - :group 'editorconfig) - -(define-obsolete-variable-alias - 'edconf-get-properties-function - 'editorconfig-get-properties-function - "0.5") -(defcustom editorconfig-get-properties-function - 'editorconfig-core-get-properties-hash - "A function which gets EditorConfig properties for specified file. - -This function will be called with one argument, full path of the target file, -and should return a hash object containing properties, or nil if any core -program is not available. Keys of this hash should be symbols of properties, -and values should be strings of their values. - - -For example, if you always want to use built-in core library instead -of any EditorConfig executable to get properties, add following to -your init.el: - - (set-variable \\='editorconfig-get-properties-function - #\\='editorconfig-core-get-properties-hash) - -Possible known values are: - -* `editorconfig-core-get-properties-hash' (default) - * Always use built-in Emacs-Lisp implementation to get properties -* `editorconfig-get-properties' - * 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" - :type 'function - :group 'editorconfig) - (define-obsolete-variable-alias 'edconf-custom-hooks 'editorconfig-after-apply-functions @@ -462,76 +416,19 @@ to non-nil when FINAL-NEWLINE is true." (> (string-to-number length) 0)) (setq fill-column (string-to-number length)))) - -(defun editorconfig--execute-editorconfig-exec (filename) - "Execute EditorConfig core with FILENAME and return output." - (if filename - (with-temp-buffer - (let ((remote (file-remote-p filename)) - (remote-localname (file-remote-p filename - 'localname))) - (display-warning '(editorconfig editorconfig--execute-editorconfig-exec) - (format "editorconfig--execute-editorconfig-exec: filename: %S | remote: %S | remote-localname: %S" - filename - remote - remote-localname) - :debug) - (if remote - (progn - (cd (concat remote "/")) - (setq filename remote-localname)) - (cd "/"))) - (display-warning '(editorconfig editorconfig--execute-editorconfig-exec) - (format "editorconfig--execute-editorconfig-exec: default-directory: %S | filename: %S" - default-directory - filename - ) - :debug) - (if (eq 0 - (process-file editorconfig-exec-path nil t nil filename)) - (buffer-string) - (editorconfig-error (buffer-string)))) - "")) - -(defun editorconfig--parse-properties (props-string) - ) - -(defun editorconfig-get-properties-from-exec (filename) - "Get EditorConfig properties of file FILENAME. - -This function uses value of `editorconfig-exec-path' to get properties." - (if (executable-find editorconfig-exec-path) - (editorconfig--parse-properties (editorconfig--execute-editorconfig-exec filename)) - (editorconfig-error "Unable to find editorconfig executable"))) - -(defun editorconfig-get-properties (filename) - "Get EditorConfig properties for file FILENAME. - -It calls `editorconfig-get-properties-from-exec' if -`editorconfig-exec-path' is found, otherwise -`editorconfig-core-get-properties-hash'." - (if (and (executable-find editorconfig-exec-path) - (not (file-remote-p filename))) - (editorconfig-get-properties-from-exec filename) - (require 'editorconfig-core) - (editorconfig-core-get-properties-hash filename))) - (defun editorconfig-call-get-properties-function (filename) - "Call `editorconfig-get-properties-function' with FILENAME and return result. + "Call `editorconfig-core-get-properties-hash' with FILENAME and return result. This function also removes `unset' properties and calls `editorconfig-hack-properties-functions'." - (unless (functionp editorconfig-get-properties-function) - (editorconfig-error "Invalid editorconfig-get-properties-function value")) (if (stringp filename) (setq filename (expand-file-name filename)) (editorconfig-error "Invalid argument: %S" filename)) (let ((props nil)) (condition-case err - (setq props (funcall editorconfig-get-properties-function - filename)) + (setq props (editorconfig-core-get-properties-hash filename)) (error - (editorconfig-error "Error from editorconfig-get-properties-function: %S" + (editorconfig-error "Error from editorconfig-core-get-properties-hash: %S" err))) (cl-loop for k being the hash-keys of props using (hash-values v) when (equal v "unset") do (remhash k props)) commit 729fc9b88b44f4168a842b3d38bc5b4be3c25772 Author: Stefan Monnier Date: Wed Jun 19 13:35:08 2024 -0400 Fix up copyright lines and license blurbs diff --git a/lisp/editorconfig-conf-mode.el b/lisp/editorconfig-conf-mode.el index 2b4ddd4410f..105ce48a9bb 100644 --- a/lisp/editorconfig-conf-mode.el +++ b/lisp/editorconfig-conf-mode.el @@ -1,6 +1,6 @@ ;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team @@ -8,20 +8,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el index d225e1456ba..48e7141e3b4 100644 --- a/lisp/editorconfig-core-handle.el +++ b/lisp/editorconfig-core-handle.el @@ -1,6 +1,6 @@ ;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team @@ -8,20 +8,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el index c7b52deaafd..2f9b374e0ed 100644 --- a/lisp/editorconfig-core.el +++ b/lisp/editorconfig-core.el @@ -1,6 +1,6 @@ ;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team @@ -8,20 +8,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el index 25a344dc2ef..85eab7abc35 100644 --- a/lisp/editorconfig-fnmatch.el +++ b/lisp/editorconfig-fnmatch.el @@ -1,6 +1,6 @@ ;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team @@ -8,20 +8,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: diff --git a/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el index d4af1a1e5a0..c77d107052f 100644 --- a/lisp/editorconfig-tools.el +++ b/lisp/editorconfig-tools.el @@ -1,6 +1,6 @@ ;;; editorconfig-tools.el --- Editorconfig tools -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team @@ -8,20 +8,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 5ab06344047..4a873ce84db 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -1,6 +1,6 @@ ;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- -;; Copyright (C) 2011-2024 EditorConfig Team +;; Copyright (C) 2011-2024 Free Software Foundation, Inc. ;; Author: EditorConfig Team ;; Version: 0.11.0 @@ -12,20 +12,20 @@ ;; 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. +;; This file is part of GNU Emacs. -;; 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. +;; GNU Emacs 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, +;; GNU Emacs 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: commit f563f0f961068e5732b9770908ebfd915a93fe12 Author: Stefan Monnier Date: Tue Jun 18 01:26:41 2024 -0400 Squashed commit of the following: commit a2b7d1129ba03ab7d06618d838cd3abe6852488b Author: Stefan Monnier Date: Tue Jun 18 01:23:21 2024 -0400 Move files for inclusion into Emacs commit cd4fc6f933e8679eff1754eaaac99e4361f0122f Author: Stefan Monnier Date: Sun Jun 16 13:33:55 2024 -0400 Incorporate trivial left-over changes The previous commits are the result of a `git rebase` that removed all the commits by contributors for whom we don't have paperwork. This one "smoothes" over some of the remaining diffs. commit 94c0223e888d637ae5d75fcb210fe4bf7898b3da Author: 10sr <8.slashes@gmail.com> Date: Sat Jun 8 00:52:06 2024 +0900 Fix text (#342) commit d50dfb5c5bf2dc832c9aff8f4b8603c2d504c41a Author: 10sr <8.slashes@gmail.com> Date: Tue Jun 4 15:02:56 2024 +0900 Refactor find-file advices (#340) * Add coding-system test * Refactor find-file advices * Fix test * Fix test * Update * Update commit f55bb4e691dcb63502035aa3e48f6839ae163b44 Author: 10sr <8.slashes@gmail.com> Date: Sun Jun 2 16:42:31 2024 +0900 Update CHANGELOG.md (#339) * Update CHANGELOG.md * Update CHANGELOG.md commit a85a4cafa6c8a1a80f3671658e5aaaf8faedb923 Author: 10sr <8.slashes@gmail.com> Date: Fri May 31 22:19:15 2024 +0900 Add switch not to override local variable values (#338) * Add tests * Define variables * Update --should-set * Add fixes to work * Update test and fix * Fix variables * Use defcustom for switch variables * Remove comment commit 4fbfad0591a9851a48b8ead1e4459677d3f64c58 Author: Jen-Chieh Shen Date: Sat May 11 22:38:20 2024 -0700 feat: Add Svelte support (#333) commit d2d942b4cc83fa0ba32dcaaf6c73004e6490bfc8 Author: 10sr <8.slashes@gmail.com> Date: Sat May 11 15:45:42 2024 +0900 Prepare v0.11.0 (#332) * Prepare v0.11.0 * Update CHANGLOG for v0.11.0 * 2024 commit 9ad3ed0e58bcd719d63d7b64538eff118d094767 Author: 10sr <8.slashes@gmail.com> Date: Fri May 10 00:45:15 2024 +0900 Update CHANGELOG (#331) commit 3fb9fd274d2435228a6545cd2a7553c9522b32e8 Author: 10sr <8.slashes@gmail.com> Date: Mon May 6 23:01:39 2024 +0900 Separate some utility commands to new file (#330) * Remove switch to use legacy version Remove `editorconfig--lagacy-version` variable. * Create editorconfig-tools.el and move some functions into it * Fix merge * Update commentary * Update CHANGELOG * Update text commit d73f126ddb44eba628a87df07f8fd7247c8221aa Author: 10sr <8.slashes@gmail.com> Date: Sun May 5 23:46:58 2024 +0900 Remove editorconfig-mode legacy version (#304) * Remove switch to use legacy version Remove `editorconfig--lagacy-version` variable. * Update CHANGELOG commit ea19d96a7afcd947ece8490d8d9846519ac53606 Author: 10sr <8.slashes@gmail.com> Date: Fri May 3 18:49:50 2024 +0900 Exclude some versions from test target (#329) nix-emacs-ci does not provide them any more. commit 641c8cd06abfd0cf99cc56eeca5458a03feec7c6 Author: Jen-Chieh Shen Date: Thu Mar 28 13:22:07 2024 -0700 ci: Bump Emacs 29.x to 3 (#327) commit 0eef782ae0ece28f0c446165febcf02f6207bb5e Author: Jen-Chieh Shen Date: Mon Mar 18 13:49:24 2024 -0700 feat: Add Zig support (#326) * feat: Add Zig support commit 4c7c96dee9ad7318b4df9414758cd46957cdb495 Author: USAMI Kenta Date: Tue Jan 9 12:24:11 2024 +0900 Add jsonian-mode (#320) commit 94f6fa546f85a49fea649d9c479f20613a36b9af Author: USAMI Kenta Date: Mon Dec 18 14:01:05 2023 +0900 Add php-ts-mode (#318) commit f6eba36c09840b3f1952fb8a542347741a4f3de9 Author: 10sr <8.slashes@gmail.com> Date: Thu Aug 3 00:05:49 2023 +0900 Add support for hcl-mode (#312) commit 4f0e71c9f9ae00fd6e90573c5c779da4c5f397ef Author: 10sr <8.slashes@gmail.com> Date: Wed Aug 2 23:45:29 2023 +0900 Temporarily remove test with windows-latest, emacs snapshot (#313) commit e81368ede389feb28d941c8e135c11e4bdf0160d Author: Jen-Chieh Shen Date: Wed Aug 2 07:25:26 2023 -0700 test: Emacs 29.1 (#311) commit dc571e9422a1713e252093b4ee0eb290841dc07c Author: 10sr <8.slashes@gmail.com> Date: Fri May 19 17:51:28 2023 +0900 Update CHANGELOG (#308) commit 8c1ec23fe6d9fc1d3e2ce24fe76503c88a4ebbc6 Author: 10sr <8.slashes@gmail.com> Date: Fri May 19 17:28:11 2023 +0900 Prepare v0.10.1 (#307) commit a415057ecfc5e89a903cb2e62a7d9d2596769532 Author: 10sr <8.slashes@gmail.com> Date: Fri May 19 17:07:23 2023 +0900 Fix compile warning of python-mode offset (#306) commit 94aa31702f7316db63411de8ded371f782d02baa Author: 10sr <8.slashes@gmail.com> Date: Fri May 19 16:51:48 2023 +0900 Fix when-let (again) (#305) * Fix compile of editorconfig-core * Use when-let* instead of when-let commit 3b2b213934e6648834f043623bdce2a3b816ece1 Author: 10sr <8.slashes@gmail.com> Date: Sun May 7 17:15:54 2023 +0900 Prepare v0.10.0 (#303) * Update CHANGELOG * Update CHANGELOG * Update version string commit ea22e6977eb64a38e19250b1fef3933b702d8a16 Author: 10sr <8.slashes@gmail.com> Date: Sun May 7 17:03:30 2023 +0900 Revert "Update version string" This reverts commit dfce47f4c5369711524c4da606201f33649bf894. commit 8ba886d3a64514ca6b558a19a3df7cf147f528f0 Author: 10sr <8.slashes@gmail.com> Date: Sun May 7 16:46:09 2023 +0900 Update version string commit c6769a3be9d5447bbf253681e731aa017de49872 Author: 10sr <8.slashes@gmail.com> Date: Sun May 7 16:17:58 2023 +0900 Check mode-class property for special modes (#301) In addition to checking parent mode commit 02bd633818a2db80b2bf5ebaaf3eaed76a0443ac Author: 10sr <8.slashes@gmail.com> Date: Sun May 7 15:59:34 2023 +0900 Load subr-x when compiling (#302) `when-let` depends on this. commit d7da0ea0fe118d88d032e81de65c79593c5181ea Author: Jen-Chieh Shen Date: Thu Apr 27 03:25:18 2023 +0800 Add support for gdscript-mode (#300) commit 93c418e7d385f55103d94a926b0ec051e51bceeb Author: Jen-Chieh Shen Date: Sun Apr 16 07:12:01 2023 +0800 fix: Fix compile warnings (#298) commit d21983b235c11f4a1845bd80e9d6ca25c9882f9a Author: Jen-Chieh Shen Date: Sun Apr 16 07:05:26 2023 +0800 Update copyright year (#297) commit 38f84cca9a68bca0e74bb4f50e178e6a9883c1f4 Author: Mohsin Kaleem Date: Mon Apr 10 00:46:35 2023 +0100 Add bash-ts-mode to editorconfig-indentation-alist (#296) Co-authored-by: Hong Xu commit 5f112084d762c05a6d31b9bd3c4619789614f842 Author: Simen Heggestøyl Date: Thu Mar 2 09:31:07 2023 +0100 Fix compilation warnings in Emacs 29 (#292) Fix a bunch of compilation warnings in Emacs 29 about wrong usage of unescaped single quotes in docstrings. commit 37b142e86513b2477c19defcf6798e362e5ba7bd Author: Jen-Chieh Shen Date: Wed Feb 15 23:12:21 2023 -0800 docs(README.md): Update development instructions (#291) commit 7f3c344e15e86a54390f4b3428432476b45d6c62 Author: Mohsin Kaleem Date: Sun Feb 12 06:17:01 2023 +0000 Add indent variable associations for numerous tree-sitter modes (#290) * Add indent variable associations for numerous tree-sitter modes * build: Correct csharp-ts-mode variable reference commit 26bc586c7e19dd00554f732f4313e07a0a18bb97 Author: Jen-Chieh Shen Date: Tue Jan 3 19:43:54 2023 +0800 Drop Emacs 24.x and 25.x (#286) * Drop Emacs 24.x and 25.x * test(build.yaml): Make fail-fast to false * Update CI test * docs: Update changelog * Revert author information commit d96709f3ddb7ce905e2ba1ff615ed875e26d6fdb Author: Jen-Chieh Shen Date: Thu Dec 29 05:46:11 2022 +0800 chore: Place emacs dependency to the front (#285) * chore: Place emacs dependency infront * Update copyright year commit 00913e8db3a864e7dbf8da7aa6ac355aeef3f999 Author: 10sr <8.slashes@gmail.com> Date: Mon Nov 7 12:00:26 2022 +0900 Prepare v0.9.1 (#281) commit b57c665de578b7510affa426478fadacef80f5d4 Author: 10sr <8.slashes@gmail.com> Date: Mon Oct 31 14:47:17 2022 +0900 Check `filename` rather than `buffer-file-name` for consistency (#280) Co-authored-by: Wade Zhang commit 35b360daebc6fc30723b5f361c65345dea0cc7f7 Author: 10sr <8.slashes@gmail.com> Date: Sun Oct 23 22:20:37 2022 +0900 Prepare v0.9.0 (#275) * Update version number in el file * Update CHANGELOG for 0.9.0 * Fix CHANGELOG * Fix release date commit 52d089efa733e0add922e07485cf8ac547bf9e3c Author: 10sr <8.slashes@gmail.com> Date: Sun Oct 23 22:13:13 2022 +0900 Fix package load for use-package usage (#277) commit b9c5af58e5059dad44a79a52790c2d913930d0ef Author: 10sr <8.slashes@gmail.com> Date: Sun Oct 23 20:47:55 2022 +0900 Add fixes for Emacs 29 (#276) * Fix warnings reported with Emacs29 snapshot * Disable vc feature for ert testings commit cc2fc3d25447dfa6271a9b6434478c2f140b4022 Author: Jen-Chieh Shen Date: Fri Sep 30 07:18:09 2022 +0800 tests(build.yml): Use latest minor version number (#274) commit 7e266d113ed69c487e25260527c3e39fa274662f Author: 10sr <8.slashes@gmail.com> Date: Mon Apr 18 14:41:07 2022 +0900 Add emacs 28.1 to test target (#270) commit bd35e505585a738cfed09f8d7fbcdac523f648bb Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 26 13:05:00 2022 +0900 Add doc about lsp-mode (#266) * WIP Add doc about lsp-mode * Update README commit 69582a19e4c40bbf2006c2fac6f61b8eb5c9d4e3 Author: 10sr <8.slashes@gmail.com> Date: Thu Sep 2 05:53:42 2021 +0900 Update CHANGELOG commit 3c47c18a72e98036d9ebf11350c3af9683d86c76 Author: 10sr <8.slashes@gmail.com> Date: Mon Aug 30 19:25:20 2021 +0900 Use new implementation by default (#263) * Use new implementation by default * Remove old test * Make editorconfig-hack-properties-functions deprecated commit 111a668e52f68706650d5624f16fd92c0c113f7b Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 13 22:01:38 2021 +0900 Prepare v0.8.2 (#262) * Update CHANGELOG * 2021 * Prepare v0.8.2 commit 4bcd7e2f12800d3a4566130f447533a1955a978a Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 13 21:55:02 2021 +0900 Update texi doc commit 7e71870e27d2ef23196127640ca3935cbdd4a432 Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 13 00:30:01 2021 +0900 Update debug message format (#261) commit 76fc064ee4ff6ab05db2c5004d7d4cd150b2fac1 Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 13 00:19:52 2021 +0900 Fix editorconfig-major-mode-hook (#260) commit db6ae0703c07568780c71dd92874886208536eaa Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 13 00:07:12 2021 +0900 Update README for NonGNU ELPA repository (#259) * Add NonGNU ELPA badge * Update README commit f3164820fc06a642bbc0eccadc5386ec98befb5b Author: 10sr <8.slashes@gmail.com> Date: Tue Aug 10 00:23:58 2021 +0900 Add some bug fixes to 20210221-testing (#258) * Rename internal function name * Update comment * Update -set-coding-system func name and doc * Add comment * Fix mode-hooks * Fix func name * Update -major-mode-hook function commit 5e0f23b64c822e7f2ff1d23c756e89c1c073c23c Author: 10sr <8.slashes@gmail.com> Date: Wed Apr 7 13:07:42 2021 +0900 Add fixes for compile warning commit b46c5dd667b68bfca204ff7424df8588dae12a56 Author: 10sr <8.slashes@gmail.com> Date: Wed Apr 7 12:02:07 2021 +0900 Make new impl work when changing major-mode (#255) commit 7375e7fdd21be087ffb52bf2917aefcaded3292c Author: 10sr <8.slashes@gmail.com> Date: Mon Feb 22 01:17:49 2021 +0900 Return early when expecting coding-system has been already set commit 13d8f9bb7bddf7f43091829fa361a336dbf2de61 Author: 10sr <8.slashes@gmail.com> Date: Sun Feb 21 22:41:57 2021 +0900 Add minor fixes to tests (#252) * Update Makefile targets * Update github actions task * Fix test macros * Update README commit ddce92ffcc92b79080949ad72801292fa2bafeb9 Author: 10sr <8.slashes@gmail.com> Date: Sun Feb 21 22:25:29 2021 +0900 Use flag instead of adding -2-mode for new version testing (#251) * Use flag instead of adding -2-mode * Fix test commit f18086a5b97625bcb51a4c8cb790efca80ef6d10 Author: 10sr <8.slashes@gmail.com> Date: Sun Feb 21 21:37:45 2021 +0900 Add debug message to -set-coding-system commit afe9f62ecfcba0ce92255fa18c4a1af0787ff3b0 Author: 10sr <8.slashes@gmail.com> Date: Sun Feb 21 21:06:19 2021 +0900 Move hack-properties-function run commit 2c7790d6eec32e486b448e2e40549d3f139227df Author: 10sr <8.slashes@gmail.com> Date: Sun Feb 21 20:58:40 2021 +0900 Update display-warning messages commit f8dc92d37b965370a2332e19609cebdddbbac406 Author: 10sr <8.slashes@gmail.com> Date: Sat Feb 20 01:56:22 2021 +0900 Fix for coding-system set when remote files do not exist (#250) commit 28108cc8b456cedbc2e895da1c1151a11571cd4f Author: 10sr <8.slashes@gmail.com> Date: Sat Feb 20 00:44:22 2021 +0900 Fix editorconfig execution for remote hosts via tramp (#249) commit 8086a8a45982b30a9620f723ce81994ed4ad26e1 Author: 10sr <8.slashes@gmail.com> Date: Sat Feb 20 00:14:23 2021 +0900 Update docstrings commit 69c8e3f766b2d458c5e3461c772cff69434962cd Author: 10sr <8.slashes@gmail.com> Date: Fri Feb 19 20:39:05 2021 +0900 Update debug message commit da2ede9ef13ae04ba4f1a37236052d9ce4c2e150 Author: 10sr <8.slashes@gmail.com> Date: Fri Feb 19 18:11:37 2021 +0900 Refactoring & add editorconfig-2-mode for beta test (#248) * Remove file type experimental feature temporarily * Do some refactors * Ignore failures of tests for file type feature * Make editorconfig-get-properties-function accept one argument * Implement editorconfig--advice-find-file-noselect * Define editorconfig-error * Implement advices * Update adviced function body * Update function name * Refactor exclude functions * Add more error handlings * Refactor editorconfig--advice-find-file-noselect * Add editorconfig-2-mode * Add nadvice to dependency list * Use display-warning instead of message for debug log * Update README * Fix editorconfig-2-mode for read-only-mode * Add test for editorconfig-2-mode commit d53e3da79f40ec879b1520b6f73c371f8a5cfc03 Author: 10sr <8.slashes@gmail.com> Date: Mon Feb 15 00:27:04 2021 +0900 Stop excluding remote files by default (#245) To exclude remote files again, add following to the init.el: (add-to-list 'editorconfig-exclude-regexps (eval-when-compile (rx string-start "/" (or "http" "https" "ftp" "sftp" "rsync" "ssh") ":"))) commit 968bb5fb871e0076a4779f78526e3ad91777e60c Author: 10sr <8.slashes@gmail.com> Date: Tue Jan 12 18:01:07 2021 +0900 Do not run editorconfig-apply on recentf-save-file (#241) commit a6c64cc26d5d237f6b3c53e8d637af96c428a5f7 Author: 10sr <8.slashes@gmail.com> Date: Fri Jan 8 13:28:50 2021 +0900 Use revert-buffer-with-coding-system to set coding system (#236) * Use revert-buffer-with-coding-system to set coding system * Avoid infinite call * Do not ask user for revert when buffer is not modified * Refactor -set-coding-system * Do not use revert when the file does not exist yet * Refactor -set-coding-system commit 9605f6bf4408e4a5025dc6862fba96de347b9332 Author: 10sr <8.slashes@gmail.com> Date: Thu Dec 24 05:26:25 2020 +0900 Remove travis.yml (#238) commit c73b0cf3fcc4dd5ff1e268d54d20ab6e88cd6b2e Author: 10sr <8.slashes@gmail.com> Date: Wed Dec 23 15:36:45 2020 +0900 Update README 2 (#225) * Update README 2 * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md commit bba5bdaef41895bf528f00923e8f1ce249a93641 Author: 10sr <8.slashes@gmail.com> Date: Wed Nov 25 15:31:14 2020 +0900 Add github actions badge commit ee39cf38f4efda519db947dd850a6522836561c5 Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 7 08:00:19 2020 +0900 Do not init submodule in Makefile commit 4def6c96944c8e704f4424d10fcd1a73076709c6 Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 7 07:21:43 2020 +0900 Add Github Actions build.yaml commit 49cf213f30d027aae34b3d499aa637cb1cca5f38 Author: Brian Leung <29217594+leungbk@users.noreply.github.com> Date: Sun Nov 22 07:42:16 2020 -0800 Silence byte-compiler warnings (#235) Move aliases before their referents Co-authored-by: 10sr <8.slashes@gmail.com> commit d4fabc95b8b2af5d7ead1b1e8065c69d5805d6b4 Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 7 07:22:32 2020 +0900 Add Emacs 27.1 to test target (#228) * Add Emacs 27.1 to travis test target * Add GitHub Actions build.yaml * Fix evm 27.1 version * Remove github actions build.yaml commit 1defe4a4cd0fa7f57c0013e6efc535bb02f827cd Author: 10sr <8.slashes@gmail.com> Date: Fri Jul 31 00:31:28 2020 +0900 Fix references in CHANGELOG (#226) * Fix issue references in CHANGELOG * Fix commit reference link commit 88efaca117ef6abd3bdee39de7b4b64628e59796 Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 30 22:37:30 2020 +0900 Update CHANGELOG commit c8c7845c73d08bd21235bc79eafa887651990a6f Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 30 22:34:36 2020 +0900 Add doc about make sandbox commit 8c551d92bacea8d6ea1b73e945ab5600f7608a78 Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 30 22:32:29 2020 +0900 Update README to help bootstrap users (#219) * Update README to help bootstrap users * Update doc * Fix doc * Update * Updat commit c0789e2d537fb609af72a1edf51e1c5e4673ab2e Author: 10sr <8.slashes@gmail.com> Date: Fri May 22 23:13:55 2020 +0900 Keep a CHANGELOG (#221) * Add empty CHANGELOG.md * Generate CHANGELOG template ```python #!/usr/bin/env python3 import subprocess def _get_tag_date(tag): git_show = subprocess.run(["git", "show", tag, "--format=%cd", ... ..."--date=short", "-s"], capture_output=True) return git_show.stdout.decode("utf-8").strip() def main(): git_tag = subprocess.run(["git", "tag"], capture_output=True) versions = list(reversed([e[1:] for e in git_tag.stdout.decode... ...("utf-8").split("\n") if e])) for version in versions: print(f"## [{version}] - {_get_tag_date('v' + version)}") print() print() print(f"[Unreleased]: https://github.com/editorconfig/... ...editorconfig-emacs/compare/v{versions[0]}...HEAD") for version, version_prev in zip(versions, versions[1:]): print(f"[{version}]: https://github.com/editorconfig/... ...editorconfig-emacs/compare/v{version_prev}...v{version}") print(f"[{versions[-1]}]: https://github.com/editorconfig/... ...editorconfig-emacs/releases/tag/v{versions[-1]}") return main() ``` * Paste release notes from github releases * Add release note for unreleased * Fix line commit 68e940e0fd312848d18aba93b49285d7a8d74182 Author: 10sr <8.slashes@gmail.com> Date: Tue May 19 20:28:23 2020 +0900 Add conf-mode abbrev-table definitions (#220) commit dc9dc966f973d9e9f2992004beb462bc5813c01c Author: 10sr <8.slashes@gmail.com> Date: Wed Feb 12 16:39:43 2020 +0900 Update hook docstrings (#215) #214 commit 5aa20f73ddbf5df60a9c66b219846d94c9d12a7d Author: 10sr <8.slashes@gmail.com> Date: Wed Feb 12 15:56:48 2020 +0900 Define -mode-apply as an interactive command (#216) commit 39175259174ba0eea3529fc4039fbd90c5990ecc Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 16 17:59:07 2020 +0900 2020 commit d29d6f1254f018cdc696cf40614e6799e2673f64 Author: 10sr <8.slashes@gmail.com> Date: Fri Dec 20 16:31:15 2019 +0900 Update README commit d24e05ccd13c44380dbbbc4756eb02ede3882b9e Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 23 13:39:46 2019 +0900 Use elisp core by default Closes #198 commit 42d9b6aebd4488d6862ff39238a284408e5e4370 Author: 10sr <8.slashes@gmail.com> Date: Fri Dec 20 16:31:40 2019 +0900 Remove a trailing whitespace commit 347e0171ad3cfcb70c0aca73b7b6fa8a5875dae6 Author: Damien Cassou Date: Wed Nov 27 06:29:43 2019 +0100 Fix typos (#212) Typos found with codespell. commit 7915da05ee67bf5c5356ddd49400e9facc15d004 Author: 10sr <8.slashes@gmail.com> Date: Fri Oct 25 16:59:30 2019 +0900 Fix that "?" does not match "/" commit 480998f061d22444571f05b6c10d190c204c227e Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 23 14:32:21 2019 +0900 Update core-test commit 63fa8f9e4bc2938e7bc02b97da79335db29bf0e0 Author: 10sr <8.slashes@gmail.com> Date: Thu Oct 10 13:44:34 2019 +0900 Bump version to v0.8.1 commit b7d3a15f606582d30590fab8bbf0202fd7351c90 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 8 13:55:05 2019 +0900 Fix support for Emacs<26 commit 19bad72db735c032e773b6201a80a5df2597c0f4 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 8 13:40:49 2019 +0900 Add editorconfig-file-type-emacs-whitelist value commit a179c9876f8f1fd343559aad13a32b96a651e86a Author: 10sr <8.slashes@gmail.com> Date: Mon Oct 7 22:34:03 2019 +0900 Disallow setting mode when it is not listed in whitelist commit cb218f4b5adc10faa2f89c4ec85bfafa7ad0600a Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 8 14:10:09 2019 +0900 Use dist: trusty commit ae5fb296026f948103ade4e7e42f3989dda44df7 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 8 14:04:41 2019 +0900 Update travis Emacs26 version commit 5e9769675fbf76566ca10f30c148f385396796ae Author: Jay Kamat Date: Mon Jun 17 06:43:54 2019 +0100 Add support for bpftrace-mode (#199) commit 875088b1c587451916accd2474d57c66d05be1c6 Author: 10sr <8.slashes@gmail.com> Date: Mon Jun 3 20:24:18 2019 +0900 Add explicit support for rpm-spec-mode commit 0faf4dc29c6c504a3026601b6035ff0735a0839b Author: 10sr <8.slashes@gmail.com> Date: Mon Jun 3 19:28:20 2019 +0900 Make editorconfig-properties-hash permanetn-local commit f511979e3c172932ba51b4b8e1172897f786c834 Author: 10sr <8.slashes@gmail.com> Date: Tue Apr 2 15:55:33 2019 +0900 Update message format for version info Update message format for version info commit efc11ec6fd100b2c19950153b1f6e64d85c36d97 Author: 10sr <8.slashes@gmail.com> Date: Tue Mar 26 23:20:10 2019 +0900 Make -version print packaging version commit c2ea49f01fbdc144e623c30cbb8b6bf4439ac6b5 Author: 10sr <8.slashes@gmail.com> Date: Tue Mar 26 20:24:31 2019 +0900 Bump version to v0.8.0 (#192) commit c6e817a36b2d901a837f373748941ff1246081f8 Author: 10sr <8.slashes@gmail.com> Date: Sat Mar 23 21:40:49 2019 +0900 Use API to get version info (#193) commit 0cf6ce9534a35823f534014ec941db2a690f9002 Author: 10sr <8.slashes@gmail.com> Date: Mon Feb 25 19:49:56 2019 +0900 Use https for melpa badge commit 695fce14c0f2cfc72520356cc9d6c46ed3fff33a Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 24 14:49:05 2019 +0900 Update plugin-tests submodule commit 1651d96aa2909d7f49c7e06a893c464e6f1fa2d9 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 24 14:48:26 2019 +0900 Do not update submodule when running tests commit ff0ed217461484a45ab8be7a8aa11c8b503f2388 Author: 10sr <8.slashes@gmail.com> Date: Tue Jan 22 13:59:50 2019 +0900 Use reference link commit 5632843e840d0e8dee819d283b8d0a2ae88b8fa8 Author: 10sr <8.slashes@gmail.com> Date: Fri Jan 18 13:17:15 2019 +0900 Update README commit 570502fdbb5e7634a43178805caae16e709ba9d7 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 17 14:10:15 2019 +0900 Update docstring commit b36f495d1510a53c63e42d6f48513b2fc3fc5b45 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 17 12:38:25 2019 +0900 Separate tool functions commit f295ca7cb2e64a8312a172b53b5eee7f06f8ac6e Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 17 11:23:49 2019 +0900 Use -*- lexical-binding: t -*- https://github.com/melpa/melpa/blob/master/... ...CONTRIBUTING.org#fixing-typical-problems commit 2d342a1dc75d800577526bd5b62e2f2e350f2447 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 17 11:16:59 2019 +0900 Fix function name commit ec5576f7a9ae86649332414995124a3355ae5c13 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 17 11:13:37 2019 +0900 Add fixes for package-lint commit bd9e60c65cd8dd1fdc0f6fe35b2684bc2c4c2d80 Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 17:09:18 2019 +0900 Update README commit 551fcd4dc2556506e95c26898d864743cfb379c8 Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 17:14:18 2019 +0900 Update commentary section commit 8352b3f1d06aefcc4f8f6b7da760ced921efe93e Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 16:52:49 2019 +0900 Remove comment commit 51d2849fb6aaf195393f37dfbd1573d0b449df9b Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 16:44:59 2019 +0900 Update year commit 9b36c88ce02325e755ce07ebbfd6622b67619d63 Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 16:43:13 2019 +0900 M-x checkdoc commit 68d488ee67e6fa06b9b596f178d445b28bab2865 Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 16 14:24:46 2019 +0900 Add struct docstring commit feddcd841a913b8f1a79251bb347a2d3b00a06ae Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 10 14:40:30 2019 +0900 Remove useless spaces commit f735659b421c5f72bc6c137fd7717a1931ce719d Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 10 14:31:53 2019 +0900 Stop using cl-defclass With Emacs<25 cl-defmethod cannot used for structs commit 56fa185bcec16e2fb97b71a4e6dee0c5ef2b6256 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 10 14:30:55 2019 +0900 Revert "Add support for Emacs24.5" This reverts commit 103081756d5d1de03dfa2d9d42b6e4a8581fca29. commit 026b21393284b9328fec956dae28c26dab1903e6 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 10 14:13:21 2019 +0900 Add support for Emacs24.5 commit 2aabf655a964a7a172de66391cfdd1d598e2e8f1 Author: 10sr <8.slashes@gmail.com> Date: Thu Jan 10 13:48:52 2019 +0900 Refactor handle lib commit d40048455064be9e090828b4cb28f86f922eae85 Author: 10sr <8.slashes@gmail.com> Date: Wed Jan 9 13:29:46 2019 +0900 Use 0.8.0 for next version commit 7a17d5ea063030313726104a3a1895bb6eb7021f Author: 10sr <8.slashes@gmail.com> Date: Tue Jan 8 16:08:04 2019 +0900 Remove unused tests commit 4f20ce1e1cbf3de1284f8de988ea12a2dcdfa690 Author: 10sr <8.slashes@gmail.com> Date: Tue Jan 8 15:58:29 2019 +0900 Get alist result from hash result commit 69768d1bd108d93d392b2d8eb5750d8b8ddca169 Author: 10sr <8.slashes@gmail.com> Date: Tue Jan 8 11:27:44 2019 +0900 Implement --hash-merge commit c36d66e3421dfbcdfa9f9221b900f3c8fbde8882 Author: 10sr <8.slashes@gmail.com> Date: Mon Jan 7 20:29:20 2019 +0900 Update get-properties-hash commit 75d0158b6c5c1723a1d21f8c4ebdc37b91aa9d1c Author: 10sr <8.slashes@gmail.com> Date: Mon Jan 7 12:21:09 2019 +0900 Add function to get properties from handlers as hash commit e8ac4bf5d3d7e70ea815f68d64933330a7ffc1d9 Author: USAMI Kenta Date: Tue Dec 25 21:05:37 2018 +0900 Use Markdown's code spans instead of Emacs style `' (#186) commit 77775d90c383c5ddd0c4f9564d022ef971c9f7c3 Author: 10sr <8.slashes@gmail.com> Date: Tue Dec 25 11:49:07 2018 +0900 Bump version to 0.7.14 (#185) commit e25ac0d49ff1e1982d58198efab35f3bd2c368d4 Author: 10sr <8.slashes@gmail.com> Date: Mon Dec 17 16:24:27 2018 +0900 Add document for editorconfig-trim-whitespaces-mode commit 29060e8494a4ee2bccae7114cdf148387bce2f47 Author: 10sr <8.slashes@gmail.com> Date: Sat Dec 15 16:46:07 2018 +0900 Add variable editorconfig-trim-whitespaces-mode commit 1327acab8d855d479d9d087129d05de671da8c76 Author: 10sr <8.slashes@gmail.com> Date: Mon Dec 3 19:41:49 2018 +0900 Use princ instead of message to write to stdout commit d22c30f408fb2447047e8413dc5ca435b062b933 Author: 10sr <8.slashes@gmail.com> Date: Mon Dec 3 18:54:25 2018 +0900 Update core-test submodule commit 88b2303a1f28a1b257fb5c205fa36428219197e7 Author: Terje Larsen Date: Sat Nov 17 23:16:12 2018 +0100 Use ws-butler when enabled and available. When having auto-save on and you edit text the cleaning up of white-space is a bit intrusive and removes the space at the end of the line where you are writing. `ws-butler-mode` is an alternative that does take this into account. commit 550897776f79f4e5395fe00924bdf620982f5b47 Author: 10sr <8.slashes@gmail.com> Date: Thu Nov 15 16:09:02 2018 +0900 Fix hack-properties-functions example commit 8241f65395cd78b83a59d5cfc1c682ef1ead90cd Author: 10sr <8.slashes@gmail.com> Date: Thu Oct 25 13:21:50 2018 +0900 Fix README and texi commit dff69487901d0074b1fdad8c91e69b40e5e6543e Author: 10sr <8.slashes@gmail.com> Date: Wed Oct 24 13:41:30 2018 +0900 Update document commit 9ca51506778b486d947cba5dabd318614ebc5628 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 14:48:34 2018 +0900 Add test for -hack-properties-functions commit 07ae870dbb2fdc4ec70c440e355bd126d124dce6 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 14:27:56 2018 +0900 Call -hack-properties-functions in editorconfig-apply commit adfb8c54ba4ea5d52a558bd97221f40a5495e170 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 14:18:46 2018 +0900 Add variable -hack-properties-functions commit 28c4846e9cac199ff4c357033a80054017687b90 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 14:04:22 2018 +0900 Fix version when -custom-hooks has marked as obsolete commit 88824e7be5b7492845d914110e07328a93901e05 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 13:56:46 2018 +0900 Update texi for hook name change commit e11f186800af869897400eb2be72f7ec4c3379d2 Author: 10sr <8.slashes@gmail.com> Date: Tue Oct 23 13:51:32 2018 +0900 Use derived-mode-p for major-mode check (#180) commit 791cb6777301fb22f97538471904188deb4b05ec Author: 10sr <8.slashes@gmail.com> Date: Fri Oct 19 19:13:19 2018 +0900 Update README.md for hook name change commit 1138109d4b29c2c8e8e360f9d9314d7081e4fbb4 Author: 10sr <8.slashes@gmail.com> Date: Fri Oct 19 19:01:42 2018 +0900 Change hook name -custom-hooks -> -after-apply-functions With obsolete-variable-alias commit ff38e8046be032e0d84a5d326dd68d3f40ea449e Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 25 18:26:43 2018 +0900 Do not call mode func when current mode is a child mode of target (#179) commit 5fff8e44195d91f967b4bacc2562026c7bcfda01 Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 25 15:40:52 2018 +0900 Use file_type_ext for test fixtures commit 20f627f9caf32d65509a8a536743c5960d52a8e0 Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 25 14:19:56 2018 +0900 Do not call major-mode when already enabled (#178) commit 5a71b05195abc14e84970ba66d4ec2987627266d Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 25 11:55:59 2018 +0900 Make conf-mode used when a file has .editorconfig extension commit 46fff5b32a0a7b014dda9a970ca99ad8c35a05d3 Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 25 11:52:16 2018 +0900 Add file_type_ext to conf-mode keyword commit 1bbbf78990925bfcb426b2752dc09cfd6ae5ba22 Author: 10sr <8.slashes@gmail.com> Date: Sat Sep 22 15:25:02 2018 +0900 Rename existing function set-major-mode -> set-major-mode-from-name commit 780fc5f46ecda16c31c82b03d12ab392576db5f4 Author: 10sr <8.slashes@gmail.com> Date: Sat Sep 22 15:19:47 2018 +0900 Update doc commit 82ba59023e3df7560e24dc4a5797bf92bcbc7656 Author: 10sr <8.slashes@gmail.com> Date: Thu Sep 20 16:54:51 2018 +0900 Set major-mode from file_type_ext value commit 2fbbea8e862c80ee7c3cc463980b1a20835b0346 Author: 10sr <8.slashes@gmail.com> Date: Fri Sep 21 13:43:11 2018 +0900 Add ert-test for file_type_ext commit 7524e641cacbc570a8a4c159fc8d2ef08e753584 Author: 10sr <8.slashes@gmail.com> Date: Sat Sep 22 17:44:47 2018 +0900 Add ert-test for file_type_emacs (#177) commit aeb53c0d1c5dc1bdf854a77ac21d746571b14fa3 Author: 10sr <8.slashes@gmail.com> Date: Sat Sep 22 17:40:14 2018 +0900 Make `fixtures' a constant (#176) commit 0f5926619f0d77b0a32fbe17730a2d04d93f1e4e Author: 10sr <8.slashes@gmail.com> Date: Tue Sep 4 11:12:01 2018 +0900 Update texi for HTTPS url commit 29cc1456c06d392bff1368c935083a23f4375274 Author: 10sr <8.slashes@gmail.com> Date: Mon Sep 3 16:48:36 2018 +0900 Use HTTPS link (#174) commit 8a602e176a068bc952a685086157a0caf4025806 Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 31 14:11:41 2018 +0900 Update doc commit b61e4feedb5108e2c555f818251fcb2af3725ba6 Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 31 16:40:54 2018 +0900 Update header.txt commit 8e91d9fe91d39b4984650c487206e138c87f65ca Author: 10sr <8.slashes@gmail.com> Date: Fri Aug 31 16:13:56 2018 +0900 Update Makefile for info generation commit 75698b1b333992b1ee300c1b82e6409297b539ee Author: 10sr <8.slashes@gmail.com> Date: Thu Aug 23 13:52:57 2018 +0900 Bump version 0.7.13 commit 5a71d819a6104c9ce8ac7f448579d3380113eed5 Author: 10sr <8.slashes@gmail.com> Date: Fri Jul 27 15:49:16 2018 +0900 Fix brackets tests (#172) commit 44ff0c5adcdc6d621967b0861e720c7b16ef3543 Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 26 12:50:33 2018 +0900 Clear translate cache on file reload commit ca36030e7e1b3f7feadc8cd1788aae4f46f5adfe Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 26 12:30:09 2018 +0900 Remove numeric-range related vairables commit c687ecda080521c00ceaa8aec05a7dd8fb2be48a Author: 10sr <8.slashes@gmail.com> Date: Thu Jul 26 12:22:08 2018 +0900 Stop checking numeric range separately commit 2dd122c2bb9bf6fc09a53f32a27c84753465e747 Author: 10sr <8.slashes@gmail.com> Date: Sun Jul 8 18:00:37 2018 +0900 Disable delete-trailing-whitespace when buffer-read-only is nil commit 898a6d84041d5c7c562e11ca3ccb59b7b3bd62e8 Author: 10sr <8.slashes@gmail.com> Date: Sun Jul 8 17:53:50 2018 +0900 Check editorconfig configs when read only state changes commit e3e54b58970742f3ef40793a7f5e14850f45f00e Author: 10sr <8.slashes@gmail.com> Date: Sun Jul 8 18:10:03 2018 +0900 Add trim-trailing-ws tests With case where read-only-mode is enabled commit 1a760c97803abf8471e33c122dbd29987fddb5a5 Author: 10sr <8.slashes@gmail.com> Date: Wed Jun 20 01:26:01 2018 +0900 Use emacs 26.1 instead of 26-pretest (#166) commit 808922da89517828d6e8eddb614d3919c94b8b56 Author: 10sr <8.slashes@gmail.com> Date: Wed Jun 20 01:08:38 2018 +0900 Bump version to 0.7.12 commit ac553270b14d31d57609de3186b60c6d2b3154e6 Author: 10sr <8.slashes@gmail.com> Date: Wed May 9 13:28:47 2018 +0900 Fix info top page (#165) * Fix info top page * Parametrize texi top title commit 2a35c763422b59e2e2dcdbd6ca842843672bf155 Author: 10sr <8.slashes@gmail.com> Date: Wed May 9 11:04:46 2018 +0900 Add commented allow_failure commit 9f4640807fe33a2021c20c0bd3f3dc076f00a54b Author: 10sr <8.slashes@gmail.com> Date: Wed May 9 10:53:58 2018 +0900 Fix batch command for emacs26-pretest testing commit 8c2357c850782b84d5f90d41503c45d6a136df49 Author: 10sr <8.slashes@gmail.com> Date: Tue May 8 12:21:58 2018 +0900 Update travis config file commit e7286c67000425551b13cc80e2ede5982a6a4649 Author: 10sr <8.slashes@gmail.com> Date: Mon May 7 14:54:37 2018 +0900 Use whitespace class commit 09229ed40ef583dc9fd4d8a683d7077ba71e1b09 Author: 10sr <8.slashes@gmail.com> Date: Mon May 7 13:04:51 2018 +0900 Add test for various normal whitespace Currently core-handle fails to parse files that contain whitespaces like line breaks, horizontal space, vertical space, etc. #161 commit 87fbfa3cea902380db512b7890cda07f872b9a07 Author: 10sr <8.slashes@gmail.com> Date: Mon May 7 11:52:54 2018 +0900 Remove unused variable commit adabfa6aea82255ea603e0cd13c69c43f50fcba8 Author: 10sr <8.slashes@gmail.com> Date: Sat May 5 02:55:20 2018 +0900 Add .gitignore again commit 14fbef761792145cc715418de3baae3485d5c386 Author: 10sr <8.slashes@gmail.com> Date: Sat May 5 02:52:36 2018 +0900 Update texi commit c9aafbcb9baceb5d3e7d5300c12788d21f642da4 Author: 10sr <8.slashes@gmail.com> Date: Sat May 5 02:52:19 2018 +0900 Fix make doc command commit 61384245f0e0b2185103f2647178cda6ef5586a8 Author: 10sr <8.slashes@gmail.com> Date: Sat May 5 02:31:03 2018 +0900 Remove .info and add .texi commit f8216577840405d6ddf0649bb9f1a2cca8b18f77 Author: 10sr <8.slashes@gmail.com> Date: Sat May 5 02:30:37 2018 +0900 Remove doc/.gitignore commit b3fbb8cb2bc75b1d277a38491418704cffd72e6f Author: 10sr <8.slashes@gmail.com> Date: Fri May 4 23:27:03 2018 +0900 Fix Makefile commit 427ddeed978c6354f0ec33286da1c0bf70ad3a14 Author: 10sr <8.slashes@gmail.com> Date: Sun Apr 29 14:21:47 2018 +0900 Add doc/.gitignore commit 31709798cace8eae8c4a8bebb9c25f9f50913506 Author: 10sr <8.slashes@gmail.com> Date: Sun Apr 29 14:21:25 2018 +0900 docs -> doc commit 0ce9c9839b72edad9b4cab9ef030173f1bcd37e9 Author: 10sr <8.slashes@gmail.com> Date: Sat Apr 28 13:46:35 2018 +0900 Add generated info file commit 5db2fd4c8abce7ca169233dc5cec3c4fdefc017e Author: 10sr <8.slashes@gmail.com> Date: Sat Apr 28 13:44:22 2018 +0900 Add make info target commit 12a79fff988a8385f9762a7db5e51fac334e2135 Author: Jay Kamat Date: Thu Apr 5 19:40:58 2018 -0400 Add tests for lisp-indent-offset ignore commit 6b92956a84498ace196d58b237602e653e22693c Author: Jay Kamat Date: Thu Apr 5 19:15:04 2018 -0400 Add variable to disable indent_size when conditions are met for lisp commit 816bab2d5b6eb7508ce6811e1e116166eca8192c Author: 10sr <8.slashes@gmail.com> Date: Fri Mar 30 13:48:30 2018 +0900 Add csharp-mode support (#154) commit b405ca428e2a67dd286ae1bd8cd75ac3a5dd6179 Author: 10sr <8slashes+git@gmail.com> Date: Sun Feb 11 00:50:44 2018 +0900 Fix fnmatch for new cases commit 4336c8bde838ce991fc0f3c70dd3471b6adb268a Author: 10sr <8slashes+git@gmail.com> Date: Sun Feb 11 00:50:23 2018 +0900 Add two test cases for fnmatch commit f56964cd65075198b1173d58802666dedc434535 Author: 10sr <8slashes+git@gmail.com> Date: Sat Feb 10 23:34:10 2018 +0900 Update core-test submodule commit ffe4396e53939da21aa6c0edbaf33dfe7a1c1d26 Author: 10sr <8slashes+git@gmail.com> Date: Tue Nov 7 20:01:20 2017 +0900 Prepare v0.7.11 commit 2cc03ae806ae0d89b0cb6812cc009419656a3055 Author: Jay Kamat Date: Fri Oct 6 00:29:13 2017 -0400 Change hook editorconfig is applied on (#143) Change from `after-change-major-mode-hook' to `change-major-mode-after-body-hook' to allow dir-local variables to take precedence over editorconfig. Closes #141 commit 9c67d568df7cf2156c07fce2909484c0c68756ef Author: 10sr <8slashes+git@gmail.com> Date: Wed Aug 16 13:06:11 2017 +0900 Fix typo commit 276097b635687dd7d337de96fd74b07b199dc3b5 Author: 10sr <8slashes+git@gmail.com> Date: Wed Aug 2 18:38:19 2017 +0900 Add apache-mode support (#135) commit 2e343c46610b6097d8102cff682e6c6f024ada35 Author: 10sr <8slashes+git@gmail.com> Date: Mon Jul 24 19:03:40 2017 +0900 Add file_type_emacs to editorocnfig-conf-mode keywords commit 8dd4394ab9f3bd00467fc70061d6950461cec6bf Author: 10sr <8slashes+git@gmail.com> Date: Mon Jul 24 18:48:33 2017 +0900 Add file_type_emacs entry for .editorconfig commit 489e2e58f19fc07ad0e468c6a444341d9b6ddaa8 Author: 10sr <8slashes+git@gmail.com> Date: Mon Jul 24 18:48:03 2017 +0900 Add file_type_emacs support commit 599d3791e45fc1be2c7d96661646a5a2ff16ca14 Author: 10sr <8slashes+git@gmail.com> Date: Mon Jul 24 18:14:16 2017 +0900 Add document about file_type_emacs property commit edfd7d9819bbac50bf399713d7c71b3af39866cc Author: 10sr <8slashes+git@gmail.com> Date: Wed Jun 7 23:13:31 2017 +0900 Prepare v0.7.10 commit 12af7738a0a9e9c693e41f55a1b536e4f44030fd Author: 10sr <8slashes+git@gmail.com> Date: Wed Jun 7 23:12:30 2017 +0900 Add function to open nearest .editorconfig file (#131) commit 0aeb78198993e803217782b7c8bf6638e5a9fbdc Author: 10sr <8slashes+git@gmail.com> Date: Wed Jun 7 22:48:47 2017 +0900 Always do submodule update when test-ert commit 71fc634a96a237a9aa9e25972885e932b5e40377 Author: Simen Heggestøyl Date: Thu May 18 13:54:19 2017 +0200 Set `fill-column` directly Set `fill-column` directly instead of using `set-fill-column`. That function is useful when used interactively, but when called from Lisp it’s almost equivalent to just setting `fill-column` directly, and it avoids showing the “Fill column set to…” message. commit 4cda53e796b2d972353cc7d3da7d1d1a571aea6e Author: Jay Kamat Date: Fri May 12 09:07:21 2017 -0700 Add support for feature mode. (#128) commit a3242c35afcab0df8f3fe0a2fae4e54d157203b8 Author: 10sr <8slashes+git@gmail.com> Date: Wed Apr 26 13:55:52 2017 +0900 Update editorconfig-conf-mode lighter text commit 61911bc92d70abd66acf4d6e648945e2a2a6ec39 Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 18 13:25:36 2017 +0900 Fix assignment to free variable warnings Fixes #127 commit a3100e700498fcb694948bf26250cfd939031bf7 Author: 10sr <8slashes+git@gmail.com> Date: Fri Mar 10 13:06:57 2017 +0900 Catch error thrown from editorconfig-custom-hooks And show it as warning. commit c54fd3abe5b8d4a6997de147afbc645896b0d55c Author: Jay Kamat Date: Wed Feb 22 21:50:06 2017 -0500 Add support for verilog-mode commit 75f1f7f934fdbe6801596466f6ab176b80f2c069 Author: 10sr <8slashes+git@gmail.com> Date: Wed Feb 22 00:37:12 2017 +0900 Prepare v0.7.9 Closes #122 commit ed06e323f9953c60d9cb32d42700407ec50c7327 Author: 10sr <8slashes+git@gmail.com> Date: Wed Feb 22 00:38:08 2017 +0900 Update year in copyright commit 3e2ec93953f6666bcca3c0b4b5252524cd3d7edd Author: 10sr <8slashes+git@gmail.com> Date: Fri Jan 13 13:02:04 2017 +0900 Update README for some variables commit 399451141873347e974ee1c2cd2f13c1ee070ffc Author: 10sr <8slashes+git@gmail.com> Date: Wed Jan 4 14:24:22 2017 +0900 By default always use Emacs Lisp Core when accessing remote files (#118) commit 426699c7c7944438cfc6481fd06cd4610f5d3881 Author: 10sr <8slashes+git@gmail.com> Date: Tue Jan 3 15:17:53 2017 +0900 Add more plugin tests commit dbfe7a208ac799069e723e46b77715436ae18b33 Author: 10sr <8slashes+git@gmail.com> Date: Tue Jan 3 14:38:22 2017 +0900 Add plugin-tests submodule commit 0496bfa0e5a74062513e9af106693afefb7d17ae Author: 10sr <8slashes+git@gmail.com> Date: Tue Jan 3 14:03:45 2017 +0900 Fix indentations of ert-tests/ See #111 commit b6b64127d7f489a48f0761f4446b11b54e5f2f11 Author: 10sr <8slashes+git@gmail.com> Date: Mon Dec 12 14:44:41 2016 +0900 Add php-mode to indentation-alist and add a short note About `php-mode-coding-style'. They basically do this at mode startup: "if php-mode-coding-style is 'pear' (which it is by default), add a c-style called 'pear' and switch to it", and that style contains a c-basic-offset value. But since we're hooking later than that, we're welcome to override c-basic-offset without any risk. Also, php-mode suggests manually typing "nxml-mode" and "js2-mode" and "web-mode" and then "php-mode" etc, to switch editing styles if you have a document with multiple types of content (which is common in .php files), and every time you type php-mode, it runs that style injection again and resets c-basic-offset. However, editorconfig runs as a hook when the major mode changes, so it still re-applies the correct offset every time that happens. See #116 for more details. commit daa0c0f096b5bf96f4027d4a006a3e6446c4b932 Author: Hong Xu Date: Tue Nov 8 00:09:10 2016 -0800 Add Usami Kenta to the contributor list. commit 005c313b4eaba2372d31d709899a1f2c33310d0c Author: Hong Xu Date: Tue Nov 8 00:06:51 2016 -0800 Reidentation for all *.el files. commit 98a370e88960298cfbdb527d40fed3747e41da8a Author: Hong Xu Date: Tue Nov 8 00:01:16 2016 -0800 Massive reformatting of docstrings. commit afadf377f9a82a66519189088cadddda376a1c9d Author: Hong Xu Date: Mon Nov 7 23:51:08 2016 -0800 Fix a doc string. commit b540d0719fe9b1059781e6cf50b21b333b2c5433 Author: USAMI Kenta Date: Tue Nov 8 16:13:41 2016 +0900 Add editorconfig-exclude-prefixes (#108) commit c545c8842a627b1d63c00280d504247ef2658b3d Author: Hong Xu Date: Sat Nov 5 22:12:33 2016 -0700 Reindent using Emacs-lisp style. commit a0b3e7037f1bb043f281e3b08423698976950b33 Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 6 13:37:54 2016 +0900 Add one space to editorconfig-mode lighter text commit d7bba76ba52fe64840c19bef9938f09ab1f40ca2 Author: Hong Xu Date: Sat Nov 5 09:44:41 2016 -0700 Add a :lighter "EditorConfig" for editorconfig-mode. commit 4e8ed00b9afe73165dc25a222890ceb8fa03ad81 Author: USAMI Kenta Date: Mon Sep 5 06:31:28 2016 +0900 Modify defgroup tag commit 79bcc708530a7ed353aafa1e9ca07ff8758e068d Author: 10sr <8slashes+git@gmail.com> Date: Tue Aug 9 14:12:21 2016 +0900 Revert "Use truename for editorconfig name" (#106) * Revert "Use truename for editorconfig name" This reverts commit f9edfc16bc5d7e3f795025ac6fa3d6608634e18a. Not an important thing, and caused a regression reported in #105. * Bump version to 0.7.8 commit 1c32816351644dd97f4b3c153eb4394bb7b206e7 Author: 10sr <8slashes+git@gmail.com> Date: Tue Jul 19 21:59:02 2016 +0900 Bump version to 0.7.7 commit 8a5e621265c4a5cb92876015699793f884876769 Author: 10sr <8slashes+git@gmail.com> Date: Fri Jul 8 12:12:30 2016 +0900 Avoid asking coding system when not specified (#102) Why ? In short: Emacs always asks which charset to use when editorconfig-mode is enabled, .editorconfig does not exist and trying to save files with non-ascii characters. This is an annoying behavior so stop it. Calling `set-buffer-file-coding-system` sets the "explicit" flag, and it is used just before saving files. When this flag is set but the charset is `undecided`, Emacs asks users what charset to use for saving files with non-ascii characters (when this flag is not set Emacs do not ask and decide to use something automatically, `utf-8` for my environment). This typically happens when editing files in repositories without .editorconfig, and it is a bit annoying behavior. This change makes this plugin not call `set-buffer-file-coding-system` at all when neither `charset` nor `end_of_line` is provided, thus Emacs can decide charset automatically when saving files in repositories without .editorconfig files. commit 4e65a21fae2c1a9a72c11dbcb73ecec42bf18af9 Author: 10sr <8slashes+git@gmail.com> Date: Wed Jul 6 12:38:00 2016 +0900 Load only editorconfig.el when using sandbox commit 3739d7316ac29fc42e2438a7a7fe9e9fc2a3c672 Author: 10sr <8slashes+git@gmail.com> Date: Fri Jun 24 15:57:46 2016 +0900 Update README.md commit 70e85e6153f311d805337302004828e016fa93c0 Author: 10sr <8slashes+git@gmail.com> Date: Fri Jun 24 12:45:38 2016 +0900 Load editorconfig-core explicitly just becore use (#100) Fix for the case where this plugin is installed with `git clone`. Additionally, When the core library is not available, it will emit a more friendly error message like: Cannot open load file" "no such file or directory" "editorconfig-core" commit 3dd8b682435e075676a47f2476a5ecb29982e313 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jun 5 13:51:45 2016 +0900 Add editorconfig-conf-mode.el (#97) And moved some functions and definitions from editorconfig.el commit d900f27638d5d4340d38a575fc93b9e2f8455fc6 Author: 10sr <8slashes+git@gmail.com> Date: Tue May 31 17:40:13 2016 +0900 Simplify definition of string-integer-p (#96) commit 663019d341fa1ec51be73aa597f378af048bfcf5 Author: 10sr <8slashes+git@gmail.com> Date: Mon May 16 23:54:24 2016 +0900 Print line number and its content on parse error (#95) commit 692503ec109764bcd7990de59dc77c44e7fc8fd6 Author: 10sr <8slashes+git@gmail.com> Date: Thu May 12 01:24:00 2016 +0900 Add a note about deprecating marmalade repository commit 55ce0fca59669ef85743879a262bfdde7b498805 Author: 10sr <8slashes+git@gmail.com> Date: Thu May 12 01:20:50 2016 +0900 Add link to Melpa stable commit 331edef26d059515fb18df3057202be24d51c639 Author: 10sr <8slashes+git@gmail.com> Date: Wed May 11 18:13:40 2016 +0900 Remove link to Marmalade package repository Recently we do not update the package in Marmalade repository. commit 7505fb780ff08cc62f41cb420723f4646ce3fe20 Author: 10sr <8slashes+git@gmail.com> Date: Thu May 5 21:43:30 2016 +0900 Bump version to 0.7.6 commit 335e70e23df617a8a2b7fe200a3015369e4b78b4 Author: 10sr <8slashes+git@gmail.com> Date: Thu May 5 21:41:30 2016 +0900 Trivial commentary fix Two spaces are required after period in Emacs documents. commit 1c2ce46d3a924c3dd72611799d868be24c8f05d7 Author: 10sr <8slashes+git@gmail.com> Date: Mon May 2 21:42:16 2016 +0900 Add examples for core-handle members commit bf8bfe5f38d33ccfcebf7ee00eae697d90c19f0f Author: 10sr <8slashes+git@gmail.com> Date: Mon May 2 20:47:02 2016 +0900 Copy properties alists before using them commit d79b9e410aa97292255622236ed2fdcba2b79b03 Author: 10sr <8slashes+git@gmail.com> Date: Mon May 2 19:32:28 2016 +0900 Use truename for editorconfig name commit a4d73a4470b4de57deaafef9fc8988355c95f462 Author: 10sr <8slashes+git@gmail.com> Date: Fri Apr 22 15:54:40 2016 +0900 Bump version to 0.7.5 commit 19e5f16ab68499a19459c638ecc6c5ed756b7111 Author: Hong Xu Date: Thu Apr 14 22:41:08 2016 -0700 Update README: add information about customize-variable. commit 8e744e00e40b956714f22880b5a747ebb61406a7 Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 12 11:23:17 2016 +0900 Use GFM style code block commit b9c1318088e07db324fed70cd8ce6eec8ca6956a Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 12 11:19:56 2016 +0900 Update editorconfig group docstring commit 787889591816ef12bd78968ae5ce25a147bb8a0e Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 12 10:48:44 2016 +0900 Make indentation of sample codes more consistent commit eba248e638e83983992f2c02f806f8cb0454f1f1 Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 12 10:45:34 2016 +0900 Fix english commit 24b4910571c042a78c14d57ecd5b1fcb11626ddc Author: 10sr <8slashes+git@gmail.com> Date: Mon Apr 11 11:16:10 2016 +0900 Add EditorConfig group definition commit b93a7964d43cf6da0d2627c41dcf8445e6109d97 Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 5 17:54:33 2016 +0900 Add a comment for contributors commit 5687b5fc35db617704e76ed06a890b5825ccbb7a Author: 10sr <8slashes+git@gmail.com> Date: Mon Apr 11 14:42:20 2016 +0900 Update instructions about core program commit 02ab02413f0e7a91969d3742bc880745402189b5 Author: 10sr <8slashes+git@gmail.com> Date: Tue Apr 5 17:51:21 2016 +0900 Add Customize section to README commit 2afc760475be59fe1105f8824fa1fb8ebdf01fc2 Author: Hong Xu Date: Wed Apr 6 00:48:17 2016 -0700 Only set fill-column if the given integer is positive. commit 73b4b61e0bad2c7c74fb46baa040f0c677b94068 Author: Hong Xu Date: Sun Apr 3 17:41:26 2016 -0700 No need to explicitly highlight the comments via font-lock in editorconfig-conf-mode commit d9ae054ccc608289654bea018a099a1e73dace12 Author: Hong Xu Date: Sun Apr 3 17:36:43 2016 -0700 Create a syntax table for editorconfig-conf-mode. Fix #83. commit 3d6df2ae193aea34f6ddd481fc17381f235b3838 Author: 10sr <8slashes+git@gmail.com> Date: Sat Apr 2 23:56:04 2016 +0900 Derive editorconfig-conf-mode from conf-unix-mode Should fix #83 commit cdcc5826d684324701ba446c1648d475ce47d5a6 Author: 10sr <8slashes+git@gmail.com> Date: Fri Apr 1 15:38:17 2016 +0900 Add make sandbox target This commit adds a new Make target `sandbox`. Issue `make sandbox` to start new Emacs that loads *.el files in current directory and does not load the user init file. commit e68384d544c14451e12c50b4bad6933b31abde24 Author: Hong Xu Date: Thu Mar 31 22:50:17 2016 -0700 Refactor editorconfig-conf-mode commit f2629b0abb5e212a015a10af460569b1dec3de29 Author: 10sr <8slashes+git@gmail.com> Date: Wed Mar 30 17:27:15 2016 +0900 Do not check metadata of files other than editorconfig.el commit 998d0e8f766dfdf92080e3f00d78e614ea136ae7 Author: 10sr <8slashes+git@gmail.com> Date: Wed Mar 30 15:41:38 2016 +0900 Bump version to 0.7.4 Only Package-Version in editoroconfig.el will be respected so remove from other files. commit 64a2a85351db22d76f1dd510469b94cf61a5ba54 Author: 10sr <8slashes+git@gmail.com> Date: Wed Mar 30 15:40:36 2016 +0900 Fix dependencies for one multifile package commit 566ab7996e373cf7747f3856b0b4e67d8c26f17d Author: Hong Xu Date: Sat Mar 26 17:04:43 2016 -0700 Bump required editorconfi-core version Fix #80 commit 0791fced08790eceb64e5e9d3e46b444b71e0753 Author: 10sr <8slashes+git@gmail.com> Date: Sun Mar 20 01:58:51 2016 +0900 Add editorconfig-exclude-modes commit 33b0716c668685e177ffbe28efb7a95011b405b1 Author: 10sr <8slashes+git@gmail.com> Date: Fri Mar 18 12:21:40 2016 +0900 Add editorocnfig-display-current-properties A function useful for debugging. commit 50df3046e5af9c0edde66d4ba2cfe662144a538b Author: 10sr <8slashes+git@gmail.com> Date: Fri Mar 18 11:55:30 2016 +0900 Add one variable editorconfig-properties-hash commit 3480bcd04e3e941d969439ed278fbb2aa7dea8ad Author: 10sr <8slashes+git@gmail.com> Date: Thu Feb 18 01:07:31 2016 +0900 Add editorconfig-conf-mode A major-mode for editing .editorconfig file. commit 914720911131a54989d3b6403a428b397466fe01 Author: 10sr <8slashes+git@gmail.com> Date: Fri Feb 12 18:06:39 2016 +0900 Bump version to v0.7.3 commit dbc25e04c487aeb7e879f4c8a3f1950e856acd8a Author: Hong Xu Date: Sat Feb 6 21:07:06 2016 -0800 Add octave-mode and matlab-mode support Close #66 commit f34c82709e2873eefa50f0c7568772b546019197 Author: Hong Xu Date: Wed Feb 3 22:12:39 2016 -0800 Add support for scss-mode commit 37d22c075078b32f8d75c2e2f0339d7a9760eeb3 Author: 10sr <8slashes+git@gmail.com> Date: Wed Jan 27 15:35:49 2016 +0900 Bump version to 0.7.2 commit f907c968c8835a980fbf0896b8e7ca81aca40d65 Author: 10sr <8slashes+git@gmail.com> Date: Wed Jan 27 15:30:28 2016 +0900 Already 2016 :) Happy new year! commit 953f4f0ab77bac932eba074cd1aab70059f3a4a1 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 24 21:51:53 2016 +0900 Bump version: 0.7.1 commit d150069fc617a3daad2d698436e51786151c78dd Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 24 18:40:36 2016 +0900 Catch error thrown from get-properties-function and display it This commit also fixes `display-warning' usage. commit 6fbb3fe14ada3e9dbf84bf29f9223a2857e55c03 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 24 17:41:25 2016 +0900 Throw error when editorconfig executable was not found commit a7ea6807e5aa2e1bae5bf482adcdfd8f9a46425a Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 24 16:29:32 2016 +0900 Add ess-mode indentation support commit 5b9a1a38d2b0c45bdd69e6d64cd4273eec95bdd9 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 24 00:23:34 2016 +0900 Add ps-mode indentation support commit 9e1b9009578934c0ec1c7721ccb0c234c93aa634 Author: 10sr <8slashes+git@gmail.com> Date: Sat Jan 23 19:23:14 2016 +0900 Add tcl-mode indentation support commit 13956895101c2935dd00aff53e10e067db1272ad Author: 10sr <8slashes+git@gmail.com> Date: Fri Jan 22 14:47:51 2016 +0900 editorocnfig-core: Throw error when parsing .editorconfig failed commit 58b060cf3413b713015b62aec847fb66402b497a Author: 10sr <8slashes+git@gmail.com> Date: Thu Jan 21 20:08:31 2016 +0900 Remove find-file-hook commit 563bebc5663b12589c713fc55080cce3fbbcd164 Author: 10sr <8slashes+git@gmail.com> Date: Thu Jan 21 02:10:27 2016 +0900 I forgot to update editorconfig-core-version const commit 466a0e4a720410d2bf13ebacecfd3ef53f8e6041 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 17 14:40:03 2016 +0900 Bump version: 0.7.0 commit adb9ba4a9d7559342934216bc1565e1ddbb4b1a7 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 17 02:49:13 2016 +0900 Update README for charset support commit d40661e532673d110dce79f40f2c3fcb9ac765a6 Author: 10sr <8slashes+git@gmail.com> Date: Sun Jan 17 02:48:36 2016 +0900 Support charset property commit ae2544b55e9c26d5479bfe16886f09a79aaa08b6 Author: 10sr <8slashes+git@gmail.com> Date: Fri Jan 15 01:38:19 2016 +0900 Bump version: 0.6.2 Also use stable version in Package-Requires: there should be no problem with this. commit fe9ed9b4cbfda2548c3fc3ca0db6e678a83f9ec7 Author: 10sr <8slashes+git@gmail.com> Date: Mon Jan 11 23:15:18 2016 +0900 Fix names of ert test cases commit cd91a226fb792b6b3cbf3aaa05951cdd1ffa091c Author: 10sr <8slashes+git@gmail.com> Date: Mon Jan 11 23:14:45 2016 +0900 Check package metadata using ert framework commit 12f18b061a562d2fabea0b4cba1b2726db7a721e Author: 10sr <8slashes+git@gmail.com> Date: Mon Jan 11 22:34:52 2016 +0900 Use dedicated functions to manipulate hook commit ae1254a7aa76f160578446dc5ead478200735b5d Author: 10sr <8slashes+git@gmail.com> Date: Thu Jan 7 19:14:51 2016 +0900 Use hook type for custom-hooks defcustom commit 58f106454036e2248cec7d4dc4ca53c8fddb71ee Author: 10sr <8slashes+git@gmail.com> Date: Sun Dec 27 22:35:38 2015 +0900 Add MELPA badges commit 9c65aa401996dd87fe054a1079885651529bd70f Author: 10sr <8slashes+git@gmail.com> Date: Thu Dec 17 19:31:43 2015 +0900 Use `require` instead of `load` in usage example commit 48f77abd9040f2eb563efd6185b366cacd8b99de Author: 10sr <8slashes+git@gmail.com> Date: Wed Dec 9 01:35:23 2015 +0900 Bump version: 0.6.1 This release is only for melpa stable and has no change since 0.6 commit ef465f0c5d0cdabbe8ae859d2cbfed018498cc94 Author: 10sr <8slashes+git@gmail.com> Date: Sat Dec 5 02:42:25 2015 +0900 Add document about running tests commit 2c3488e82410130bf811291ee07c9e208228a7a8 Author: 10sr <8slashes+git@gmail.com> Date: Sat Dec 5 01:52:40 2015 +0900 Make `editorconfig-apply' an interactive command commit d94e1f29f333bc8e70fda372a0ca906d54eed365 Author: 10sr <8slashes+git@gmail.com> Date: Fri Dec 4 01:30:24 2015 +0900 Fix some warnings reported by flycheck Mainly docstring fix commit df4dea58f13173bd1f8a2cf59b897e9429add23b Author: 10sr <8slashes+git@gmail.com> Date: Fri Dec 4 16:08:10 2015 +0900 Fix editorconfig-core commentary text commit 2f297a27107c068b802fc92dbe166d4a8fae9e44 Author: 10sr <8slashes+git@gmail.com> Date: Thu Dec 3 02:12:59 2015 +0900 Add license header to executable commit 98a42ef7e85c2af1fa84be91ccfb677449ffe9ec Author: 10sr <8slashes+git@gmail.com> Date: Tue Dec 1 02:05:08 2015 +0900 Prepare v0.6 commit 320bfe2fa53175b8854cb81d5b008a4592fe475e Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 29 00:18:38 2015 +0900 Fix all indentation according to editorconfig commit 220f04ad82d8adae6562c036d42d61eb1a01d50f Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 29 01:18:33 2015 +0900 Update README for core elisp commit 8beaa3e2fc3a3676c5a22b219e6faf80c0a23489 Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 29 00:32:53 2015 +0900 Use core in elisp as a fallback editorconfig-core-get-properties-hash will be called when editorconfig executable is not found. commit 8555cc5e7181da63c93ab41c1fadc9c8d3ae2224 Author: 10sr <8slashes+git@gmail.com> Date: Sat Nov 28 23:55:19 2015 +0900 Update Makefile to run all tests including core commit e3fe4530edab8b748415f25df5f173b82dc503f5 Author: 10sr <8slashes+git@gmail.com> Date: Sat Nov 28 23:30:57 2015 +0900 Add editorconfig-core el files commit 0b236465262048ff9143af337013becf324a3188 Author: 10sr <8slashes+git@gmail.com> Date: Wed Nov 25 12:08:39 2015 +0900 Add files used to test core functions commit cc948068c916e854561933a5857a5fbb55aeaa26 Author: 10sr <8slashes+git@gmail.com> Date: Sat Nov 28 23:35:37 2015 +0900 Update .editorconfig for Makefile and .gitmodules commit 12f49e98fa559b3055be17ab71f4092f1f078386 Author: 10sr <8slashes+git@gmail.com> Date: Tue Nov 17 16:36:15 2015 +0900 Do nothing when current buffer does not visit any file commit 1c7857782098192e8aba314bd7925814e3b4fddb Author: Hong Xu Date: Thu Nov 5 12:43:57 2015 -0800 Add 10sr to the contributor list commit d076a16e81db4697be0d8744468906ab110f8b7e Author: Hong Xu Date: Thu Nov 5 00:57:40 2015 -0800 Apply settings on major mode change commit e9da0d685d9d7367bce9dc3c572234b23293f0c3 Author: Hong Xu Date: Thu Nov 5 00:54:45 2015 -0800 Rename editorconfig-find-file-hook to editorconfig-apply commit f61c0e31151381d7dd6efc22afcbb9db20c6cf00 Author: 10sr <8slashes+git@gmail.com> Date: Mon Nov 2 01:40:55 2015 +0900 Add aliases for obsolete variables and bump version commit cfb329dabf54c1c99da3352481d7d819be9f90d7 Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 1 20:10:51 2015 +0900 Update README commit 241554e8881cdc42e8524c16a4c0a39838c2c337 Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 1 18:14:39 2015 +0900 Change symbol prefix: edconf -> editorconfig commit 0a319fab7845153a91fbd12ff1174f2808e2ed2c Author: 10sr <8slashes+git@gmail.com> Date: Sun Nov 1 18:11:03 2015 +0900 Add global minor mode commit a4b8e55bf4dea4567f165ad5f71694f659610b3d Author: 10sr <8slashes+git@gmail.com> Date: Tue Oct 27 22:15:00 2015 -0700 Make EditorConfig core function pluggable Close #41 Squashed commit of the following: commit e91aca6f38d9c42be19cc49aafc75ac086907b00 Author: 10sr <8slashes+git@gmail.com> Date: Sun Oct 25 03:19:26 2015 +0900 Fix typo in docstring commit 76ce139cd0a0ff6bc250615ca7bb94868c85c41d Author: 10sr <8slashes+git@gmail.com> Date: Tue Oct 13 13:51:13 2015 +0900 Implement edconf-get-properties-from-exec commit 23baf520c83a7cb68634cd173ce28f9a6842f593 Author: 10sr <8slashes+git@gmail.com> Date: Mon Oct 12 03:18:54 2015 +0900 Add variable edconf-get-properties-function commit 46eb2863daa2f391bda9b9f8b0db0db210922b32 Author: USAMI Kenta Date: Fri Oct 23 01:51:34 2015 +0900 Add autoload cookie commit d068ec0546938a0d02b05ac5a75c370962205ed2 Author: USAMI Kenta Date: Fri Oct 23 01:41:55 2015 +0900 Use \' instead of $ commit b45ec732a2b59f8b3404ae40a52de0f08471bcb6 Author: Hong Xu Date: Mon Mar 16 15:02:01 2015 -0700 Relicense to GPLv3+ commit 871a69ab908cb00e69fa5be0f7e4deaabcbe8b5d Author: Hong Xu Date: Mon Mar 16 14:39:06 2015 -0700 Add Hong Xu to contributor list. commit 7a7e1544c961ee4659af40e6f59c2777d12ea297 Author: Hong Xu Date: Mon Mar 16 14:38:42 2015 -0700 Update a few links in the README commit e7a0874591b23885e10dc322211ff9f77b944dae Author: Hong Xu Date: Fri Dec 19 00:33:17 2014 -0800 Add hook mechanism. commit c36ed4aeb7096abbe455fd91fd4708a413f0c16f Author: Hong Xu Date: Sat Dec 20 18:04:39 2014 -0800 Version 0.4 commit 6c18a40b51e459b44af380aa42e111870ab9334f Author: Hong Xu Date: Thu Dec 18 23:17:28 2014 -0800 Make edconf-exec-path a customizable variable. commit 480a6bba4761fe1074bd70b4dc9cb461e50fa3b4 Author: Hong Xu Date: Thu Dec 18 22:13:17 2014 -0800 Fix some issues caused by the previous commit. commit 92519a8c255cfd7d2b730842c7cb00304f992735 Author: Hong Xu Date: Thu Dec 18 21:58:11 2014 -0800 Don't set indent size if the given value makes no sense. commit 9d1d2364313086590d0e578aab5dbaabeaf03ec9 Author: Hong Xu Date: Thu Dec 18 21:11:19 2014 -0800 Don't set max_line_length if not specified. commit d776cdc5eeedcac6a58fa50ea685275d6fec40e6 Author: Hong Xu Date: Thu Dec 18 21:02:28 2014 -0800 Support max_line_length. commit 56722d34df673387597dd68e3dd2c179fb0fcb96 Author: Hong Xu Date: Mon Aug 11 09:32:49 2014 -0700 Add sh-indentation to the list of indent variable. commit 6bdcaf89dff0ec33ccb82cd8c82658ae8a66c4e0 Author: Hong Xu Date: Tue Jul 8 14:38:52 2014 -0700 Add cmake-mode support. commit 5bc887b015d0c192133109448debcb1cd0a7b575 Author: Hong Xu Date: Wed Oct 16 18:10:24 2013 -0700 Support web-mode. Fix editorconfig/editorconfig#124 commit 4e2bf3ddd61a87ac30bdfea04d222b8643ffd337 Author: Hong Xu Date: Thu Jun 6 17:50:32 2013 -0700 Add the package manager installation way to README commit ac28a9fd1d5b4bd0130fe78d3428cc1e93bbff7a Author: Hong Xu Date: Thu Jun 6 17:41:45 2013 -0700 Bump version number commit fbe97a082421acf8ea41abee76f6ce223496a628 Author: Hong Xu Date: Wed Jun 5 01:06:46 2013 -0700 Wrong way to indent html. Fixes it. commit d7a7b6af8e7af9982543df76739be3f50e2bfee9 Author: Hong Xu Date: Wed Jun 5 01:02:45 2013 -0700 Add JS and HTML indent settings. commit 5dfbeb541ec9aa652e5728e7108cedb7c12a0a9b Author: Hong Xu Date: Sun Jun 2 11:58:46 2013 -0700 Fix indentation problem in the source file. commit 9fdbf9ffddc1758019158328eadf293f6ecb7435 Author: Hong Xu Date: Sun Jun 2 11:53:48 2013 -0700 Set indent value for AucTeX commit e69ebeeaa1dd8e4769d5a40e25323db8d8672e59 Author: Hong Xu Date: Wed May 29 22:30:39 2013 -0700 Reset the indentation rule. commit ef90cfda833faeeb8b92cd528bf9523762efa94e Author: Hong Xu Date: Sun May 26 10:32:29 2013 -0700 Update package information. commit 8ee7d0b5334da68b9147c28465529b07c5010363 Author: Hong Xu Date: Sun May 26 00:56:26 2013 -0700 Set indent_size for lisp mode and ruby mode. commit 45afbe1bc96afb423d42a2f547804f0e11f89f3f Author: Hong Xu Date: Mon Mar 18 10:18:52 2013 -0700 Add a link to `editorconfig.el` in README commit 10be4fd165d39baa4394e26256f696a39ab01de3 Author: Jonas Bernoulli Date: Mon Mar 18 05:06:03 2013 +0100 provide feature, use symbol prefix, add commentary, remove url from summary commit a8ca8c46f75e76565d773c44cc9f36169beaa24c Author: Hong Xu Date: Sun Mar 4 12:37:02 2012 +0800 Update EditorConfig Core URL. commit c45e871a5d1394e6755fd2202d83cb53ad1b1e04 Author: Hong Xu Date: Wed Jan 25 10:57:55 2012 +0800 Add properties link. commit d744546fc6864c0a2a4b524804982656988526b9 Author: Hong Xu Date: Tue Jan 10 09:41:41 2012 +0800 Add root=true to the top .editorconfig. commit 68ad326706a14a707395501aeb03b579aef83777 Author: Hong Xu Date: Sat Nov 26 11:05:37 2011 +0800 Update EditorConfig url. commit 38ac90325669f2643c3205715d4b76aa3e1891ca Author: Stefan Monnier Date: Thu Jun 13 14:28:14 2024 -0400 Erase initial commit content commit 6360e7b904fcadb30678bf7fa740c998976eec75 Author: Trey Hunner Date: Fri Nov 4 21:12:11 2011 -0700 Add initial plugin diff --git a/doc/man/editorconfig.texi b/doc/man/editorconfig.texi new file mode 100644 index 00000000000..5e7d3b85552 --- /dev/null +++ b/doc/man/editorconfig.texi @@ -0,0 +1,297 @@ +@dircategory Emacs +@direntry +* EditorConfig: (editorconfig). EditorConfig Emacs Plugin. +@end direntry + +@node Top +@chapter EditorConfig Emacs Plugin +@anchor{#editorconfig-emacs-plugin} +This is an @uref{https://editorconfig.org,EditorConfig} plugin for +@uref{https://www.gnu.org/software/emacs/,Emacs}. + +@menu +* Getting Started:: +* Supported properties:: +* Customize:: +* Troubleshooting:: +* Submitting Bugs and Feature Requests:: +* License:: +@end menu + +@node Getting Started +@section Getting Started +@anchor{#getting-started} + +@menu +* packageel:: +* use-package:: +* Manual installation:: +@end menu + +@node packageel +@subsection package.el +@anchor{#package.el} +This package is available from +@uref{https://melpa.org/#/editorconfig,MELPA}, +@uref{https://stable.melpa.org/#/editorconfig,MELPA Stable} and +@uref{http://elpa.nongnu.org/nongnu/editorconfig.html,NonGNU ELPA}. +Install from these repositories and enable global minor-mode +@code{editorconfig-mode}: + +@verbatim +(editorconfig-mode 1) +@end verbatim + +Normally, enabling @code{editorconfig-mode} should be enough for this +plugin to work: all other configurations are optional. This mode sets up +hooks so that EditorConfig properties will be loaded and applied to the +new buffers automatically when visiting files. + +@node use-package +@subsection use-package +@anchor{#use-package} +If you use +@uref{https://www.emacswiki.org/emacs/UsePackage,@strong{use-package}}, +add the following to your @code{init.el} file: + +@verbatim +(use-package editorconfig + :ensure t + :config + (editorconfig-mode 1)) +@end verbatim + +@node Manual installation +@subsection Manual installation +@anchor{#manual-installation} +Copy all @code{.el} files in this repository to @code{~/.emacs.d/lisp} +and add the following: + +@verbatim +(add-to-list 'load-path "~/.emacs.d/lisp") +(require 'editorconfig) +(editorconfig-mode 1) +@end verbatim + +@node Supported properties +@section Supported properties +@anchor{#supported-properties} +Current Emacs plugin coverage for EditorConfig's +@uref{https://editorconfig.org/#supported-properties,properties}: + +@itemize +@item +@code{indent_style} +@item +@code{indent_size} +@item +@code{tab_width} +@item +@code{end_of_line} +@item +@code{charset} +@item +@code{trim_trailing_whitespace} +@item +@code{insert_final_newline = true} is supported +@item +@code{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 @code{.editorconfig} marks as +trailing-newline-free +@item +@code{max_line_length} +@item +@code{file_type_ext} (Experimental) +(See below) +@item +@code{file_type_emacs} (Experimental) +(See below) +@item +@code{root} (only used by EditorConfig core) +@end itemize + +Not yet covered properties marked with over-strike -- pull requests +implementing missing features warmly welcomed! Typically, you will want +to tie these to native functionality, or the configuration of existing +packages handling the feature. + +As several packages have their own handling of, say, indentation, we +might not yet cover some mode you use, but we try to add the ones that +show up on our radar. + +@menu +* File Type file_type_ext file_type_emacs:: +@end menu + +@node File Type file_type_ext file_type_emacs +@subsection File Type (file_type_ext, file_type_emacs) +@anchor{#file-type-file_type_ext-file_type_emacs} +File-type feature is currently disabled, because this package is now +undergoing big internal refactoring. For those who want this +functionality, please consider using +@uref{https://github.com/10sr/editorconfig-custom-majormode-el,editorconfig-custom-majormode}. + +@node Customize +@section Customize +@anchor{#customize} +@code{editorconfig-emacs} provides some customize variables. + +Here are some of these variables: for the full list of available +variables, type M-x customize-group [RET] editorconfig [RET]. + +@menu +* editorconfig-trim-whitespaces-mode:: +* editorconfig-after-apply-functions:: +* editorconfig-hack-properties-functions:: +@end menu + +@node editorconfig-trim-whitespaces-mode +@subsection @code{editorconfig-trim-whitespaces-mode} +@anchor{#editorconfig-trim-whitespaces-mode} +Buffer local minor-mode to use to trim trailing whitespaces. + +If set, editorconfig will enable/disable this mode in accord with +@code{trim_trailing_whitespace} property in @code{.editorconfig}. +Otherwise, use Emacs built-in @code{delete-trailing-whitespace} +function. + +One possible value is +@uref{https://github.com/lewang/ws-butler,@code{ws-butler-mode}}, with +which only lines touched get trimmed. To use it, add following to your +init.el: + +@verbatim +(setq editorconfig-trim-whitespaces-mode + 'ws-butler-mode) +@end verbatim + +@node editorconfig-after-apply-functions +@subsection @code{editorconfig-after-apply-functions} +@anchor{#editorconfig-after-apply-functions} +(Formerly @code{editorconfig-custom-hooks}) + +A list of functions which will be called after loading common +EditorConfig settings, when you can set some custom variables. + +For example, @code{web-mode} has several variables for indentation +offset size and EditorConfig sets them at once by @code{indent_size}. +You can stop indenting only blocks of @code{web-mode} by adding +following to your init.el: + +@verbatim +(add-hook 'editorconfig-after-apply-functions + (lambda (props) (setq web-mode-block-padding 0))) +@end verbatim + +@node editorconfig-hack-properties-functions +@subsection @code{editorconfig-hack-properties-functions} +@anchor{#editorconfig-hack-properties-functions} +A list of functions 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, Makefile files always use tab characters for indentation: +you can overwrite "indent_style" property when current @code{major-mode} +is @code{makefile-mode}: + +@verbatim +(add-hook 'editorconfig-hack-properties-functions + '(lambda (props) + (when (derived-mode-p 'makefile-mode) + (puthash 'indent_style "tab" props)))) +@end verbatim + +@node Troubleshooting +@section Troubleshooting +@anchor{#troubleshooting} +Enabling @code{editorconfig-mode} should be enough for normal cases. + +When EditorConfig properties are not effective for unknown reason, we +recommend first trying +@code{M-x editorconfig-display-current-properties}. + +This command will open a new buffer and display the EditorConfig +properties loaded for current buffer. You can check if EditorConfig +properties were not read for buffers at all, or they were loaded but did +not take effect for some other reasons. + +@menu +* Indentation for new major-modes:: +* Not work at all for FOO-mode!:: +@end menu + +@node Indentation for new major-modes +@subsection Indentation for new major-modes +@anchor{#indentation-for-new-major-modes} +Because most Emacs major-modes have their own indentation settings, this +plugin requires explicit support for each major-mode for +@code{indent_size} property. + +By default this plugin ships with settings for many major-modes, but, +sorry to say, it cannot be perfect. Especially it is difficult to +support brand-new major-modes. Please feel free to submit issue or +pull-request for such major-mode! + +Supported major-modes and their indentation configs are defined in the +variable @code{editorconfig-indentation-alist}. + +@node Not work at all for FOO-mode! +@subsection Not work at all for FOO-mode! +@anchor{#not-work-at-all-for-foo-mode} +Most cases properties are loaded just after visiting files when +@code{editorconfig-mode} is enabled. But it is known that there are +major-modes that this mechanism does not work for and require explicit +call of @code{editorconfig-apply}. + +Typically it will occur when the major-mode is not defined using +@code{define-derived-mode} (@code{rpm-spec-mode} is an example for +this). Please feel free to submit issues if you find such modes! + +@node Submitting Bugs and Feature Requests +@section Submitting Bugs and Feature Requests +@anchor{#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 + +@menu +* Development:: +@end menu + +@node Development +@subsection Development +@anchor{#development} +Make and @uref{https://cmake.org,CMake} must be installed to run the +tests locally: + +@verbatim +$ make check +@end verbatim + +To start a new Emacs process with current @code{*.el} and without +loading user init file, run: + +@verbatim +$ make sandbox +@end verbatim + +@node License +@section License +@anchor{#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 @url{https://www.gnu.org/licenses/}. + +@bye diff --git a/lisp/editorconfig-conf-mode.el b/lisp/editorconfig-conf-mode.el new file mode 100644 index 00000000000..2b4ddd4410f --- /dev/null +++ b/lisp/editorconfig-conf-mode.el @@ -0,0 +1,95 @@ +;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- 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: + +;; Major mode for editing .editorconfig files. + +;;; Code: + +(require 'conf-mode) + +(defvar editorconfig-conf-mode-syntax-table + (let ((table (make-syntax-table conf-unix-mode-syntax-table))) + (modify-syntax-entry ?\; "<" table) + table) + "Syntax table in use in `editorconfig-conf-mode' buffers.") + +(defvar editorconfig-conf-mode-abbrev-table nil + "Abbrev table in use in `editorconfig-conf-mode' buffers.") +(define-abbrev-table 'editorconfig-conf-mode-abbrev-table ()) + +;;;###autoload +(define-derived-mode editorconfig-conf-mode conf-unix-mode "Conf[EditorConfig]" + "Major mode for editing .editorconfig files." + (set-variable 'indent-line-function 'indent-relative) + (let ((key-property-list + '("charset" + "end_of_line" + "file_type_emacs" + "file_type_ext" + "indent_size" + "indent_style" + "insert_final_newline" + "max_line_length" + "root" + "tab_width" + "trim_trailing_whitespace")) + (key-value-list + '("unset" + "true" + "false" + "lf" + "cr" + "crlf" + "space" + "tab" + "latin1" + "utf-8" + "utf-8-bom" + "utf-16be" + "utf-16le")) + (font-lock-value + '(("^[ \t]*\\[\\(.+?\\)\\]" 1 font-lock-type-face) + ("^[ \t]*\\(.+?\\)[ \t]*[=:]" 1 font-lock-variable-name-face)))) + + ;; Highlight all key values + (dolist (key-value key-value-list) + (push `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value) + 1 font-lock-constant-face) + font-lock-value)) + ;; Highlight all key properties + (dolist (key-property key-property-list) + (push `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property) + 1 font-lock-builtin-face) + font-lock-value)) + + (conf-mode-initialize "#" font-lock-value))) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode)) + +(provide 'editorconfig-conf-mode) +;;; editorconfig-conf-mode.el ends here diff --git a/lisp/editorconfig-core-handle.el b/lisp/editorconfig-core-handle.el new file mode 100644 index 00000000000..d225e1456ba --- /dev/null +++ b/lisp/editorconfig-core-handle.el @@ -0,0 +1,243 @@ +;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- 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: + +;; Handle structures for EditorConfig config file. This library is used +;; internally from editorconfig-core.el . + +;;; Code: + +(require 'cl-lib) + +(require 'editorconfig-fnmatch) + +(defvar editorconfig-core-handle--cache-hash + (make-hash-table :test 'equal) + "Hash of EditorConfig filename and its `editorconfig-core-handle' instance.") + +(cl-defstruct editorconfig-core-handle-section + "Structure representing one section in a .editorconfig file. + +Slots: + +`name' + String of section name (glob string). + +`props' + Alist of properties: (KEY . VALUE)." + (name nil) + (props nil)) + +(defun editorconfig-core-handle-section-get-properties (section file dir) + "Return properties alist when SECTION name match FILE. + +DIR should be the directory where .editorconfig file which has SECTION lives. +IF not match, return nil." + (when (editorconfig-core-handle--fnmatch-p + file (editorconfig-core-handle-section-name section) dir) + (editorconfig-core-handle-section-props section))) + +(cl-defstruct editorconfig-core-handle + "Structure representing an .editorconfig file. + +Slots: +`top-props' + Alist of top properties like ((\"root\" . \"true\")) + +`sections' + List of `editorconfig-core-handle-section' structure objects. + +`mtime' + Last modified time of .editorconfig file. + +`path' + Absolute path to .editorconfig file.' +" + (top-props nil) + (sections nil) + (mtime nil) + (path nil)) + + +(defun editorconfig-core-handle (conf) + "Return EditorConfig handle for CONF, which should be a file path. + +If CONF does not exist return nil." + (when (file-readable-p conf) + (let ((cached (gethash conf editorconfig-core-handle--cache-hash)) + (mtime (nth 5 (file-attributes conf)))) + (if (and cached + (equal (editorconfig-core-handle-mtime cached) mtime)) + cached + (let ((parsed (editorconfig-core-handle--parse-file conf))) + (puthash conf + (make-editorconfig-core-handle :top-props (plist-get parsed :top-props) + :sections (plist-get parsed :sections) + :mtime mtime + :path conf) + editorconfig-core-handle--cache-hash)))))) + +(defun editorconfig-core-handle-root-p (handle) + "Return non-nil if HANDLE represent root EditorConfig file. + +If HANDLE is nil return nil." + (when handle + (string-equal "true" + (downcase (or (cdr (assoc "root" + (editorconfig-core-handle-top-props handle))) + ""))))) + +(defun editorconfig-core-handle-get-properties (handle file) + "Return list of alist of properties from HANDLE for FILE. +The list returned will be ordered by the lines they appear. + +If HANDLE is nil return nil." + (when handle + (let ((dir (file-name-directory (editorconfig-core-handle-path handle)))) + (cl-loop for section in (editorconfig-core-handle-sections handle) + for props = (editorconfig-core-handle-section-get-properties section + file + dir) + when props collect (copy-alist props))))) +(make-obsolete 'editorconfig-core-handle-get-properties + 'editorconfig-core-handle-get-properties-hash + "0.8.0") + + +(defun editorconfig-core-handle-get-properties-hash (handle file) + "Return hash of properties from HANDLE for FILE. + +If HANDLE is nil return nil." + (when handle + (let ((hash (make-hash-table)) + (dir (file-name-directory (editorconfig-core-handle-path + handle)))) + (dolist (section (editorconfig-core-handle-sections handle)) + (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir) + do (puthash (intern key) value hash))) + hash))) + +(defun editorconfig-core-handle--fnmatch-p (name pattern dir) + "Return non-nil if NAME match PATTERN. +If pattern has slash, pattern should be relative to DIR. + +This function is a fnmatch with a few modification for EditorConfig usage." + (if (string-match-p "/" pattern) + (let ((pattern (replace-regexp-in-string "^/" "" pattern)) + (dir (file-name-as-directory dir))) + (editorconfig-fnmatch-p name (concat dir pattern))) + (editorconfig-fnmatch-p name (concat "**/" pattern)))) + +(defsubst editorconfig-core-handle--string-trim (str) + "Remove leading and trailing whitespaces from STR." + (replace-regexp-in-string "[[:space:]]+\\'" + "" + (replace-regexp-in-string "\\`[[:space:]]+" + "" + str))) + +(defun editorconfig-core-handle--parse-file (conf) + "Parse EditorConfig file CONF. + +This function returns cons of its top properties alist and +alist of patterns and its properties alist. +The list returned will be ordered by the lines they appear. + +If CONF is not found return nil." + (when (file-readable-p conf) + (with-temp-buffer + ;; NOTE: Use this instead of insert-file-contents-literally to enable + ;; code conversion + (insert-file-contents conf) + (goto-char (point-min)) + (let ((point-max (point-max)) + (sections ()) + (top-props nil) + + ;; String of current line + (line "") + ;; nil when pattern not appeared yet, "" when pattern is empty ("[]") + (pattern nil) + ;; Alist of properties for current PATTERN + (props ()) + + ;; Current line num + (current-line-number 1)) + (while (not (eq (point) point-max)) + (setq line + (buffer-substring-no-properties (line-beginning-position) + (line-end-position))) + (setq line + (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$" + "" + (editorconfig-core-handle--string-trim line))) + + (cond + ((string-equal "" line) + nil) + + ;; Start of section + ((string-match "^\\[\\(.*\\)\\]$" + line) + (when pattern + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props))) + (setq pattern nil) + (setq props nil)) + (setq pattern (match-string 1 line))) + + (t + (let ((idx (string-match "=\\|:" line))) + (unless idx + (error "Error while reading config file: %s:%d:\n %s\n" + conf current-line-number line)) + (let ((key (downcase (editorconfig-core-handle--string-trim + (substring line 0 idx)))) + (value (editorconfig-core-handle--string-trim + (substring line (1+ idx))))) + (when (and (< (length key) 51) + (< (length value) 256)) + (if pattern + (when (< (length pattern) 4097) + (setq props + `(,@props (,key . ,value)))) + (setq top-props + `(,@top-props (,key . ,value))))))))) + (setq current-line-number (1+ current-line-number)) + (goto-char (point-min)) + (forward-line (1- current-line-number))) + (when pattern + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props)))) + (list :top-props top-props + :sections sections))))) + +(provide 'editorconfig-core-handle) +;;; editorconfig-core-handle.el ends here diff --git a/lisp/editorconfig-core.el b/lisp/editorconfig-core.el new file mode 100644 index 00000000000..c7b52deaafd --- /dev/null +++ b/lisp/editorconfig-core.el @@ -0,0 +1,182 @@ +;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- 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: + +;; This library is one implementation of EditorConfig Core, which parses +;; .editorconfig files and returns properties for given files. +;; This can be used in place of, for example, editorconfig-core-c. + + +;; Use from EditorConfig Emacs Plugin + +;; Emacs plugin (v0.5 or later) can utilize this implementation. +;; By default, the plugin first search for any EditorConfig executable, +;; and fallback to this library if not found. +;; If you always want to use this library, add following lines to your init.el: + +;; (setq editorconfig-get-properties-function +;; 'editorconfig-core-get-properties-hash) + + +;; Functions + +;; editorconfig-core-get-properties (&optional file confname confversion) + +;; Get EditorConfig properties for FILE. + +;; If FILE is not given, use currently visiting file. +;; Give CONFNAME for basename of config file other than .editorconfig. +;; If need to specify config format version, give CONFVERSION. + +;; This functions returns alist of properties. Each element will look like +;; (KEY . VALUE) . + + +;; editorconfig-core-get-properties-hash (&optional file confname confversion) + +;; Get EditorConfig properties for FILE. + +;; This function is almost same as `editorconfig-core-get-properties', but +;; returns hash object instead. + +;;; Code: + +(require 'cl-lib) + +(require 'editorconfig-core-handle) + +(eval-when-compile + (require 'subr-x)) + + +(defun editorconfig-core--get-handles (dir confname &optional result) + "Get list of EditorConfig handlers for DIR from CONFNAME. + +In the resulting list, the handle for root config file comes first, and the +nearest comes last. +The list may contains nil when no file was found for directories. +RESULT is used internally and normally should not be used." + (setq dir (expand-file-name dir)) + (let ((handle (editorconfig-core-handle (concat (file-name-as-directory dir) + confname))) + (parent (file-name-directory (directory-file-name dir)))) + (if (or (string= parent dir) + (and handle (editorconfig-core-handle-root-p handle))) + (cl-remove-if-not 'identity (cons handle result)) + (editorconfig-core--get-handles parent + confname + (cons handle result))))) + +;;;###autoload +(defun editorconfig-core-get-nearest-editorconfig (directory) + "Return path to .editorconfig file that is closest to DIRECTORY." + (when-let* ((handle (car (last + (editorconfig-core--get-handles directory + ".editorconfig"))))) + (editorconfig-core-handle-path handle))) + +;;;###autoload +(defun editorconfig-core-get-properties (&optional file confname confversion) + "Get EditorConfig properties for FILE. +If FILE is not given, use currently visiting file. +Give CONFNAME for basename of config file other than .editorconfig. +If need to specify config format version, give CONFVERSION. + +This function returns an alist of properties. Each element will +look like (KEY . VALUE)." + (let ((hash (editorconfig-core-get-properties-hash file confname confversion)) + (result nil)) + (maphash (lambda (key value) + (add-to-list 'result (cons (symbol-name key) value))) + hash) + result)) + +(defun editorconfig-core--hash-merge (into update) + "Merge two hashes INTO and UPDATE. + +This is a destructive function, hash INTO will be modified. +When the same key exists in both two hashes, values of UPDATE takes precedence." + (maphash (lambda (key value) (puthash key value into)) update) + into) + +;;;###autoload +(defun editorconfig-core-get-properties-hash (&optional file confname confversion) + "Get EditorConfig properties for FILE. +If FILE is not given, use currently visiting file. +Give CONFNAME for basename of config file other than .editorconfig. +If need to specify config format version, give CONFVERSION. + +This function is almost same as `editorconfig-core-get-properties', but returns +hash object instead." + (setq file + (expand-file-name (or file + buffer-file-name + (error "FILE is not given and `buffer-file-name' is nil")))) + (setq confname (or confname ".editorconfig")) + (setq confversion (or confversion "0.12.0")) + (let ((result (make-hash-table))) + (dolist (handle (editorconfig-core--get-handles (file-name-directory file) + confname)) + (editorconfig-core--hash-merge result + (editorconfig-core-handle-get-properties-hash handle + file))) + + ;; Downcase known boolean values + (dolist (key '( end_of_line indent_style indent_size insert_final_newline + trim_trailing_whitespace charset)) + (when-let* ((val (gethash key result))) + (puthash key (downcase val) result))) + + ;; Add indent_size property + (let ((v-indent-size (gethash 'indent_size result)) + (v-indent-style (gethash 'indent_style result))) + (when (and (not v-indent-size) + (string= v-indent-style "tab") + ;; If VERSION < 0.9.0, indent_size should have no default value + (version<= "0.9.0" + confversion)) + (puthash 'indent_size + "tab" + result))) + ;; Add tab_width property + (let ((v-indent-size (gethash 'indent_size result)) + (v-tab-width (gethash 'tab_width result))) + (when (and v-indent-size + (not v-tab-width) + (not (string= v-indent-size "tab"))) + (puthash 'tab_width v-indent-size result))) + ;; Update indent-size property + (let ((v-indent-size (gethash 'indent_size result)) + (v-tab-width (gethash 'tab_width result))) + (when (and v-indent-size + v-tab-width + (string= v-indent-size "tab")) + (puthash 'indent_size v-tab-width result))) + + result)) + +(provide 'editorconfig-core) +;;; editorconfig-core.el ends here diff --git a/lisp/editorconfig-fnmatch.el b/lisp/editorconfig-fnmatch.el new file mode 100644 index 00000000000..25a344dc2ef --- /dev/null +++ b/lisp/editorconfig-fnmatch.el @@ -0,0 +1,284 @@ +;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- 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: + +;; 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/lisp/editorconfig-tools.el b/lisp/editorconfig-tools.el new file mode 100644 index 00000000000..d4af1a1e5a0 --- /dev/null +++ b/lisp/editorconfig-tools.el @@ -0,0 +1,122 @@ +;;; 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))))) + +(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) + + +(provide 'editorconfig-tools) +;;; editorconfig-tools.el ends here diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el new file mode 100644 index 00000000000..5ab06344047 --- /dev/null +++ b/lisp/editorconfig.el @@ -0,0 +1,747 @@ +;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2024 EditorConfig Team + +;; Author: EditorConfig Team +;; Version: 0.11.0 +;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Package-Requires: ((emacs "26.1") (nadvice "0.3")) +;; Keywords: convenience editorconfig + +;; 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 helps developers define and maintain consistent +;; coding styles between different editors and IDEs. + +;; The EditorConfig project consists of a file format for defining +;; coding styles and a collection of text editor plugins that enable +;; editors to read the file format and adhere to defined styles. +;; EditorConfig files are easily readable and they work nicely with +;; version control systems. + +;;; Code: + +(require 'cl-lib) +(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)) + +(require 'editorconfig-core) + +(defgroup editorconfig nil + "EditorConfig Emacs Plugin. + +EditorConfig helps developers define and maintain consistent +coding styles between different editors and IDEs." + :tag "EditorConfig" + :prefix "editorconfig-" + :group 'tools) + +(define-obsolete-variable-alias + 'edconf-exec-path + 'editorconfig-exec-path + "0.5") +(defcustom editorconfig-exec-path + "editorconfig" + "Path to EditorConfig executable. + +Used by `editorconfig--execute-editorconfig-exec'." + :type 'string + :group 'editorconfig) + +(define-obsolete-variable-alias + 'edconf-get-properties-function + 'editorconfig-get-properties-function + "0.5") +(defcustom editorconfig-get-properties-function + 'editorconfig-core-get-properties-hash + "A function which gets EditorConfig properties for specified file. + +This function will be called with one argument, full path of the target file, +and should return a hash object containing properties, or nil if any core +program is not available. Keys of this hash should be symbols of properties, +and values should be strings of their values. + + +For example, if you always want to use built-in core library instead +of any EditorConfig executable to get properties, add following to +your init.el: + + (set-variable \\='editorconfig-get-properties-function + #\\='editorconfig-core-get-properties-hash) + +Possible known values are: + +* `editorconfig-core-get-properties-hash' (default) + * Always use built-in Emacs-Lisp implementation to get properties +* `editorconfig-get-properties' + * 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" + :type 'function + :group 'editorconfig) + +(define-obsolete-variable-alias + 'edconf-custom-hooks + 'editorconfig-after-apply-functions + "0.5") +(define-obsolete-variable-alias + 'editorconfig-custom-hooks + 'editorconfig-after-apply-functions + "0.7.14") +(defcustom editorconfig-after-apply-functions () + "A list of functions after loading common EditorConfig settings. + +Each element in this list is a hook function. This hook function +takes one parameter, which is a property hash table. The value +of properties can be obtained through gethash function. + +The hook does not have to be coding style related; you can add +whatever functionality you want. For example, the following is +an example to add a new property emacs_linum to decide whether to +show line numbers on the left: + + (add-hook \\='editorconfig-after-apply-functions + \\='(lambda (props) + (let ((show-line-num (gethash \\='emacs_linum props))) + (cond ((equal show-line-num \"true\") (linum-mode 1)) + ((equal show-line-num \"false\") (linum-mode 0)))))) + +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) + +(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. +\(Since 2021/08/30 (v0.9.0): Buffer coding-systems are set before running +this functions, so this variable cannot be used to change coding-systems.) + +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)))) + +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) +(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: + charset values will be referenced before running this hook." + "v0.9.0") + +(define-obsolete-variable-alias + 'edconf-indentation-alist + 'editorconfig-indentation-alist + "0.5") +(defcustom editorconfig-indentation-alist + ;; For contributors: Sort modes in alphabetical order + `((apache-mode apache-indent-level) + (bash-ts-mode sh-basic-offset + sh-indentation) + (bpftrace-mode c-basic-offset) + (c++-ts-mode c-basic-offset + c-ts-mode-indent-offset) + (c-ts-mode c-basic-offset + c-ts-mode-indent-offset) + (cmake-mode cmake-tab-width) + (cmake-ts-mode cmake-tab-width + cmake-ts-mode-indent-offset) + (csharp-mode c-basic-offset) + (csharp-ts-mode c-basic-offset + csharp-ts-mode-indent-offset) + (emacs-lisp-mode lisp-indent-offset) + (ess-mode ess-indent-offset) + (feature-mode feature-indent-offset + feature-indent-level) + (gdscript-mode gdscript-indent-offset) + (go-ts-mode go-ts-mode-indent-offset) + (hcl-mode hcl-indent-level) + (html-ts-mode html-ts-mode-indent-offset) + (java-ts-mode c-basic-offset + java-ts-mode-indent-offset) + (js-mode js-indent-level) + (jsonian-mode jsonian-default-indentation) + (latex-mode . editorconfig-set-indentation-latex-mode) + (lisp-mode lisp-indent-offset) + (matlab-mode matlab-indent-level) + (octave-mode octave-block-offset) + ;; No need to change `php-mode-coding-style' value for php-mode + ;; since we run editorconfig later than it resets `c-basic-offset'. + ;; See https://github.com/editorconfig/editorconfig-emacs/issues/116 + ;; for details. + (php-mode c-basic-offset) + (php-ts-mode php-ts-mode-indent-offset) + (ps-mode ps-mode-tab) + (ruby-mode ruby-indent-level) + (rust-ts-mode rust-indent-offset + rust-ts-mode-indent-offset) + (scss-mode css-indent-offset) + (sgml-mode sgml-basic-offset) + (sh-mode sh-indentation) + (svelte-mode svelte-basic-offset) + (tcl-mode tcl-indent-level + tcl-continued-indent-level) + (toml-ts-mode toml-ts-mode-indent-offset) + (verilog-mode verilog-indent-level + verilog-indent-level-behavioral + verilog-indent-level-declaration + verilog-indent-level-module + verilog-cexp-indent + verilog-case-indent) + (web-mode (web-mode-indent-style . ,(lambda (size) 2)) + web-mode-markup-indent-offset + web-mode-css-indent-offset + web-mode-code-indent-offset) + (zig-mode zig-indent-offset) + ) + "Alist of indentation setting methods by modes." + :risky t) + +(defcustom editorconfig-exclude-modes () + "Modes in which `editorconfig-mode-apply' will not run." + :type '(repeat (symbol :tag "Major Mode")) + :group 'editorconfig) + +(defcustom editorconfig-exclude-regexps () + "List 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) +(with-eval-after-load 'recentf + (add-to-list 'editorconfig-exclude-regexps + (rx-to-string '(seq string-start + (eval (expand-file-name recentf-save-file))) + t))) + +(defcustom editorconfig-trim-whitespaces-mode nil + "Buffer local minor-mode to use to trim trailing whitespaces. + +If set, enable that mode when `trim_trailing_whitespace` is set to true. +Otherwise, use `delete-trailing-whitespace'." + :type 'symbol + :group 'editorconfig) + +(defvar editorconfig-properties-hash nil + "Hash object of EditorConfig properties that was enabled for current buffer. +Set by `editorconfig-apply' and nil if that is not invoked in +current buffer yet.") +(make-variable-buffer-local 'editorconfig-properties-hash) +(put 'editorconfig-properties-hash + 'permanent-local + t) + +(defvar editorconfig-lisp-use-default-indent nil + "Selectively ignore the value of indent_size for 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.") + +(defcustom editorconfig-override-file-local-variables t + "Non-nil means editorconfig will override file local variable values." + :type 'boolean + :group 'editorconfig) + +(defcustom editorconfig-override-dir-local-variables t + "Non-nil means editorconfig will override values defined in dir-locals.el ." + :type 'boolean + :group 'editorconfig) + +(define-error 'editorconfig-error + "Error thrown from editorconfig lib") + +(defun editorconfig-error (&rest args) + "Signal an `editorconfig-error'. +Make a message by passing ARGS to `format-message'." + (signal 'editorconfig-error (list (apply #'format-message args)))) + +(defun editorconfig--disabled-for-filename (filename) + "Return non-nil when EditorConfig is disabled for FILENAME." + (cl-assert (stringp filename)) + (cl-loop for regexp in editorconfig-exclude-regexps + if (string-match regexp filename) return t + finally return nil)) + +(defun editorconfig--disabled-for-majormode (majormode) + "Return non-nil when Editorconfig is disabled for MAJORMODE." + (cl-assert majormode) + (or (provided-mode-derived-p majormode 'special-mode) + ;; Some special modes (like `archive-mode') are not derived from + ;; `special-mode' + (eq (get majormode 'mode-class) 'special) + (memq majormode + editorconfig-exclude-modes))) + +(defun editorconfig-string-integer-p (string) + "Return non-nil if STRING represents integer." + (and (stringp string) + (string-match-p "\\`[0-9]+\\'" string))) + +(defun editorconfig-set-indentation-latex-mode (size) + "Set `latex-mode' indent size to SIZE." + (setq-local LaTeX-indent-level size) + (setq-local LaTeX-item-indent size) + (setq-local TeX-brace-indent-level size)) + +(cl-defun editorconfig--should-set (symbol &optional size) + "Determine if editorconfig should set SYMBOL. + +Optional arg SIZE is used when symbol is `lisp-indent-offset'. +See `editorconfig-lisp-use-default-indent' for details." + (display-warning '(editorconfig editorconfig--should-set) + (format "symbol: %S | size: %S" + symbol + size) + :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)) + + (when (eq symbol 'lisp-indent-offset) + (cl-return-from editorconfig--should-set + (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 (style &optional size tab_width) + "Set indentation type from STYLE, SIZE and 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) + ) + + (cond ((not (editorconfig--should-set 'indent-tabs-mode)) + nil) + ) + + (when (editorconfig--should-set 'evil-shift-width) + ) + ) + +(defvar-local editorconfig--apply-coding-system-currently nil + "Used internally.") +(put 'editorconfig--apply-coding-system-currently + 'permanent-local + t) + +(defun editorconfig-merge-coding-systems (end-of-line charset) + "Return merged coding system symbol of END-OF-LINE and CHARSET." + (let ((eol (cond + ((equal end-of-line "lf") 'undecided-unix) + ((equal end-of-line "cr") 'undecided-mac) + ((equal end-of-line "crlf") 'undecided-dos) + (t 'undecided))) + (cs (cond + ((equal charset "latin1") 'iso-latin-1) + ((equal charset "utf-8") 'utf-8) + ((equal charset "utf-8-bom") 'utf-8-with-signature) + ((equal charset "utf-16be") 'utf-16be-with-signature) + ((equal charset "utf-16le") 'utf-16le-with-signature) + (t 'undecided)))) + (merge-coding-systems cs eol))) + +(cl-defun editorconfig-set-coding-system-revert (end-of-line charset) + "Set buffer coding system by END-OF-LINE and CHARSET. + +This function will revert buffer when the coding-system has been changed." + ;; `editorconfig--advice-find-file-noselect' does not use this function + (let ((coding-system (editorconfig-merge-coding-systems end-of-line + charset))) + (display-warning '(editorconfig editorconfig-set-coding-system-revert) + (format "editorconfig-set-coding-system-revert: buffer-file-name: %S | buffer-file-coding-system: %S | coding-system: %S | apply-currently: %S" + buffer-file-name + buffer-file-coding-system + coding-system + editorconfig--apply-coding-system-currently) + :debug) + (when (eq coding-system 'undecided) + (cl-return-from editorconfig-set-coding-system-revert)) + (when (and buffer-file-coding-system + (memq buffer-file-coding-system + (coding-system-aliases (merge-coding-systems coding-system + buffer-file-coding-system)))) + (cl-return-from editorconfig-set-coding-system-revert)) + (unless (file-readable-p buffer-file-name) + (set-buffer-file-coding-system coding-system) + (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 + (unwind-protect + (progn + (setq editorconfig--apply-coding-system-currently coding-system) + ;; Revert without query if buffer is not modified + (let ((revert-without-query '("."))) + (revert-buffer-with-coding-system coding-system))) + (setq editorconfig--apply-coding-system-currently nil))))) + +(defun editorconfig-set-trailing-nl (final-newline) + "Set up requiring final newline by FINAL-NEWLINE. + +This function will set `require-final-newline' and `mode-require-final-newline' +to non-nil when FINAL-NEWLINE is true." + (pcase final-newline + ("true" + ) + ("false" + ))) + +(defun editorconfig-set-trailing-ws (trim-trailing-ws) + (if editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 1) + ...) + (when editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 0)) + ...) + +(defun editorconfig-set-line-length (length) + "Set the max line length (`fill-column') to LENGTH." + (when (and (editorconfig-string-integer-p length) + (> (string-to-number length) 0)) + (setq fill-column (string-to-number length)))) + + +(defun editorconfig--execute-editorconfig-exec (filename) + "Execute EditorConfig core with FILENAME and return output." + (if filename + (with-temp-buffer + (let ((remote (file-remote-p filename)) + (remote-localname (file-remote-p filename + 'localname))) + (display-warning '(editorconfig editorconfig--execute-editorconfig-exec) + (format "editorconfig--execute-editorconfig-exec: filename: %S | remote: %S | remote-localname: %S" + filename + remote + remote-localname) + :debug) + (if remote + (progn + (cd (concat remote "/")) + (setq filename remote-localname)) + (cd "/"))) + (display-warning '(editorconfig editorconfig--execute-editorconfig-exec) + (format "editorconfig--execute-editorconfig-exec: default-directory: %S | filename: %S" + default-directory + filename + ) + :debug) + (if (eq 0 + (process-file editorconfig-exec-path nil t nil filename)) + (buffer-string) + (editorconfig-error (buffer-string)))) + "")) + +(defun editorconfig--parse-properties (props-string) + ) + +(defun editorconfig-get-properties-from-exec (filename) + "Get EditorConfig properties of file FILENAME. + +This function uses value of `editorconfig-exec-path' to get properties." + (if (executable-find editorconfig-exec-path) + (editorconfig--parse-properties (editorconfig--execute-editorconfig-exec filename)) + (editorconfig-error "Unable to find editorconfig executable"))) + +(defun editorconfig-get-properties (filename) + "Get EditorConfig properties for file FILENAME. + +It calls `editorconfig-get-properties-from-exec' if +`editorconfig-exec-path' is found, otherwise +`editorconfig-core-get-properties-hash'." + (if (and (executable-find editorconfig-exec-path) + (not (file-remote-p filename))) + (editorconfig-get-properties-from-exec filename) + (require 'editorconfig-core) + (editorconfig-core-get-properties-hash filename))) + +(defun editorconfig-call-get-properties-function (filename) + "Call `editorconfig-get-properties-function' with FILENAME and return result. + +This function also removes `unset' properties and calls +`editorconfig-hack-properties-functions'." + (unless (functionp editorconfig-get-properties-function) + (editorconfig-error "Invalid editorconfig-get-properties-function value")) + (if (stringp filename) + (setq filename (expand-file-name filename)) + (editorconfig-error "Invalid argument: %S" filename)) + (let ((props nil)) + (condition-case err + (setq props (funcall editorconfig-get-properties-function + filename)) + (error + (editorconfig-error "Error from editorconfig-get-properties-function: %S" + err))) + (cl-loop for k being the hash-keys of props using (hash-values v) + when (equal v "unset") do (remhash k props)) + props)) + +(defun editorconfig-set-local-variables (props) + "Set buffer variables according to EditorConfig PROPS." + (editorconfig-set-indentation (gethash 'indent_style props) + (gethash 'indent_size props) + (gethash 'tab_width props)) + (editorconfig-set-trailing-nl (gethash 'insert_final_newline props)) + (editorconfig-set-trailing-ws (gethash 'trim_trailing_whitespace props)) + (editorconfig-set-line-length (gethash 'max_line_length props))) + + +(defun editorconfig-major-mode-hook () + "Function to run when `major-mode' has been changed. + +This functions does not reload .editorconfig file, just sets local variables +again. Changing major mode can reset these variables. + +This function also executes `editorconfig-after-apply-functions' functions." + (display-warning '(editorconfig editorconfig-major-mode-hook) + (format "editorconfig-major-mode-hook: editorconfig-mode: %S, major-mode: %S, -properties-hash: %S" + (and (boundp 'editorconfig-mode) + editorconfig-mode) + major-mode + editorconfig-properties-hash) + :debug) + (when (and (bound-and-true-p editorconfig-mode) + editorconfig-properties-hash) + (editorconfig-set-local-variables editorconfig-properties-hash) + (condition-case err + (run-hook-with-args 'editorconfig-after-apply-functions editorconfig-properties-hash) + (error + (display-warning '(editorconfig editorconfig-major-mode-hook) + (format "Error while running `editorconfig-after-apply-functions': %S" + err)))))) + +(defvar editorconfig--filename-codingsystem-hash (make-hash-table :test 'equal) + "Used interally. + +`editorconfig--advice-find-file-noselect' will put value to this hash, and +`editorconfig--advice-insert-file-contents' will use the value to set +`coding-system-for-read' value.") + +(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--filename-codingsystem-hash' 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--filename-codingsystem-hash + buffer-file-name) + :debug) + (let ((coding-system (and (stringp filename) + (gethash (expand-file-name filename) + editorconfig--filename-codingsystem-hash)))) + (if (and coding-system + (not (eq coding-system + 'undecided))) + (let ((coding-system-for-read coding-system)) + (apply f filename args)) + (apply f filename args)))) + +(defun editorconfig--advice-find-file-noselect (f filename &rest args) + "Get EditorConfig properties and apply them to buffer to be visited. + +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))) + (puthash (expand-file-name filename) + coding-system + editorconfig--filename-codingsystem-hash)) + (error + (display-warning '(editorconfig editorconfig--advice-find-file-noselect) + (format "Failed to get properties, styles will not be applied: %S" + err) + :warning))) + + (setq ret (apply f filename args)) + (clrhash editorconfig--filename-codingsystem-hash) + + (condition-case err + (with-current-buffer ret + (when (and props + ;; filename has already been checked + (not (editorconfig--disabled-for-majormode major-mode))) + + ;; 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 this case, explicitly set this value so that saving will be done + ;; with expected coding system. + (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))) + (set-buffer-file-coding-system coding-system)) + + ;; 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) + (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) + ;; When initializing buffer, `editorconfig-major-mode-hook' + ;; will be called before setting `editorconfig-properties-hash', so + ;; execute this explicitly here. + (editorconfig-set-local-variables props) + + (condition-case err + (run-hook-with-args 'editorconfig-after-apply-functions props) + (error + (display-warning '(editorconfig editorconfig--advice-find-file-noselect) + (format "Error while running `editorconfig-after-apply-functions': %S" + err)))))) + (error + (display-warning '(editorconfig editorconfig--advice-find-file-noselect) + (format "Error while setting variables from EditorConfig: %S" err)))) + ret)) + + +;;;###autoload +(define-minor-mode editorconfig-mode + "Toggle EditorConfig feature. + +To disable EditorConfig in some buffers, modify +`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'." + :global t + :lighter editorconfig-mode-lighter + (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) + (dolist (hook modehooks) + (remove-hook hook 'editorconfig-major-mode-hook))))) + + +;; (defconst editorconfig--version +;; (eval-when-compile +;; (require 'lisp-mnt) +;; (declare-function lm-version "lisp-mnt" nil) +;; (lm-version)) +;; "EditorConfig version.") + +(declare-function find-library-name "find-func" (library)) +(declare-function lm-version "lisp-mnt" nil) + +;;;###autoload +(defun editorconfig-version (&optional show-version) + "Get EditorConfig version as string. + +If called interactively or if SHOW-VERSION is non-nil, show the +version in the echo area and the messages buffer." + (interactive (list t)) + (let* ((version (with-temp-buffer + (require 'find-func) + (insert-file-contents (find-library-name "editorconfig")) + (require 'lisp-mnt) + (lm-version))) + (pkg (and (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))) + (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: