dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

commit 6b318ffa8ed2dd0bf97254c4ca369cf266ea6c45
parent f5a27d61bfe3f74aff9b4b74ccd540f25e148d17
Author: Lukas Henkel <lh@entf.net>
Date:   Sun, 17 Jul 2022 20:42:48 +0200

Add editorconfig mode

Diffstat:
Aelpa/editorconfig-0.8.2.signed | 2++
Aelpa/editorconfig-0.8.2/.editorconfig | 30++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/.github/workflows/build.yaml | 40++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/CHANGELOG.md | 307+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/CONTRIBUTORS | 11+++++++++++
Aelpa/editorconfig-0.8.2/LICENSE | 674+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/Makefile | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/README.md | 248+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/dir | 18++++++++++++++++++
Aelpa/editorconfig-0.8.2/doc/editorconfig.texi | 297+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/doc/header.txt | 6++++++
Aelpa/editorconfig-0.8.2/editorconfig-autoloads.el | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig-conf-mode.el | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig-core-handle.el | 266+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig-core.el | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig-fnmatch.el | 291++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig-pkg.el | 2++
Aelpa/editorconfig-0.8.2/editorconfig.el | 992+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aelpa/editorconfig-0.8.2/editorconfig.info | 348+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Minit.el | 4+++-
20 files changed, 4056 insertions(+), 1 deletion(-)

diff --git a/elpa/editorconfig-0.8.2.signed b/elpa/editorconfig-0.8.2.signed @@ -0,0 +1 @@ +Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org> (trust undefined) created at 2021-08-13T23:05:03+0200 using RSA +\ No newline at end of file diff --git a/elpa/editorconfig-0.8.2/.editorconfig b/elpa/editorconfig-0.8.2/.editorconfig @@ -0,0 +1,30 @@ +root = true + +[*] +end_of_line = lf + +trim_trailing_whitespace = true +insert_final_newline = true + + +[*.el] +indent_style = space +max_line_length = 80 + + +[Makefile] +indent_style = tab +tab_width = 4 + + +[.gitmodules] +indent_style = tab +tab_width = 4 + + +[*.yml] +indent_style = space +indent_size = 2 + +[ert-tests/**/*.ini] +file_type_ext = editorconfig diff --git a/elpa/editorconfig-0.8.2/.github/workflows/build.yaml b/elpa/editorconfig-0.8.2/.github/workflows/build.yaml @@ -0,0 +1,40 @@ +--- +name: build + +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize] + branches: + - 'master' + release: + types: [published] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + emacs_version: + - "24.5" + - "25.3" + - "26.3" + - "27.1" + experimental: [false] + include: + - emacs_version: snapshot + experimental: true + continue-on-error: ${{ matrix.experimental }} + steps: + - name: Checkout + uses: actions/checkout@v1 + with: + submodules: recursive + - name: Setup Emacs + uses: purcell/setup-emacs@master + with: + version: ${{ matrix.emacs_version }} + - name: Run tests + run: make check diff --git a/elpa/editorconfig-0.8.2/CHANGELOG.md b/elpa/editorconfig-0.8.2/CHANGELOG.md @@ -0,0 +1,307 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + + +## [0.8.2] - 2021-08-13 + +### Added + +- Add rustic-mode to editorconfig-indentation-alist ([#208]) +- Add conf-mode abbrev-table definitions ([#220]) +- Add meson-mode indentation rule ([#253]) +- Add support for rjsx-mode ([#254]) +- Update README for NonGNU ELPA repository ([#259]) +- Add new implementation of editorconfig-mode ([#248], [#250], [#251], [#255], [#258], [#260]) + - By default this is disabled: set `(setq editorconfig--enable-20210221-testing t)` to use this + +### Fixed + +- Fix so that "?" does not match "/" ([#211]) +- Fix document typo ([#213]) +- Don't make unchanged vars buffer-local ([#222]) +- Silence byte-compiler warnings ([#235]) +- Use revert-buffer-with-coding-system to set coding system ([#236]) +- Do not run editorconfig-apply on recentf-save-file ([#241]) +- Skip special-mode buffers when applying ([#247]) +- Stop excluding remote files by default ([#234], [#245]) +- Fix editorconfig execution for remote hosts via tramp ([#249]) +- Add minor fixes to tests ([#252]) +- Fix excluding the recentf-save-file when in a symlinked directory ([#256]) + +### Changed + +- Define -mode-apply as an interactive command ([#216]) +- Use elisp core by default ([#209]) +- User functions in the hooks `editorconfig-hack-properties-functions` and + `editorconfig-after-apply-functions` can no longer distinguish explicitly + unset properties from ones that were never set in the first place. ([#222]) + + +## [0.8.1] - 2019-10-10 + +### Added + +- Add indentation support + - [#196] + - enh-ruby-mode + - haxor-mode + - mips-mode + - nasm-mode + - terra-mode + - kotlin-mode + - bpftrace-mode ([#199]) + - f90-mode ([#200]) +- Add explicit support for rpm-spec-mode ([efc1ff4], see [#197] ) +- Add whitelist for file_type_emacs value ([#204]) + + +## [0.8.0] - 2019-03-26 + +### Fixed + +- Allow library forget properties order ([#187]) +- Use API to get version info ([#193]) + - `editorconfig-version()` was added and `editorconfig-core-version` removed +- Update docs and metadata to follow MELPA guidelines ([#189]) +- Refactor ([#188], [#191]) + + +## [0.7.14] - 2018-12-25 + +### Added + +- Add feature to decide major-mode from file_type_ext [EXPERIMENTAL] [#175] ([#178]) ([#179]) ([#180]) +- Add feature to hack properties before applying [#182] +- Add variable editorconfig-trim-whitespaces-mode [#183] + - Useful when you want to use non-default mode like `ws-butler` to trim spaces + +### Fixed + +- Make conf-mode used when a file has .editorconfig extension [01a0640] +- Fix tests +- Fix docs + +### Changed + +- Change hook name -custom-hooks -> -after-apply-functions [bb4bc44] + + +## [0.7.13] - 2018-08-23 + +### Fixed + +- Check editorconfig configs when read only state changes ([#168]) +- use CURDIR instead of PWD in Makefile ([#170]) +- Refactor fnmatch-p ([#171]) +- Update tests + + +## [0.7.12] - 2018-06-20 + +### Added + +- Add /Fix major-mode support + - pug-mode [#149] + - csharp-mode [#154] +- Add variable to disable lisp-indent-offset sometimes [#155] +- Add texinfo doc [#159] + +### Fixed + +- Avoid passing a non-absolute file path to editorconfig(1) [#151] +- Use "-with-signature" coding systems for all UTF-16 charsets [#158] +- Allow normal whitespace when reading EditorConfig settings file [#162] +- Add some fixes to tests + + +## [0.7.11] - 2017-11-07 + +### Added + +- Add /Fix major-mode support + - apache-mode + - groovy-mode + - web-mode +- Add support for a custom lighter +- Add editorconfig-format-buffer function +- Add experimental file_type_emacs support + +### Changed + +- Change hook editorconfig is applied on + + +## [0.7.10] - 2017-06-07 + +*Undocumented* + +## [0.7.9] - 2017-02-22 + +*Undocumented* + +## [0.7.8] - 2016-08-09 + +*Undocumented* + +## [0.7.7] - 2016-07-19 + +*Undocumented* + +## [0.7.6] - 2016-05-05 + +*Undocumented* + +## [0.7.5] - 2016-04-22 + +*Undocumented* + +## [0.7.4] - 2016-03-31 + +*Undocumented* + +## [0.7.3] - 2016-02-12 + +*Undocumented* + +## [0.7.2] - 2016-01-27 + +*Undocumented* + +## [0.7.1] - 2016-01-24 + +*Undocumented* + +## [0.7.0] - 2016-01-17 + +*Undocumented* + +## [0.6.2] - 2016-01-15 + +*Undocumented* + +## [0.6.1] - 2015-12-09 + +*Undocumented* + +## [0.6] - 2015-12-04 + +*Undocumented* + +## [0.5] - 2015-11-04 + +*Undocumented* + +## [0.4] - 2014-12-20 + +*Undocumented* + +## [0.3] - 2014-05-07 + +*Undocumented* + +## [0.2] - 2013-06-06 + +*Undocumented* + +## [0.1] - 2012-02-07 + +*Undocumented* + + +[Unreleased]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.8.2...HEAD +[0.8.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.8.1...v0.8.2 +[0.8.1]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.8.0...v0.8.1 +[0.8.0]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.14...v0.8.0 +[0.7.14]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.13...v0.7.14 +[0.7.13]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.12...v0.7.13 +[0.7.12]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.11...v0.7.12 +[0.7.11]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.10...v0.7.11 +[0.7.10]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.9...v0.7.10 +[0.7.9]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.8...v0.7.9 +[0.7.8]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.7...v0.7.8 +[0.7.7]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.6...v0.7.7 +[0.7.6]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.5...v0.7.6 +[0.7.5]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.4...v0.7.5 +[0.7.4]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.3...v0.7.4 +[0.7.3]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.2...v0.7.3 +[0.7.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.1...v0.7.2 +[0.7.1]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.7.0...v0.7.1 +[0.7.0]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.6.2...v0.7.0 +[0.6.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.6.1...v0.6.2 +[0.6.1]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.6...v0.6.1 +[0.6]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.5...v0.6 +[0.5]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.4...v0.5 +[0.4]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.3...v0.4 +[0.3]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.2...v0.3 +[0.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.1...v0.2 +[0.1]: https://github.com/editorconfig/editorconfig-emacs/releases/tag/v0.1 +[#260]: https://github.com/editorconfig/editorconfig-emacs/issues/260 +[#258]: https://github.com/editorconfig/editorconfig-emacs/issues/258 +[#255]: https://github.com/editorconfig/editorconfig-emacs/issues/255 +[#251]: https://github.com/editorconfig/editorconfig-emacs/issues/251 +[#250]: https://github.com/editorconfig/editorconfig-emacs/issues/250 +[#248]: https://github.com/editorconfig/editorconfig-emacs/issues/248 +[#259]: https://github.com/editorconfig/editorconfig-emacs/issues/259 +[#256]: https://github.com/editorconfig/editorconfig-emacs/issues/256 +[#252]: https://github.com/editorconfig/editorconfig-emacs/issues/252 +[#249]: https://github.com/editorconfig/editorconfig-emacs/issues/249 +[#245]: https://github.com/editorconfig/editorconfig-emacs/issues/245 +[#234]: https://github.com/editorconfig/editorconfig-emacs/issues/234 +[#241]: https://github.com/editorconfig/editorconfig-emacs/issues/241 +[#236]: https://github.com/editorconfig/editorconfig-emacs/issues/236 +[#235]: https://github.com/editorconfig/editorconfig-emacs/issues/235 +[#222]: https://github.com/editorconfig/editorconfig-emacs/issues/222 +[#222]: https://github.com/editorconfig/editorconfig-emacs/issues/222 +[#220]: https://github.com/editorconfig/editorconfig-emacs/issues/220 +[#216]: https://github.com/editorconfig/editorconfig-emacs/issues/216 +[#213]: https://github.com/editorconfig/editorconfig-emacs/issues/213 +[#211]: https://github.com/editorconfig/editorconfig-emacs/issues/211 +[#209]: https://github.com/editorconfig/editorconfig-emacs/issues/209 +[#208]: https://github.com/editorconfig/editorconfig-emacs/issues/208 +[#204]: https://github.com/editorconfig/editorconfig-emacs/issues/204 +[#200]: https://github.com/editorconfig/editorconfig-emacs/issues/200 +[#199]: https://github.com/editorconfig/editorconfig-emacs/issues/199 +[#197]: https://github.com/editorconfig/editorconfig-emacs/issues/197 +[#196]: https://github.com/editorconfig/editorconfig-emacs/issues/196 +[#193]: https://github.com/editorconfig/editorconfig-emacs/issues/193 +[#191]: https://github.com/editorconfig/editorconfig-emacs/issues/191 +[#189]: https://github.com/editorconfig/editorconfig-emacs/issues/189 +[#188]: https://github.com/editorconfig/editorconfig-emacs/issues/188 +[#187]: https://github.com/editorconfig/editorconfig-emacs/issues/187 +[#183]: https://github.com/editorconfig/editorconfig-emacs/issues/183 +[#182]: https://github.com/editorconfig/editorconfig-emacs/issues/182 +[#180]: https://github.com/editorconfig/editorconfig-emacs/issues/180 +[#179]: https://github.com/editorconfig/editorconfig-emacs/issues/179 +[#178]: https://github.com/editorconfig/editorconfig-emacs/issues/178 +[#175]: https://github.com/editorconfig/editorconfig-emacs/issues/175 +[#171]: https://github.com/editorconfig/editorconfig-emacs/issues/171 +[#170]: https://github.com/editorconfig/editorconfig-emacs/issues/170 +[#168]: https://github.com/editorconfig/editorconfig-emacs/issues/168 +[#162]: https://github.com/editorconfig/editorconfig-emacs/issues/162 +[#159]: https://github.com/editorconfig/editorconfig-emacs/issues/159 +[#158]: https://github.com/editorconfig/editorconfig-emacs/issues/158 +[#155]: https://github.com/editorconfig/editorconfig-emacs/issues/155 +[#154]: https://github.com/editorconfig/editorconfig-emacs/issues/154 +[#151]: https://github.com/editorconfig/editorconfig-emacs/issues/151 +[#149]: https://github.com/editorconfig/editorconfig-emacs/issues/149 +[01a0640]: https://github.com/editorconfig/editorconfig-emacs/commit/01a064015ed8d00f2853f966f07d2be5b97bfe5e +[efc1ff4]: https://github.com/editorconfig/editorconfig-emacs/commit/efc1ff4b1c3422d6e231b1c01138becab4b9eded +[bb4bc44]: https://github.com/editorconfig/editorconfig-emacs/commit/bb4bc4497783e6607480cd0b761f974136784fdd diff --git a/elpa/editorconfig-0.8.2/CONTRIBUTORS b/elpa/editorconfig-0.8.2/CONTRIBUTORS @@ -0,0 +1,11 @@ +Contributors to EditorConfig Emacs plugin (chronological order): + +Trey Hunner +Jonas Bernoulli +Johan Sundström +Desmond O. Chang +Steve Jordan +Hong Xu +10sr +Usami Kenta +Izaak "Zaak" Beekman diff --git a/elpa/editorconfig-0.8.2/LICENSE b/elpa/editorconfig-0.8.2/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<https://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<https://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/elpa/editorconfig-0.8.2/Makefile b/elpa/editorconfig-0.8.2/Makefile @@ -0,0 +1,75 @@ +# -*- Makefile -*- + +TEXI_CHAPTER := EditorConfig Emacs Plugin + +EMACS = emacs +PANDOC = pandoc +AWK = awk + +PROJECT_ROOT_DIR = $(CURDIR) +ERT_TESTS = $(wildcard $(PROJECT_ROOT_DIR)/ert-tests/*.el) + +# Compile with noninteractive and relatively clean environment. +BATCHFLAGS = -batch -q --no-site-file -L $(PROJECT_ROOT_DIR) + +MAIN_SRC = editorconfig.el +SRCS = $(wildcard $(PROJECT_ROOT_DIR)/*.el) +OBJS = $(SRCS:.el=.elc) + +.PHONY: check \ + compile clean \ + test test-ert test-core \ + sandbox doc + +check: compile test + + +compile: $(OBJS) + +$(OBJS): %.elc: %.el + $(EMACS) $(BATCHFLAGS) -f batch-byte-compile $^ + +clean: + -rm -f $(OBJS) + + +doc: doc/editorconfig.texi + +doc/editorconfig.texi: README.md doc/header.txt + mkdir -p doc + tail -n +4 $< | $(PANDOC) -s -f markdown -t texinfo -o $@.body + $(AWK) 'f{print} /^@chapter $(TEXI_CHAPTER)/{f=1;print}' $@.body >$@.body2 + cat doc/header.txt $@.body2 >$@ + rm -f $@.body $@.body2 + +test: test-ert test-core + $(EMACS) $(BATCHFLAGS) -l editorconfig.el + + +# ert test +test-ert: $(ERT_TESTS) $(OBJS) + $(EMACS) $(BATCHFLAGS) \ + --eval "(setq debug-on-error t)" \ + --eval "(require 'ert)" \ + --eval "(setq metadata-el-files '($(MAIN_SRC:%=\"%\")))" \ + $(ERT_TESTS:%=-l "%") \ + -f ert-run-tests-batch-and-exit + + + +# Core test +core-test/CMakeLists.txt: + git submodule init + +test-core: core-test/CMakeLists.txt $(OBJS) + cd $(PROJECT_ROOT_DIR)/core-test && \ + cmake -DEDITORCONFIG_CMD="$(PROJECT_ROOT_DIR)/bin/editorconfig-el" . + cd $(PROJECT_ROOT_DIR)/core-test && \ + EMACS_BIN=$(EMACS) EDITORCONFIG_CORE_LIBRARY_PATH="$(PROJECT_ROOT_DIR)" \ + ctest --output-on-failure . + + +# Start Emacs that loads *.el in current directory and does not load the user +# init file +sandbox: + $(EMACS) -q -L $(PROJECT_ROOT_DIR) $(MAIN_SRC:%=-l "%") diff --git a/elpa/editorconfig-0.8.2/README.md b/elpa/editorconfig-0.8.2/README.md @@ -0,0 +1,248 @@ +![build](https://github.com/editorconfig/editorconfig-emacs/workflows/build/badge.svg) +[![MELPA](https://melpa.org/packages/editorconfig-badge.svg)](http://melpa.org/#/editorconfig) +[![MELPA Stable](https://stable.melpa.org/packages/editorconfig-badge.svg)](https://stable.melpa.org/#/editorconfig) +[![NonGNU ELPA](http://elpa.nongnu.org/nongnu/editorconfig.svg)](http://elpa.nongnu.org/nongnu/editorconfig.html) + + +# EditorConfig Emacs Plugin + +This is an [EditorConfig][] plugin for [Emacs][]. + + +## Getting Started + + +### package.el + +This package is available from [MELPA][], [MELPA Stable][] and [NonGNU ELPA][]. +Install from these repositories and enable global minor-mode `editorconfig-mode`: + +```emacs-lisp +(editorconfig-mode 1) +``` + +Normally, enabling `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. + + +### use-package + +If you use [**use-package**][use-package], add the following to your +`init.el` file: + +```emacs-lisp +(use-package editorconfig + :ensure t + :config + (editorconfig-mode 1)) +``` + + +### Manual installation + +Copy all `.el` files in this repository to `~/.emacs.d/lisp` and add the +following: + +```emacs-lisp +(add-to-list 'load-path "~/.emacs.d/lisp") +(require 'editorconfig) +(editorconfig-mode 1) +``` + + + +## Supported properties + +Current Emacs plugin coverage for EditorConfig's [properties][]: + +* `indent_style` +* `indent_size` +* `tab_width` +* `end_of_line` +* `charset` +* `trim_trailing_whitespace` +* `insert_final_newline = true` is supported +* <del>`insert_final_newline = false`</del> is not enforced + (as in trailing newlines actually being removed automagically), + we just buffer-locally override any preferences that would auto-add them + to files `.editorconfig` marks as trailing-newline-free +* `max_line_length` +* <del>`file_type_ext` (Experimental)</del> (See below) +* <del>`file_type_emacs` (Experimental)</del> (See below) +* `root` (only used by EditorConfig core) + +Not yet covered properties marked with <del>over-strike</del> +– 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. + + + +### <del>File Type (file_type_ext, file_type_emacs)</del> + +File-type feature is currently disabled, because this package is now undergoing +big internal refactoring. +For those who want this functionality, +please consider using [editorconfig-custom-majormode](https://github.com/10sr/editorconfig-custom-majormode-el). + + +## Customize + +`editorconfig-emacs` provides some customize variables. + +Here are some of these variables: for the full list of available variables, +type <kbd>M-x customize-group [RET] editorconfig [RET]</kbd>. + + +### `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 +`trim_trailing_whitespace` property in `.editorconfig`. +Otherwise, use Emacs built-in `delete-trailing-whitespace` function. + +One possible value is +[`ws-butler-mode`](https://github.com/lewang/ws-butler), with which +only lines touched get trimmed. To use it, add following to your +init.el: + +``` emacs-lisp +(setq editorconfig-trim-whitespaces-mode + 'ws-butler-mode) +``` + + +### `editorconfig-after-apply-functions` + +(Formerly `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, `web-mode` has several variables for indentation offset size and +EditorConfig sets them at once by `indent_size`. You can stop indenting +only blocks of `web-mode` by adding following to your init.el: + +```emacs-lisp +(add-hook 'editorconfig-after-apply-functions + (lambda (props) (setq web-mode-block-padding 0))) +``` + + +### `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 `major-mode` is +`makefile-mode`: + +``` emacs-lisp +(add-hook 'editorconfig-hack-properties-functions + '(lambda (props) + (when (derived-mode-p 'makefile-mode) + (puthash 'indent_style "tab" props)))) + +``` + + +## Troubleshooting + +Enabling `editorconfig-mode` should be enough for normal cases. + +When EditorConfig properties are not effective for unknown reason, we recommend +first trying `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. + + + +### 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 `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 +`editorconfig-indentation-alist`. + + +### Not work at all for FOO-mode! + +Most cases properties are loaded just after visiting files when +`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 `editorconfig-apply`. + +Typically it will occur when the major-mode is not defined using +`define-derived-mode` (`rpm-spec-mode` is an example for this). +Please feel free to submit issues if you find such modes! + + + + +## 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 + + +### Development + +Make and [CMake][] must be installed to run the tests +locally: + + $ make check + +To start a new Emacs process with current `*.el` and without loading user init +file, run: + + $ make sandbox + + + + +## License + +EditorConfig Emacs Plugin is free software: you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see <https://www.gnu.org/licenses/>. + + + +[Emacs]: https://www.gnu.org/software/emacs/ +[MELPA]: https://melpa.org/#/editorconfig +[MELPA Stable]: https://stable.melpa.org/#/editorconfig +[NonGNU ELPA]: http://elpa.nongnu.org/nongnu/editorconfig.html +[use-package]: https://www.emacswiki.org/emacs/UsePackage +[EditorConfig]: https://editorconfig.org +[EditorConfig C Core]: https://github.com/editorconfig/editorconfig-core-c +[properties]: https://editorconfig.org/#supported-properties +[CMake]: https://cmake.org diff --git a/elpa/editorconfig-0.8.2/dir b/elpa/editorconfig-0.8.2/dir @@ -0,0 +1,18 @@ +This is the file .../info/dir, which contains the +topmost node of the Info hierarchy, called (dir)Top. +The first time you invoke Info you start off looking at this node. + +File: dir, Node: Top This is the top of the INFO tree + + This (the Directory node) gives a menu of major topics. + Typing "q" exits, "H" lists all Info commands, "d" returns here, + "h" gives a primer for first-timers, + "mEmacs<Return>" visits the Emacs manual, etc. + + In Emacs, you can click mouse button 2 on a menu item or cross reference + to select it. + +* Menu: + +Emacs +* EditorConfig: (editorconfig). EditorConfig Emacs Plugin. diff --git a/elpa/editorconfig-0.8.2/doc/editorconfig.texi b/elpa/editorconfig-0.8.2/doc/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/elpa/editorconfig-0.8.2/doc/header.txt b/elpa/editorconfig-0.8.2/doc/header.txt @@ -0,0 +1,6 @@ +@dircategory Emacs +@direntry +* EditorConfig: (editorconfig). EditorConfig Emacs Plugin. +@end direntry + +@node Top diff --git a/elpa/editorconfig-0.8.2/editorconfig-autoloads.el b/elpa/editorconfig-0.8.2/editorconfig-autoloads.el @@ -0,0 +1,143 @@ +;;; editorconfig-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + + +;;; Generated autoloads from editorconfig.el + +(autoload 'editorconfig-apply "editorconfig" "\ +Get and apply EditorConfig properties to current buffer. + +This function does not respect the values of `editorconfig-exclude-modes' and +`editorconfig-exclude-regexps' and always applies available properties. +Use `editorconfig-mode-apply' instead to make use of these variables." t nil) +(defvar editorconfig-mode nil "\ +Non-nil if Editorconfig mode is enabled. +See the `editorconfig-mode' command +for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `editorconfig-mode'.") +(custom-autoload 'editorconfig-mode "editorconfig" nil) +(autoload 'editorconfig-mode "editorconfig" "\ +Toggle EditorConfig feature. + +To disable EditorConfig in some buffers, modify +`editorconfig-exclude-modes' or `editorconfig-exclude-regexps'. + +This is a global minor mode. If called interactively, toggle the +`Editorconfig mode' mode. If the prefix argument is positive, +enable the mode, and if it is zero or negative, disable the mode. + +If called from Lisp, toggle the mode if ARG is `toggle'. Enable +the mode if ARG is nil, omitted, or is a positive number. +Disable the mode if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate `(default-value \\='editorconfig-mode)'. + +The mode's hook is called both when the mode is enabled and when +it is disabled. + +(fn &optional ARG)" t nil) +(autoload 'editorconfig-find-current-editorconfig "editorconfig" "\ +Find the closest .editorconfig file for current file." t nil) +(autoload 'editorconfig-display-current-properties "editorconfig" "\ +Display EditorConfig properties extracted for current buffer." t nil) +(defalias 'describe-editorconfig-properties 'editorconfig-display-current-properties) +(autoload 'editorconfig-format-buffer "editorconfig" "\ +Format buffer according to .editorconfig indent_style and indent_width." t nil) +(autoload 'editorconfig-version "editorconfig" "\ +Get EditorConfig version as string. + +If called interactively or if SHOW-VERSION is non-nil, show the +version in the echo area and the messages buffer. + +(fn &optional SHOW-VERSION)" t nil) +(register-definition-prefixes "editorconfig" '("editorconfig-")) + + +;;; Generated autoloads from editorconfig-conf-mode.el + +(autoload 'editorconfig-conf-mode "editorconfig-conf-mode" "\ +Major mode for editing .editorconfig files. + +(fn)" t nil) +(add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode)) +(register-definition-prefixes "editorconfig-conf-mode" '("editorconfig-conf-mode-")) + + +;;; Generated autoloads from editorconfig-core.el + +(autoload 'editorconfig-core-get-nearest-editorconfig "editorconfig-core" "\ +Return path to .editorconfig file that is closest to DIRECTORY. + +(fn DIRECTORY)" nil nil) +(autoload 'editorconfig-core-get-properties "editorconfig-core" "\ +Get EditorConfig properties for FILE. +If FILE is not given, use currently visiting file. +Give CONFNAME for basename of config file other than .editorconfig. +If need to specify config format version, give CONFVERSION. + +This functions returns alist of properties. Each element will look like +'(KEY . VALUE) . + +(fn &optional FILE CONFNAME CONFVERSION)" nil nil) +(autoload 'editorconfig-core-get-properties-hash "editorconfig-core" "\ +Get EditorConfig properties for FILE. +If FILE is not given, use currently visiting file. +Give CONFNAME for basename of config file other than .editorconfig. +If need to specify config format version, give CONFVERSION. + +This function is almost same as `editorconfig-core-get-properties', but returns +hash object instead. + +(fn &optional FILE CONFNAME CONFVERSION)" nil nil) +(register-definition-prefixes "editorconfig-core" '("editorconfig-core--")) + + +;;; Generated autoloads from editorconfig-core-handle.el + +(register-definition-prefixes "editorconfig-core-handle" '("editorconfig-core-handle")) + + +;;; Generated autoloads from editorconfig-fnmatch.el + +(autoload 'editorconfig-fnmatch-p "editorconfig-fnmatch" "\ +Test whether STRING match PATTERN. + +Matching ignores case if `case-fold-search' is non-nil. + +PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can +be used: + +* Matches any string of characters, except path separators (/) +** Matches any string of characters +? Matches any single character +[name] Matches any single character in name +[^name] Matches any single character not in name +{s1,s2,s3} Matches any of the strings given (separated by commas) +{min..max} Matches any number between min and max + +(fn STRING PATTERN)" nil nil) +(register-definition-prefixes "editorconfig-fnmatch" '("editorconfig-fnmatch-")) + +;;; End of scraped data + +(provide 'editorconfig-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8-emacs-unix +;; End: + +;;; editorconfig-autoloads.el ends here diff --git a/elpa/editorconfig-0.8.2/editorconfig-conf-mode.el b/elpa/editorconfig-0.8.2/editorconfig-conf-mode.el @@ -0,0 +1,101 @@ +;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2021 EditorConfig Team + +;; Author: EditorConfig Team <editorconfig@googlegroups.com> + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors +;; or the CONTRIBUTORS file for the list of contributors. + +;; This file is part of EditorConfig Emacs Plugin. + +;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at your +;; option) any later version. + +;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +;; Public License for more details. + +;; You should have received a copy of the GNU General Public License along with +;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Major mode for editing .editorconfig files. + +;;; Code: + +(require 'conf-mode) + +(defvar editorconfig-conf-mode-syntax-table + (let ((table (make-syntax-table conf-unix-mode-syntax-table))) + (modify-syntax-entry ?\; "<" table) + table) + "Syntax table in use in `editorconfig-conf-mode' buffers.") + +(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/elpa/editorconfig-0.8.2/editorconfig-core-handle.el b/elpa/editorconfig-0.8.2/editorconfig-core-handle.el @@ -0,0 +1,266 @@ +;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2021 EditorConfig Team + +;; Author: EditorConfig Team <editorconfig@googlegroups.com> + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors +;; or the CONTRIBUTORS file for the list of contributors. + +;; This file is part of EditorConfig Emacs Plugin. + +;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at your +;; option) any later version. + +;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +;; Public License for more details. + +;; You should have received a copy of the GNU General Public License along with +;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Handle structures for EditorConfig config file. This library is used +;; internally from editorconfig-core.el . + +;;; Code: + +(require 'cl-lib) + +(require 'editorconfig-fnmatch) + +(defvar editorconfig-core-handle--cache-hash + (make-hash-table :test 'equal) + "Hash of EditorConfig filename and its `editorconfig-core-handle' instance.") + +(cl-defstruct editorconfig-core-handle-section + "Structure representing one section in a .editorconfig file. + +Slots: + +`name' + String of section name (glob string). + +`props' + Alist of properties: (KEY . VALUE)." + (name nil) + (props nil)) + +(defun editorconfig-core-handle-section-get-properties (section file dir) + "Return properties alist when SECTION name match FILE. + +DIR should be the directory where .editorconfig file which has SECTION lives. +IF not match, return nil." + (when (editorconfig-core-handle--fnmatch-p + file + (editorconfig-core-handle-section-name section) + dir) + (editorconfig-core-handle-section-props section))) + +(cl-defstruct editorconfig-core-handle + "Structure representing an .editorconfig file. + +Slots: +`top-props' + Alist of top 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 (point-at-bol) + (point-at-eol))) + (setq line + (replace-regexp-in-string "\\(^\\| \\)\\(#\\|;\\).*$" + "" + (editorconfig-core-handle--string-trim line))) + + (cond + ((string-equal "" line) + nil) + + ;; Start of section + ((string-match "^\\[\\(.*\\)\\]$" + line) + (when pattern + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props))) + (setq pattern nil) + (setq props nil)) + (setq pattern (match-string 1 line))) + + (t + (let ((idx (string-match "=\\|:" + line))) + (unless idx + (error "Error while reading config file: %s:%d:\n %s\n" + conf + current-line-number + line)) + (let ( + (key (downcase (editorconfig-core-handle--string-trim + (substring line + 0 + idx)))) + (value (editorconfig-core-handle--string-trim + (substring line + (1+ idx))))) + (when (and (< (length key) 51) + (< (length value) 256)) + (if pattern + (when (< (length pattern) 4097) + (setq props + `(,@props (,key . ,value)))) + (setq top-props + `(,@top-props (,key . ,value)))))))) + ) + (setq current-line-number + (1+ current-line-number)) + (goto-char (point-min)) + (forward-line (1- current-line-number)) + ) + (when pattern + (setq sections + `(,@sections ,(make-editorconfig-core-handle-section + :name pattern + :props props)))) + (list :top-props top-props + :sections sections))))) + +(provide 'editorconfig-core-handle) + +;;; editorconfig-core-handle.el ends here diff --git a/elpa/editorconfig-0.8.2/editorconfig-core.el b/elpa/editorconfig-0.8.2/editorconfig-core.el @@ -0,0 +1,202 @@ +;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2021 EditorConfig Team + +;; Author: EditorConfig Team <editorconfig@googlegroups.com> + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors +;; or the CONTRIBUTORS file for the list of contributors. + +;; This file is part of EditorConfig Emacs Plugin. + +;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at your +;; option) any later version. + +;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +;; Public License for more details. + +;; You should have received a copy of the GNU General Public License along with +;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; This library is one implementation of EditorConfig Core, which parses +;; .editorconfig files and returns properties for given files. +;; This can be used in place of, for example, editorconfig-core-c. + + +;; Use from EditorConfig Emacs Plugin + +;; Emacs plugin (v0.5 or later) can utilize this implementation. +;; By default, the plugin first search for any EditorConfig executable, +;; and fallback to this library if not found. +;; If you always want to use this library, add following lines to your init.el: + +;; (setq editorconfig-get-properties-function +;; 'editorconfig-core-get-properties-hash) + + +;; Functions + +;; editorconfig-core-get-properties (&optional file confname confversion) + +;; Get EditorConfig properties for FILE. + +;; If FILE is not given, use currently visiting file. +;; Give CONFNAME for basename of config file other than .editorconfig. +;; If need to specify config format version, give CONFVERSION. + +;; This functions returns alist of properties. Each element will look like +;; (KEY . VALUE) . + + +;; editorconfig-core-get-properties-hash (&optional file confname confversion) + +;; Get EditorConfig properties for FILE. + +;; This function is almost same as `editorconfig-core-get-properties', but +;; returns hash object instead. + +;;; Code: + +(require 'cl-lib) + +(require 'editorconfig-core-handle) + + +(defun editorconfig-core--get-handles (dir confname &optional result) + "Get list of EditorConfig handlers for DIR from CONFNAME. + +In the resulting list, the handle for root config file comes first, and the +nearest comes last. +The list may contains nil when no file was found for directories. +RESULT is used internally and normally should not be used." + (setq dir (expand-file-name dir)) + (let ((handle (editorconfig-core-handle (concat (file-name-as-directory dir) + confname))) + (parent (file-name-directory (directory-file-name dir)))) + (if (or (string= parent + dir) + (and handle + (editorconfig-core-handle-root-p handle))) + (cl-remove-if-not 'identity + (cons handle result)) + (editorconfig-core--get-handles parent + confname + (cons handle + result))))) + +;;;###autoload +(defun editorconfig-core-get-nearest-editorconfig (directory) + "Return path to .editorconfig file that is closest to DIRECTORY." + (let ((handle (car (last (editorconfig-core--get-handles directory + ".editorconfig"))))) + (when handle + (editorconfig-core-handle-path handle)))) + +;;;###autoload +(defun editorconfig-core-get-properties (&optional file confname confversion) + "Get EditorConfig properties for FILE. +If FILE is not given, use currently visiting file. +Give CONFNAME for basename of config file other than .editorconfig. +If need to specify config format version, give CONFVERSION. + +This functions returns alist of properties. Each element will look like +'(KEY . VALUE) ." + (let ((hash (editorconfig-core-get-properties-hash file confname confversion)) + (result nil)) + (maphash (lambda (key value) + (add-to-list 'result + (cons (symbol-name key) + value))) + hash) + result)) + +(defun editorconfig-core--hash-merge (into update) + "Merge 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 + )) + (let ((val (gethash key + result))) + (when val + (puthash key + (downcase val) + result)))) + + ;; Add indent_size property + (let ((v-indent-size (gethash 'indent_size result)) + (v-indent-style (gethash 'indent_style result))) + (when (and (not v-indent-size) + (string= v-indent-style "tab") + ;; If VERSION < 0.9.0, indent_size should have no default value + (version<= "0.9.0" + confversion)) + (puthash 'indent_size + "tab" + result))) + ;; Add tab_width property + (let ((v-indent-size (gethash 'indent_size result)) + (v-tab-width (gethash 'tab_width result))) + (when (and v-indent-size + (not v-tab-width) + (not (string= v-indent-size "tab"))) + (puthash 'tab_width + v-indent-size + result))) + ;; Update indent-size property + (let ((v-indent-size (gethash 'indent_size result)) + (v-tab-width (gethash 'tab_width result))) + (when (and v-indent-size + v-tab-width + (string= v-indent-size "tab")) + (puthash 'indent_size + v-tab-width + result))) + + result)) + +(provide 'editorconfig-core) + +;;; editorconfig-core.el ends here diff --git a/elpa/editorconfig-0.8.2/editorconfig-fnmatch.el b/elpa/editorconfig-0.8.2/editorconfig-fnmatch.el @@ -0,0 +1,291 @@ +;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2021 EditorConfig Team + +;; Author: EditorConfig Team <editorconfig@googlegroups.com> + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors +;; or the CONTRIBUTORS file for the list of contributors. + +;; This file is part of EditorConfig Emacs Plugin. + +;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at your +;; option) any later version. + +;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +;; Public License for more details. + +;; You should have received a copy of the GNU General Public License along with +;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; editorconfig-fnmatch.el provides a fnmatch implementation with a few +;; extensions. +;; The main usage of this library is glob pattern matching for EditorConfig, but +;; it can also act solely. + +;; editorconfig-fnmatch-p (name pattern) + +;; Test whether NAME match PATTERN. + +;; PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings +;; can be used: + +;; * Matches any string of characters, except path separators (/) +;; ** Matches any string of characters +;; ? Matches any single character +;; [name] Matches any single character in name +;; [^name] Matches any single character not in name +;; {s1,s2,s3} Matches any of the strings given (separated by commas) +;; {min..max} Matches any number between min and max + + +;; This library is a port from editorconfig-core-py library. +;; https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/fnmatch.py + +;;; Code: + +(require 'cl-lib) + +(defvar editorconfig-fnmatch--cache-hashtable + nil + "Cache of shell pattern and its translation.") +;; Clear cache on file reload +(setq editorconfig-fnmatch--cache-hashtable + (make-hash-table :test 'equal)) + + +(defconst editorconfig-fnmatch--left-brace-regexp + "\\(^\\|[^\\]\\){" + "Regular expression for left brace ({).") + +(defconst editorconfig-fnmatch--right-brace-regexp + "\\(^\\|[^\\]\\)}" + "Regular expression for right brace (}).") + + +(defconst editorconfig-fnmatch--numeric-range-regexp + "\\([+-]?[0-9]+\\)\\.\\.\\([+-]?[0-9]+\\)" + "Regular expression for numeric range (like {-3..+3}).") + +(defun editorconfig-fnmatch--match-num (regexp string) + "Return how many times REGEXP is found in STRING." + (let ((num 0)) + ;; START arg does not work as expected in this case + (while (string-match regexp string) + (setq num (1+ num) + string (substring string (match-end 0)))) + num)) + +;;;###autoload +(defun editorconfig-fnmatch-p (string pattern) + "Test whether STRING match PATTERN. + +Matching ignores case if `case-fold-search' is non-nil. + +PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can +be used: + +* Matches any string of characters, except path separators (/) +** Matches any string of characters +? Matches any single character +[name] Matches any single character in name +[^name] Matches any single character not in name +{s1,s2,s3} Matches any of the strings given (separated by commas) +{min..max} Matches any number between min and max" + (string-match (editorconfig-fnmatch-translate pattern) + string)) + +;;(editorconfig-fnmatch-translate "{a,{-3..3}}.js") +;;(editorconfig-fnmatch-p "1.js" "{a,{-3..3}}.js") + +(defun editorconfig-fnmatch-translate (pattern) + "Translate a shell PATTERN to a regular expression. + +Translation result will be cached, so same translation will not be done twice." + (let ((cached (gethash pattern + editorconfig-fnmatch--cache-hashtable))) + (or cached + (puthash pattern + (editorconfig-fnmatch--do-translate pattern) + editorconfig-fnmatch--cache-hashtable)))) + + +(defun editorconfig-fnmatch--do-translate (pattern &optional nested) + "Translate a shell PATTERN to a regular expression. + +Set NESTED to t when this function is called from itself. + +This function is called from `editorconfig-fnmatch-translate', when no cached +translation is found for PATTERN." + (let ((index 0) + (length (length pattern)) + (brace-level 0) + (in-brackets nil) + ;; List of strings of resulting regexp + (result ()) + (is-escaped nil) + (matching-braces (= (editorconfig-fnmatch--match-num + editorconfig-fnmatch--left-brace-regexp + pattern) + (editorconfig-fnmatch--match-num + editorconfig-fnmatch--right-brace-regexp + pattern))) + + current-char + pos + has-slash + has-comma + num-range) + + (while (< index length) + (if (and (not is-escaped) + (string-match "[^]\\*?[{},/\\-]+" + ;;(string-match "[^]\\*?[{},/\\-]+" "?.a") + pattern + index) + (eq index (match-beginning 0))) + (setq result `(,@result ,(regexp-quote (match-string 0 pattern))) + index (match-end 0) + is-escaped nil) + + (setq current-char (aref pattern index) + index (1+ index)) + + (cl-case current-char + (?* + (setq pos index) + (if (and (< pos length) + (= (aref pattern pos) ?*)) + (setq result `(,@result ".*")) + (setq result `(,@result "[^/]*")))) + + (?? + (setq result `(,@result "[^/]"))) + + (?\[ + (if in-brackets + (setq result `(,@result "\\[")) + (if (= (aref pattern index) ?/) + ;; Slash after an half-open bracket + (setq result `(,@result "\\[/") + index (+ index 1)) + (setq pos index + has-slash nil) + (while (and (< pos length) + (not (= (aref pattern pos) ?\])) + (not has-slash)) + (if (and (= (aref pattern pos) ?/) + (not (= (aref pattern (- pos 1)) ?\\))) + (setq has-slash t) + (setq pos (1+ pos)))) + (if has-slash + (setq result `(,@result ,(concat "\\[" + (substring pattern + index + (1+ pos)) + "\\]")) + index (+ pos 2)) + (if (and (< index length) + (memq (aref pattern index) + '(?! ?^))) + (setq index (1+ index) + result `(,@result "[^")) + (setq result `(,@result "["))) + (setq in-brackets t))))) + + (?- + (if in-brackets + (setq result `(,@result "-")) + (setq result `(,@result "\\-")))) + + (?\] + (setq result `(,@result "]") + in-brackets nil)) + + (?{ + (setq pos index + has-comma nil) + (while (and (or (and (< pos length) + (not (= (aref pattern pos) + ?}))) + is-escaped) + (not has-comma)) + (if (and (eq (aref pattern pos) + ?,) + (not is-escaped)) + (setq has-comma t) + (setq is-escaped (and (eq (aref pattern pos) + ?\\) + (not is-escaped)) + pos (1+ pos)))) + (if (and (not has-comma) + (< pos length)) + (let ((pattern-sub (substring pattern index pos))) + (setq num-range (string-match editorconfig-fnmatch--numeric-range-regexp + pattern-sub)) + (if num-range + (let ((number-start (string-to-number (match-string 1 + pattern-sub))) + (number-end (string-to-number (match-string 2 + pattern-sub)))) + (setq result `(,@result ,(concat "\\(?:" + (mapconcat 'number-to-string + (cl-loop for i from number-start to number-end + collect i) + "\\|") + "\\)")))) + (let ((inner (editorconfig-fnmatch--do-translate pattern-sub t))) + (setq result `(,@result ,(format "{%s}" + inner))))) + (setq index (1+ pos))) + (if matching-braces + (setq result `(,@result "\\(?:") + brace-level (1+ brace-level)) + (setq result `(,@result "{"))))) + + (?, + (if (and (> brace-level 0) + (not is-escaped)) + (setq result `(,@result "\\|")) + (setq result `(,@result "\\,")))) + + (?} + (if (and (> brace-level 0) + (not is-escaped)) + (setq result `(,@result "\\)") + brace-level (- brace-level 1)) + (setq result `(,@result "}")))) + + (?/ + (if (and (<= (+ index 3) + (length pattern)) + (string= (substring pattern index (+ index 3)) + "**/")) + (setq result `(,@result "\\(?:/\\|/.*/\\)") + index (+ index 3)) + (setq result `(,@result "/")))) + + (t + (unless (= current-char + ?\\) + (setq result `(,@result ,(regexp-quote (char-to-string current-char))))))) + + (if (= current-char ?\\) + (progn (when is-escaped + (setq result `(,@result "\\\\"))) + (setq is-escaped (not is-escaped))) + (setq is-escaped nil)))) + (unless nested + (setq result `("^" ,@result "\\'"))) + (apply 'concat result))) + +(provide 'editorconfig-fnmatch) + +;;; editorconfig-fnmatch.el ends here diff --git a/elpa/editorconfig-0.8.2/editorconfig-pkg.el b/elpa/editorconfig-0.8.2/editorconfig-pkg.el @@ -0,0 +1,2 @@ +;; Generated package description from editorconfig.el -*- no-byte-compile: t -*- +(define-package "editorconfig" "0.8.2" "EditorConfig Emacs Plugin" '((cl-lib "0.5") (nadvice "0.3") (emacs "24")) :authors '(("EditorConfig Team" . "editorconfig@googlegroups.com")) :maintainer '("EditorConfig Team" . "editorconfig@googlegroups.com") :url "https://github.com/editorconfig/editorconfig-emacs#readme") diff --git a/elpa/editorconfig-0.8.2/editorconfig.el b/elpa/editorconfig-0.8.2/editorconfig.el @@ -0,0 +1,992 @@ +;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- + +;; Copyright (C) 2011-2021 EditorConfig Team + +;; Author: EditorConfig Team <editorconfig@googlegroups.com> +;; Version: 0.8.2 +;; URL: https://github.com/editorconfig/editorconfig-emacs#readme +;; Package-Requires: ((cl-lib "0.5") (nadvice "0.3") (emacs "24")) + +;; See +;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors +;; or the CONTRIBUTORS file for the list of contributors. + +;; This file is part of EditorConfig Emacs Plugin. + +;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at your +;; option) any later version. + +;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +;; Public License for more details. + +;; You should have received a copy of the GNU General Public License along with +;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; EditorConfig helps developers define and maintain consistent +;; coding styles between different editors and IDEs. + +;; The EditorConfig project consists of a file format for defining +;; coding styles and a collection of text editor plugins that enable +;; editors to read the file format and adhere to defined styles. +;; EditorConfig files are easily readable and they work nicely with +;; version control systems. + +;;; Code: +(require 'cl-lib) +(require 'nadvice) +(eval-when-compile + (require 'rx) + (defvar tex-indent-basic) + (defvar tex-indent-item) + (defvar tex-indent-arg) + (defvar evil-shift-width)) + +(declare-function editorconfig-core-get-properties-hash + "editorconfig-core" + (&optional file confname confversion)) + +(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) + +(defcustom editorconfig-mode-lighter " EditorConfig" + "Command `editorconfig-mode' lighter string." + :type 'string + :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. + +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) + +(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) + (awk-mode c-basic-offset) + (bpftrace-mode c-basic-offset) + (c++-mode c-basic-offset) + (c-mode c-basic-offset) + (cmake-mode cmake-tab-width) + (coffee-mode coffee-tab-width) + (cperl-mode cperl-indent-level) + (crystal-mode crystal-indent-level) + (csharp-mode c-basic-offset) + (css-mode css-indent-offset) + (d-mode c-basic-offset) + (emacs-lisp-mode lisp-indent-offset) + (enh-ruby-mode enh-ruby-indent-level) + (erlang-mode erlang-indent-level) + (ess-mode ess-indent-offset) + (f90-mode f90-associate-indent + f90-continuation-indent + f90-critical-indent + f90-do-indent + f90-if-indent + f90-program-indent + f90-type-indent) + (feature-mode feature-indent-offset + feature-indent-level) + (fsharp-mode fsharp-continuation-offset + fsharp-indent-level + fsharp-indent-offset) + (groovy-mode groovy-indent-offset) + (haskell-mode haskell-indent-spaces + haskell-indent-offset + haskell-indentation-layout-offset + haskell-indentation-left-offset + haskell-indentation-starter-offset + haskell-indentation-where-post-offset + haskell-indentation-where-pre-offset + shm-indent-spaces) + (haxor-mode haxor-tab-width) + (idl-mode c-basic-offset) + (jade-mode jade-tab-width) + (java-mode c-basic-offset) + (js-mode js-indent-level) + (js-jsx-mode js-indent-level sgml-basic-offset) + (js2-mode js2-basic-offset) + (js2-jsx-mode js2-basic-offset sgml-basic-offset) + (js3-mode js3-indent-level) + (json-mode js-indent-level) + (julia-mode julia-indent-offset) + (kotlin-mode kotlin-tab-width) + (latex-mode . editorconfig-set-indentation-latex-mode) + (lisp-mode lisp-indent-offset) + (livescript-mode livescript-tab-width) + (lua-mode lua-indent-level) + (matlab-mode matlab-indent-level) + (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) + (pike-mode c-basic-offset) + (ps-mode ps-mode-tab) + (pug-mode pug-tab-width) + (puppet-mode puppet-indent-level) + (python-mode . editorconfig-set-indentation-python-mode) + (rjsx-mode js-indent-level sgml-basic-offset) + (ruby-mode ruby-indent-level) + (rust-mode rust-indent-offset) + (rustic-mode rustic-indent-offset) + (scala-mode scala-indent:step) + (scss-mode css-indent-offset) + (sgml-mode sgml-basic-offset) + (sh-mode sh-basic-offset sh-indentation) + (slim-mode slim-indent-offset) + (sml-mode sml-indent-level) + (tcl-mode tcl-indent-level + tcl-continued-indent-level) + (terra-mode terra-indent-level) + (typescript-mode typescript-indent-level) + (verilog-mode verilog-indent-level + verilog-indent-level-behavioral + verilog-indent-level-declaration + verilog-indent-level-module + verilog-cexp-indent + verilog-case-indent) + (web-mode (web-mode-indent-style . (lambda (size) 2)) + web-mode-attr-indent-offset + web-mode-attr-value-indent-offset + web-mode-code-indent-offset + web-mode-css-indent-offset + web-mode-markup-indent-offset + web-mode-sql-indent-offset + web-mode-block-padding + web-mode-script-padding + web-mode-style-padding) + (yaml-mode yaml-indent-offset)) + "Alist of indentation setting methods by modes. + +Each element looks like (MODE . FUNCTION) or (MODE . INDENT-SPEC-LIST). + +If FUNCTION is provided, it will be called when setting the +indentation. The indent size will be passed. + +If INDENT-SPEC-LIST is provided, each element of it must have one of the +following forms: + + 1. VARIABLE + It means (VARIABLE . 1). + + 2. (VARIABLE . SPEC) + Setting VARIABLE according to the type of SPEC: + + - Integer + The value is (* SPEC INDENT-SIZE); + + - Function + The value is (funcall SPEC INDENT-SIZE); + + - Any other type. + The value is SPEC. + +NOTE: Only the **buffer local** value of VARIABLE will be set." + :type '(alist :key-type symbol :value-type sexp) + :risky t + :group 'editorconfig) + +(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 (file-truename (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.") + +(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 (editorconfig--provided-mode-derived-p majormode 'special-mode) + (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-python-mode (size) + "Set `python-mode' indent size to SIZE." + (set (make-local-variable (if (or (> emacs-major-version 24) + (and (= emacs-major-version 24) + (>= emacs-minor-version 3))) + 'python-indent-offset + 'python-indent)) + size) + ;; For https://launchpad.net/python-mode + (when (boundp 'py-indent-offset) + (set (make-local-variable 'py-indent-offset) size))) + +(defun editorconfig-set-indentation-latex-mode (size) + "Set `latex-mode' indent size to SIZE." + (set (make-local-variable 'tex-indent-basic) size) + (set (make-local-variable 'tex-indent-item) size) + (set (make-local-variable 'tex-indent-arg) (* 2 size)) + ;; For AUCTeX + (when (boundp 'TeX-brace-indent-level) + (set (make-local-variable 'TeX-brace-indent-level) size)) + (when (boundp 'LaTeX-indent-level) + (set (make-local-variable 'LaTeX-indent-level) size)) + (when (boundp 'LaTeX-item-indent) + (set (make-local-variable 'LaTeX-item-indent) (- size)))) + +(defun editorconfig--should-set (size symbol) + "Determines if editorconfig should set SYMBOL using SIZE." + (if (eq symbol 'lisp-indent-offset) + (cond + ((eql nil editorconfig-lisp-use-default-indent) + t) + ((eql t editorconfig-lisp-use-default-indent) + nil) + ((numberp editorconfig-lisp-use-default-indent) + (not (eql size editorconfig-lisp-use-default-indent))) + (t t)) + t)) + +(defun editorconfig-set-indentation (style &optional size tab_width) + "Set indentation type from STYLE, SIZE and TAB_WIDTH." + (if (editorconfig-string-integer-p size) + (setq size (string-to-number size)) + (when (not (equal size "tab")) (setq size nil))) + (cond (tab_width + (setq tab-width (string-to-number tab_width))) + ((numberp size) + (setq tab-width size))) + (when (equal size "tab") + (setq size tab-width)) + (cond ((equal style "space") + (setq indent-tabs-mode nil)) + ((equal style "tab") + (setq indent-tabs-mode t))) + (when size + (when (featurep 'evil) + (set (make-local-variable 'evil-shift-width) size)) + (let ((parent major-mode) + entry) + ;; Find the closet parent mode of `major-mode' in + ;; `editorconfig-indentation-alist'. + (while (and (not (setq entry (assoc parent editorconfig-indentation-alist))) + (setq parent (get parent 'derived-mode-parent)))) + (when entry + (let ((fn-or-list (cdr entry))) + (cond ((functionp fn-or-list) (funcall fn-or-list size)) + ((listp fn-or-list) + (dolist (elem fn-or-list) + (cond ((and (symbolp elem) + (editorconfig--should-set size elem)) + (set (make-local-variable elem) size)) + ((and (consp elem) + (editorconfig--should-set size (car elem))) + (let ((spec (cdr elem))) + (set (make-local-variable (car elem)) + (cond ((functionp spec) (funcall spec size)) + ((integerp spec) (* spec size)) + (t spec)))))))))))))) + +(defvar editorconfig--apply-coding-system-currently nil + "Used internally.") +(make-variable-buffer-local 'editorconfig--apply-coding-system-currently) +(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." + (cond + ((equal final-newline "true") + ;; keep prefs around how/when the nl is added, if set - otherwise add on save + (set (make-local-variable 'require-final-newline) (or require-final-newline t)) + (set (make-local-variable 'mode-require-final-newline) (or mode-require-final-newline t))) + ((equal final-newline "false") + ;; FIXME: Add functionality for actually REMOVING any trailing newlines here! + ;; (rather than just making sure we don't automagically ADD a new one) + (set (make-local-variable 'require-final-newline) nil) + (set (make-local-variable 'mode-require-final-newline) nil)))) + +(defun editorconfig-set-trailing-ws (trim-trailing-ws) + "Set up trimming of trailing whitespace at end of lines by TRIM-TRAILING-WS." + (make-local-variable 'write-file-functions) ;; just current buffer + (when (and (equal trim-trailing-ws "true") + (not buffer-read-only)) + ;; when true we push delete-trailing-whitespace (emacs > 21) + ;; to write-file-functions + (if editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 1) + (add-to-list + 'write-file-functions + 'delete-trailing-whitespace))) + (when (or (equal trim-trailing-ws "false") + buffer-read-only) + ;; when false we remove every delete-trailing-whitespace + ;; from write-file-functions + (when editorconfig-trim-whitespaces-mode + (funcall editorconfig-trim-whitespaces-mode 0)) + (setq + write-file-functions + (delete + 'delete-trailing-whitespace + write-file-functions)))) + +(defun editorconfig-set-line-length (length) + "Set the max line length (`fill-column') to LENGTH." + (when (and (editorconfig-string-integer-p length) + (> (string-to-number length) 0)) + (setq fill-column (string-to-number length)))) + +;; Emacs<26 does not have provided-mode-derived-p +(defun editorconfig--provided-mode-derived-p (mode &rest modes) + "Non-nil if MODE is derived from one of MODES. +Uses the `derived-mode-parent' property of the symbol to trace backwards. +If you just want to check `major-mode', use `derived-mode-p'." + (if (fboundp 'provided-mode-derived-p) + (apply 'provided-mode-derived-p mode modes) + (while (and (not (memq mode modes)) + (setq mode (get mode 'derived-mode-parent)))) + mode)) + + +(defun editorconfig--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) + "Create properties hash table from PROPS-STRING." + (let (props-list properties) + (setq props-list (split-string props-string "\n") + properties (make-hash-table)) + (dolist (prop props-list properties) + (let ((key-val (split-string prop " *= *"))) + (when (> (length key-val) 1) + (let ((key (intern (car key-val))) + (val (mapconcat 'identity (cdr key-val) ""))) + (puthash key val properties))))))) + +(defun editorconfig-get-properties-from-exec (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 buffer-file-name))) + (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'ted 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))) + +;;;###autoload +(defun editorconfig-apply () + "Get and apply EditorConfig properties to current buffer. + +This function does not respect the values of `editorconfig-exclude-modes' and +`editorconfig-exclude-regexps' and always applies available properties. +Use `editorconfig-mode-apply' instead to make use of these variables." + (interactive) + (when buffer-file-name + (condition-case err + (progn + (let ((props (editorconfig-call-get-properties-function buffer-file-name))) + (condition-case err + (run-hook-with-args 'editorconfig-hack-properties-functions props) + (error + (display-warning '(editorconfig editorconfig-hack-properties-functions) + (format "Error while running editorconfig-hack-properties-functions, abort running hook: %S" + err) + :warning))) + (setq editorconfig-properties-hash props) + (editorconfig-set-local-variables props) + (editorconfig-set-coding-system-revert + (gethash 'end_of_line props) + (gethash 'charset props)) + (condition-case err + (run-hook-with-args 'editorconfig-after-apply-functions props) + (error + (display-warning '(editorconfig editorconfig-after-apply-functions) + (format "Error while running editorconfig-after-apply-functions, abort running hook: %S" + err) + :warning))))) + (error + (display-warning '(editorconfig editorconfig-apply) + (format "Error in editorconfig-apply, styles will not be applied: %S" err) + :error))))) + +(defun editorconfig-mode-apply () + "Get and apply EditorConfig properties to current buffer. + +This function does nothing when the major mode is listed in +`editorconfig-exclude-modes', or variable `buffer-file-name' matches +any of regexps in `editorconfig-exclude-regexps'." + (interactive) + (when (and major-mode + (not (editorconfig--disabled-for-majormode major-mode)) + buffer-file-name + (not (editorconfig--disabled-for-filename buffer-file-name))) + (editorconfig-apply))) + +(defun editorconfig-major-mode-hook () + "Function to run when `major-mode' has been changed. + +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 (boundp 'editorconfig-mode) + 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--cons-filename-codingsystem nil + "Used interally. + +`editorconfig--advice-find-file-noselect' will set this variable, and +`editorconfig--advice-insert-file-contents' will use this variable to set +`coding-system-for-read' value.") + +(defun editorconfig--advice-insert-file-contents (f filename &rest args) + "Set `coding-system-for-read'. + +This function should be added as an advice function to `insert-file-contents'. +F is that function, and FILENAME and ARGS are arguments passed to F." + ;; This function uses `editorconfig--cons-filename-codingsystem' to decide what coding-system + ;; should be used, which will be set by `editorconfig--advice-find-file-noselect'. + (display-warning '(editorconfig editorconfig--advice-insert-file-contents) + (format "editorconfig--advice-insert-file-contents: filename: %S args: %S codingsystem: %S bufferfilename: %S" + filename args + editorconfig--cons-filename-codingsystem + buffer-file-name) + :debug) + (if (and (stringp filename) + (stringp (car editorconfig--cons-filename-codingsystem)) + (string= (expand-file-name filename) + (car editorconfig--cons-filename-codingsystem)) + (cdr editorconfig--cons-filename-codingsystem) + (not (eq (cdr editorconfig--cons-filename-codingsystem) + 'undecided))) + (let ( + (coding-system-for-read (cdr editorconfig--cons-filename-codingsystem)) + ;; (coding-system-for-read 'undecided) + ) + (apply f filename args)) + (apply f filename args))) + +(defun editorconfig--advice-find-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)))) + (error + (display-warning '(editorconfig editorconfig--advice-find-file-noselect) + (format "Failed to get properties, styles will not be applied: %S" + err) + :warning))) + + (let ((editorconfig--cons-filename-codingsystem (cons (expand-file-name filename) + coding-system))) + (setq ret (apply f filename args))) + + (condition-case err + (with-current-buffer ret + (when (and props + ;; filename has already been checked + (not (editorconfig--disabled-for-majormode major-mode))) + (when (and (file-remote-p filename) + (not (local-variable-p 'buffer-file-coding-system)) + (not (file-exists-p filename)) + coding-system + (not (eq coding-system + 'undecided))) + ;; When file path indicates it is a remote file and it actually + ;; does not exists, `buffer-file-coding-system' will not be set. + ;; (Seems `insert-file-contents' will not be called) + ;; For that case, explicitly set this value so that saving will be done + ;; with expected coding system. + (set-buffer-file-coding-system coding-system)) + + ;; NOTE: When using editorconfig-2-mode, hack-properties-functions cannot affect coding-system value, + ;; 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)) + +(defvar editorconfig--enable-20210221-testing nil + "Enable testing version of `editorconfig-mode'. + +Currently this mode is not well tested yet and can cause unexpected behaviors +like killing Emacs process or not able to visit files at all.") + +;;;###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 + (if editorconfig--enable-20210221-testing + (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)))) + + ;; editorconfig--enable-20210221-testing is disabled + ;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for why + ;; not `after-change-major-mode-hook' + (dolist (hook '(change-major-mode-after-body-hook + read-only-mode-hook + ;; Some modes call `kill-all-local-variables' in their init + ;; code, which clears some values set by editorconfig. + ;; For those modes, editorconfig-apply need to be called + ;; explicitly through their hooks. + rpm-spec-mode-hook + )) + (if editorconfig-mode + (add-hook hook 'editorconfig-mode-apply) + (remove-hook hook 'editorconfig-mode-apply))))) + + +;; Tools +;; Some useful commands for users, not required for EditorConfig to work + +;;;###autoload +(defun editorconfig-find-current-editorconfig () + "Find the closest .editorconfig file for current file." + (interactive) + (eval-and-compile (require 'editorconfig-core)) + (let ((file (editorconfig-core-get-nearest-editorconfig + default-directory))) + (when file + (find-file file)))) + +;;;###autoload +(defun editorconfig-display-current-properties () + "Display EditorConfig properties extracted for current buffer." + (interactive) + (if editorconfig-properties-hash + (let ( + (buf (get-buffer-create "*EditorConfig Properties*")) + (file buffer-file-name) + (props editorconfig-properties-hash)) + (with-current-buffer buf + (erase-buffer) + (insert (format "# EditorConfig for %s\n" file)) + (maphash (lambda (k v) + (insert (format "%S = %s\n" k v))) + props)) + (display-buffer buf)) + (message "Properties are not applied to current buffer yet.") + nil)) +;;;###autoload +(defalias 'describe-editorconfig-properties + 'editorconfig-display-current-properties) + +;;;###autoload +(defun editorconfig-format-buffer() + "Format buffer according to .editorconfig indent_style and indent_width." + (interactive) + (if (string= (gethash 'indent_style editorconfig-properties-hash) "tab") + (tabify (point-min) (point-max))) + (if (string= (gethash 'indent_style editorconfig-properties-hash) "space") + (untabify (point-min) (point-max))) + (indent-region (point-min) (point-max))) + + + +;; (defconst editorconfig--version +;; (eval-when-compile +;; (require 'lisp-mnt) +;; (declare-function lm-version "lisp-mnt" nil) +;; (lm-version)) +;; "EditorConfig version.") + +(declare-function find-library-name "find-func" (library)) +(declare-function lm-version "lisp-mnt" nil) + +;;;###autoload +(defun editorconfig-version (&optional show-version) + "Get EditorConfig version as string. + +If called interactively or if SHOW-VERSION is non-nil, show the +version in the echo area and the messages buffer." + (interactive (list t)) + (let* ((version + (with-temp-buffer + (require 'find-func) + (insert-file-contents (find-library-name "editorconfig")) + (require 'lisp-mnt) + (lm-version))) + (pkg + (and (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: diff --git a/elpa/editorconfig-0.8.2/editorconfig.info b/elpa/editorconfig-0.8.2/editorconfig.info @@ -0,0 +1,348 @@ +This is editorconfig.info, produced by makeinfo version 6.5 from +editorconfig.texi. + +INFO-DIR-SECTION Emacs +START-INFO-DIR-ENTRY +* EditorConfig: (editorconfig). EditorConfig Emacs Plugin. +END-INFO-DIR-ENTRY + + +File: editorconfig.info, Node: Top, Next: Getting Started, Up: (dir) + +1 EditorConfig Emacs Plugin +*************************** + +This is an EditorConfig (https://editorconfig.org) plugin for Emacs +(https://www.gnu.org/software/emacs/). + +* Menu: + +* Getting Started:: +* Supported properties:: +* Customize:: +* Troubleshooting:: +* Submitting Bugs and Feature Requests:: +* License:: + + +File: editorconfig.info, Node: Getting Started, Next: Supported properties, Prev: Top, Up: Top + +1.1 Getting Started +=================== + +* Menu: + +* packageel:: +* use-package:: +* Manual installation:: + + +File: editorconfig.info, Node: packageel, Next: use-package, Up: Getting Started + +1.1.1 package.el +---------------- + +This package is available from MELPA (https://melpa.org/#/editorconfig), +MELPA Stable (https://stable.melpa.org/#/editorconfig) and NonGNU ELPA +(http://elpa.nongnu.org/nongnu/editorconfig.html). Install from these +repositories and enable global minor-mode 'editorconfig-mode': + +(editorconfig-mode 1) + + Normally, enabling '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. + + +File: editorconfig.info, Node: use-package, Next: Manual installation, Prev: packageel, Up: Getting Started + +1.1.2 use-package +----------------- + +If you use *use-package* (https://www.emacswiki.org/emacs/UsePackage), +add the following to your 'init.el' file: + +(use-package editorconfig + :ensure t + :config + (editorconfig-mode 1)) + + +File: editorconfig.info, Node: Manual installation, Prev: use-package, Up: Getting Started + +1.1.3 Manual installation +------------------------- + +Copy all '.el' files in this repository to '~/.emacs.d/lisp' and add the +following: + +(add-to-list 'load-path "~/.emacs.d/lisp") +(require 'editorconfig) +(editorconfig-mode 1) + + +File: editorconfig.info, Node: Supported properties, Next: Customize, Prev: Getting Started, Up: Top + +1.2 Supported properties +======================== + +Current Emacs plugin coverage for EditorConfig's properties +(https://editorconfig.org/#supported-properties): + + * 'indent_style' + * 'indent_size' + * 'tab_width' + * 'end_of_line' + * 'charset' + * 'trim_trailing_whitespace' + * 'insert_final_newline = true' is supported + * 'insert_final_newline = false' is not enforced (as in trailing + newlines actually being removed automagically), we just + buffer-locally override any preferences that would auto-add them to + files '.editorconfig' marks as trailing-newline-free + * 'max_line_length' + * 'file_type_ext' (Experimental) (See below) + * 'file_type_emacs' (Experimental) (See below) + * 'root' (only used by EditorConfig core) + + Not yet covered properties marked with over-strike - pull requests +implementing missing features warmly welcomed! Typically, you will want +to tie these to native functionality, or the configuration of existing +packages handling the feature. + + As several packages have their own handling of, say, indentation, we +might not yet cover some mode you use, but we try to add the ones that +show up on our radar. + +* Menu: + +* File Type file_type_ext file_type_emacs:: + + +File: editorconfig.info, Node: File Type file_type_ext file_type_emacs, Up: Supported properties + +1.2.1 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 editorconfig-custom-majormode +(https://github.com/10sr/editorconfig-custom-majormode-el). + + +File: editorconfig.info, Node: Customize, Next: Troubleshooting, Prev: Supported properties, Up: Top + +1.3 Customize +============= + +'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:: + + +File: editorconfig.info, Node: editorconfig-trim-whitespaces-mode, Next: editorconfig-after-apply-functions, Up: Customize + +1.3.1 '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 +'trim_trailing_whitespace' property in '.editorconfig'. Otherwise, use +Emacs built-in 'delete-trailing-whitespace' function. + + One possible value is 'ws-butler-mode' +(https://github.com/lewang/ws-butler), with which only lines touched get +trimmed. To use it, add following to your init.el: + +(setq editorconfig-trim-whitespaces-mode + 'ws-butler-mode) + + +File: editorconfig.info, Node: editorconfig-after-apply-functions, Next: editorconfig-hack-properties-functions, Prev: editorconfig-trim-whitespaces-mode, Up: Customize + +1.3.2 'editorconfig-after-apply-functions' +------------------------------------------ + +(Formerly '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, 'web-mode' has several variables for indentation offset +size and EditorConfig sets them at once by 'indent_size'. You can stop +indenting only blocks of 'web-mode' by adding following to your init.el: + +(add-hook 'editorconfig-after-apply-functions + (lambda (props) (setq web-mode-block-padding 0))) + + +File: editorconfig.info, Node: editorconfig-hack-properties-functions, Prev: editorconfig-after-apply-functions, Up: Customize + +1.3.3 '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 +'major-mode' is 'makefile-mode': + +(add-hook 'editorconfig-hack-properties-functions + '(lambda (props) + (when (derived-mode-p 'makefile-mode) + (puthash 'indent_style "tab" props)))) + + +File: editorconfig.info, Node: Troubleshooting, Next: Submitting Bugs and Feature Requests, Prev: Customize, Up: Top + +1.4 Troubleshooting +=================== + +Enabling 'editorconfig-mode' should be enough for normal cases. + + When EditorConfig properties are not effective for unknown reason, we +recommend first trying '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!:: + + +File: editorconfig.info, Node: Indentation for new major-modes, Next: Not work at all for FOO-mode!, Up: Troubleshooting + +1.4.1 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 '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 'editorconfig-indentation-alist'. + + +File: editorconfig.info, Node: Not work at all for FOO-mode!, Prev: Indentation for new major-modes, Up: Troubleshooting + +1.4.2 Not work at all for FOO-mode! +----------------------------------- + +Most cases properties are loaded just after visiting files when +'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 'editorconfig-apply'. + + Typically it will occur when the major-mode is not defined using +'define-derived-mode' ('rpm-spec-mode' is an example for this). Please +feel free to submit issues if you find such modes! + + +File: editorconfig.info, Node: Submitting Bugs and Feature Requests, Next: License, Prev: Troubleshooting, Up: Top + +1.5 Submitting Bugs and Feature Requests +======================================== + +Bugs, feature requests, and other issues should be submitted to the +issue tracker: https://github.com/editorconfig/editorconfig-emacs/issues + +* Menu: + +* Development:: + + +File: editorconfig.info, Node: Development, Up: Submitting Bugs and Feature Requests + +1.5.1 Development +----------------- + +Make and CMake (https://cmake.org) must be installed to run the tests +locally: + +$ make check + + To start a new Emacs process with current '*.el' and without loading +user init file, run: + +$ make sandbox + + +File: editorconfig.info, Node: License, Prev: Submitting Bugs and Feature Requests, Up: Top + +1.6 License +=========== + +EditorConfig Emacs Plugin is free software: you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. + + + +Tag Table: +Node: Top208 +Ref: #editorconfig-emacs-plugin340 +Node: Getting Started590 +Ref: #getting-started733 +Node: packageel797 +Ref: #package.el919 +Node: use-package1483 +Ref: #use-package1635 +Node: Manual installation1823 +Ref: #manual-installation1973 +Node: Supported properties2148 +Ref: #supported-properties2307 +Node: File Type file_type_ext file_type_emacs3481 +Ref: #file-type-file_type_ext-file_type_emacs3682 +Node: Customize3941 +Ref: #customize4078 +Node: editorconfig-trim-whitespaces-mode4397 +Ref: #editorconfig-trim-whitespaces-mode4613 +Node: editorconfig-after-apply-functions5104 +Ref: #editorconfig-after-apply-functions5367 +Node: editorconfig-hack-properties-functions5853 +Ref: #editorconfig-hack-properties-functions6081 +Node: Troubleshooting6691 +Ref: #troubleshooting6856 +Node: Indentation for new major-modes7396 +Ref: #indentation-for-new-major-modes7600 +Node: Not work at all for FOO-mode!8116 +Ref: #not-work-at-all-for-foo-mode8316 +Node: Submitting Bugs and Feature Requests8738 +Ref: #submitting-bugs-and-feature-requests8943 +Node: Development9111 +Ref: #development9238 +Node: License9442 +Ref: #license9565 + +End Tag Table diff --git a/init.el b/init.el @@ -270,6 +270,7 @@ '(dired-dwim-target 'dired-dwim-target-next) '(dired-kill-when-opening-new-dired-buffer t) '(ediff-split-window-function 'split-window-horizontally) + '(editorconfig-mode t) '(elfeed-tube-auto-save-p t) '(fido-mode t) '(fido-vertical-mode t) @@ -304,7 +305,7 @@ ("melpa-stable" . "https://stable.melpa.org/packages/") ("melpa" . "https://melpa.org/packages/"))) '(package-selected-packages - '(elfeed-tube-mpv elfeed-tube restclient-jq graphviz-dot-mode consult-eglot jq-mode multiple-cursors ob-restclient restclient vterm deadgrep helpful pdf-tools paredit-menu paredit corfu sly eglot aggressive-indent project nov nhexl-mode elfeed magit yaml-mode json-mode lua-mode go-mode geiser-guile geiser org-roam org-contrib org ace-window expand-region consult marginalia uuidgen request diminish which-key)) + '(editorconfig forge elfeed-tube-mpv elfeed-tube cider restclient-jq graphviz-dot-mode consult-eglot jq-mode multiple-cursors ob-restclient restclient vterm deadgrep helpful pdf-tools paredit-menu paredit corfu sly eglot aggressive-indent project nov nhexl-mode elfeed magit yaml-mode json-mode lua-mode go-mode geiser-guile geiser org-roam org-contrib org ace-window expand-region consult marginalia uuidgen request diminish which-key)) '(pcomplete-ignore-case t t) '(pixel-scroll-precision-mode t) '(read-buffer-completion-ignore-case t) @@ -363,5 +364,6 @@ (diminish 'which-key-mode) (diminish 'aggressive-indent-mode) +(diminish 'editorconfig-mode) (server-start)