pax_global_header00006660000000000000000000000064141054664620014522gustar00rootroot0000000000000052 comment=375418d1d63f6ec780876593181b6d39054919da editorconfig-emacs-0.8.2/000077500000000000000000000000001410546646200152735ustar00rootroot00000000000000editorconfig-emacs-0.8.2/.editorconfig000066400000000000000000000005231410546646200177500ustar00rootroot00000000000000root = 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 editorconfig-emacs-0.8.2/.github/000077500000000000000000000000001410546646200166335ustar00rootroot00000000000000editorconfig-emacs-0.8.2/.github/workflows/000077500000000000000000000000001410546646200206705ustar00rootroot00000000000000editorconfig-emacs-0.8.2/.github/workflows/build.yaml000066400000000000000000000014331410546646200226540ustar00rootroot00000000000000--- 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 editorconfig-emacs-0.8.2/.gitignore000066400000000000000000000000351410546646200172610ustar00rootroot00000000000000*.elc *~ \#* .\#* *.autosave editorconfig-emacs-0.8.2/.gitmodules000066400000000000000000000004051410546646200174470ustar00rootroot00000000000000[submodule "editorconfig-core-test"] path = core-test url = https://github.com/editorconfig/editorconfig-core-test.git [submodule "editorconfig-plugin-tests"] path = ert-tests/plugin-tests url = https://github.com/editorconfig/editorconfig-plugin-tests.git editorconfig-emacs-0.8.2/CHANGELOG.md000066400000000000000000000246141410546646200171130ustar00rootroot00000000000000# 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 editorconfig-emacs-0.8.2/CONTRIBUTORS000066400000000000000000000002731410546646200171550ustar00rootroot00000000000000Contributors 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 editorconfig-emacs-0.8.2/LICENSE000066400000000000000000001045171410546646200163100ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. 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. Copyright (C) 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 . 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: Copyright (C) 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 . 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 . editorconfig-emacs-0.8.2/Makefile000066400000000000000000000033341410546646200167360ustar00rootroot00000000000000# -*- 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 "%") editorconfig-emacs-0.8.2/README.md000066400000000000000000000171471410546646200165640ustar00rootroot00000000000000![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 * `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. ### 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). ## 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]. ### `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 . [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 editorconfig-emacs-0.8.2/bin/000077500000000000000000000000001410546646200160435ustar00rootroot00000000000000editorconfig-emacs-0.8.2/bin/editorconfig-el000077500000000000000000000105021410546646200210410ustar00rootroot00000000000000#!/bin/sh :;#-*-Emacs-Lisp-*- :;test -n "$EMACS_BIN" || EMACS_BIN=emacs :;exec "$EMACS_BIN" -batch -Q --eval '(setq debug-on-error t)' -l "$0" -- "$@" ;; editorconfig-el --- EditorConfig Core executable in Emacs Lisp ;; Copyright (C) 2011-2020 EditorConfig Team ;; Author: EditorConfig Team ;; URL: https://github.com/editorconfig/editorconfig-emacs#readme ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors ;; or the CONTRIBUTORS file for the list of contributors. ;; This file is part of EditorConfig Emacs Plugin. ;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ;; Public License for more details. ;; You should have received a copy of the GNU General Public License along with ;; EditorConfig Emacs Plugin. If not, see . ;;; Commentary: ;; This executable is mainly for testing core feature, and not intended to be ;; used by users. ;;; Code: (when (getenv "EDITORCONFIG_CORE_LIBRARY_PATH") (setq load-path (append (split-string (getenv "EDITORCONFIG_CORE_LIBRARY_PATH") ":") load-path))) (require 'cl-lib) (require 'editorconfig) ; For `editorconfig-version' (require 'editorconfig-core) (defconst editorconfig-bin-help-message "Usage: editorconfig [-f ] [-b ] [-h|--help] [-v|--version] [ ...] Options: -f Specify config filename other than \".editorconfig\" -b Specify config format version -h|--help Print this help message -v|--version Display version information ... File paths to get EditorConfig properties" "Help message of EditorConfig executable.") (defun editorconfig-bin-parse-args (argv &optional confname version) "Parse arguments and return list. List returned will be looked like (FILES CONFNAME VERSION). If either -v, --version, -h or --help option apprears, exit emacs immediately with required output." (unless argv (message editorconfig-bin-help-message) (kill-emacs 0)) (cl-case (intern (car argv)) (-f (editorconfig-bin-parse-args (cddr argv) (cadr argv) version)) (-b (editorconfig-bin-parse-args (cddr argv) confname (cadr argv))) ((-h --help) (message editorconfig-bin-help-message) (kill-emacs 0)) ((-v --version) (princ (format "EditorConfig-EmacsLisp Version %s\n" (editorconfig-version))) (kill-emacs 0)) (otherwise (when (and argv (string-match-p "^-" (car argv))) (error "Invalid option: %s" (car argv))) (list argv confname version)) )) (defun main (argv) ;; TODO: Read file list from stdin if - is given as FILENAME (let ((parsed (editorconfig-bin-parse-args argv))) (cl-case (length (car parsed)) (0 nil) (1 (dolist (p (editorconfig-core-get-properties (caar parsed) (nth 1 parsed) (nth 2 parsed))) (princ (format "%s=%s\n" (car p) (cdr p))))) (otherwise (dolist (file (car parsed)) (princ (format "[%s]\n" file)) (dolist (p (editorconfig-core-get-properties file (nth 1 parsed) (nth 2 parsed))) (princ (format "%s=%s\n" (car p) (cdr p)))))))) 0) ;; car of command-line-args-left is "--" (kill-emacs (main (cdr command-line-args-left))) ;;; editorconfig-el ends here editorconfig-emacs-0.8.2/core-test/000077500000000000000000000000001410546646200172005ustar00rootroot00000000000000editorconfig-emacs-0.8.2/doc/000077500000000000000000000000001410546646200160405ustar00rootroot00000000000000editorconfig-emacs-0.8.2/doc/.gitignore000066400000000000000000000000071410546646200200250ustar00rootroot00000000000000*.body editorconfig-emacs-0.8.2/doc/editorconfig.texi000066400000000000000000000220601410546646200214070ustar00rootroot00000000000000@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 editorconfig-emacs-0.8.2/doc/header.txt000066400000000000000000000001611410546646200200270ustar00rootroot00000000000000@dircategory Emacs @direntry * EditorConfig: (editorconfig). EditorConfig Emacs Plugin. @end direntry @node Top editorconfig-emacs-0.8.2/editorconfig-conf-mode.el000066400000000000000000000062161410546646200221430ustar00rootroot00000000000000;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*- ;; Copyright (C) 2011-2021 EditorConfig Team ;; Author: EditorConfig Team ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors ;; or the CONTRIBUTORS file for the list of contributors. ;; This file is part of EditorConfig Emacs Plugin. ;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ;; Public License for more details. ;; You should have received a copy of the GNU General Public License along with ;; EditorConfig Emacs Plugin. If not, see . ;;; Commentary: ;; Major mode for editing .editorconfig files. ;;; Code: (require 'conf-mode) (defvar editorconfig-conf-mode-syntax-table (let ((table (make-syntax-table conf-unix-mode-syntax-table))) (modify-syntax-entry ?\; "<" table) table) "Syntax table in use in `editorconfig-conf-mode' buffers.") (defvar editorconfig-conf-mode-abbrev-table nil "Abbrev table in use in `editorconfig-conf-mode' buffers.") (define-abbrev-table 'editorconfig-conf-mode-abbrev-table ()) ;;;###autoload (define-derived-mode editorconfig-conf-mode conf-unix-mode "Conf[EditorConfig]" "Major mode for editing .editorconfig files." (set-variable 'indent-line-function 'indent-relative) (let ((key-property-list '("charset" "end_of_line" "file_type_emacs" "file_type_ext" "indent_size" "indent_style" "insert_final_newline" "max_line_length" "root" "tab_width" "trim_trailing_whitespace")) (key-value-list '("unset" "true" "false" "lf" "cr" "crlf" "space" "tab" "latin1" "utf-8" "utf-8-bom" "utf-16be" "utf-16le")) (font-lock-value '(("^[ \t]*\\[\\(.+?\\)\\]" 1 font-lock-type-face) ("^[ \t]*\\(.+?\\)[ \t]*[=:]" 1 font-lock-variable-name-face)))) ;; Highlight all key values (dolist (key-value key-value-list) (push `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value) 1 font-lock-constant-face) font-lock-value )) ;; Highlight all key properties (dolist (key-property key-property-list) (push `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property) 1 font-lock-builtin-face) font-lock-value )) (conf-mode-initialize "#" font-lock-value))) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode)) (provide 'editorconfig-conf-mode) ;;; editorconfig-conf-mode.el ends here editorconfig-emacs-0.8.2/editorconfig-core-handle.el000066400000000000000000000231161410546646200224530ustar00rootroot00000000000000;;; editorconfig-core-handle.el --- Handle Class for EditorConfig File -*- lexical-binding: t -*- ;; Copyright (C) 2011-2021 EditorConfig Team ;; Author: EditorConfig Team ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors ;; or the CONTRIBUTORS file for the list of contributors. ;; This file is part of EditorConfig Emacs Plugin. ;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ;; Public License for more details. ;; You should have received a copy of the GNU General Public License along with ;; EditorConfig Emacs Plugin. If not, see . ;;; Commentary: ;; Handle structures for EditorConfig config file. This library is used ;; internally from editorconfig-core.el . ;;; Code: (require 'cl-lib) (require 'editorconfig-fnmatch) (defvar editorconfig-core-handle--cache-hash (make-hash-table :test 'equal) "Hash of EditorConfig filename and its `editorconfig-core-handle' instance.") (cl-defstruct editorconfig-core-handle-section "Structure representing one section in a .editorconfig file. Slots: `name' String of section name (glob string). `props' Alist of properties: (KEY . VALUE)." (name nil) (props nil)) (defun editorconfig-core-handle-section-get-properties (section file dir) "Return properties alist when SECTION name match FILE. DIR should be the directory where .editorconfig file which has SECTION lives. IF not match, return nil." (when (editorconfig-core-handle--fnmatch-p file (editorconfig-core-handle-section-name section) dir) (editorconfig-core-handle-section-props section))) (cl-defstruct editorconfig-core-handle "Structure representing an .editorconfig file. Slots: `top-props' Alist of top properties like ((\"root\" . \"true\")) `sections' List of `editorconfig-core-handle-section' structure objects. `mtime' Last modified time of .editorconfig file. `path' Absolute path to .editorconfig file.' " (top-props nil) (sections nil) (mtime nil) (path nil)) (defun editorconfig-core-handle (conf) "Return EditorConfig handle for CONF, which should be a file path. If CONF does not exist return nil." (when (file-readable-p conf) (let ((cached (gethash conf editorconfig-core-handle--cache-hash)) (mtime (nth 5 (file-attributes conf)))) (if (and cached (equal (editorconfig-core-handle-mtime cached) mtime)) cached (let ((parsed (editorconfig-core-handle--parse-file conf))) (puthash conf (make-editorconfig-core-handle :top-props (plist-get parsed :top-props) :sections (plist-get parsed :sections) :mtime mtime :path conf) editorconfig-core-handle--cache-hash)))))) (defun editorconfig-core-handle-root-p (handle) "Return non-nil if HANDLE represent root EditorConfig file. If HANDLE is nil return nil." (when handle (string-equal "true" (downcase (or (cdr (assoc "root" (editorconfig-core-handle-top-props handle))) ""))))) (defun editorconfig-core-handle-get-properties (handle file) "Return list of alist of properties from HANDLE for FILE. The list returned will be ordered by the lines they appear. If HANDLE is nil return nil." (when handle (let ((dir (file-name-directory (editorconfig-core-handle-path handle)))) (cl-loop for section in (editorconfig-core-handle-sections handle) for props = (editorconfig-core-handle-section-get-properties section file dir) when props collect (copy-alist props))))) (make-obsolete 'editorconfig-core-handle-get-properties 'editorconfig-core-handle-get-properties-hash "0.8.0") (defun editorconfig-core-handle-get-properties-hash (handle file) "Return hash of properties from HANDLE for FILE. If HANDLE is nil return nil." (when handle (let ((hash (make-hash-table)) (dir (file-name-directory (editorconfig-core-handle-path handle)))) (dolist (section (editorconfig-core-handle-sections handle)) (cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file dir) do (puthash (intern key) value hash))) hash))) (defun editorconfig-core-handle--fnmatch-p (name pattern dir) "Return non-nil if NAME match PATTERN. If pattern has slash, pattern should be relative to DIR. This function is a fnmatch with a few modification for EditorConfig usage." (if (string-match-p "/" pattern) (let ((pattern (replace-regexp-in-string "^/" "" pattern)) (dir (file-name-as-directory dir))) (editorconfig-fnmatch-p name (concat dir pattern))) (editorconfig-fnmatch-p name (concat "**/" pattern)))) (defsubst editorconfig-core-handle--string-trim (str) "Remove leading and trailing whitespaces from STR." (replace-regexp-in-string "[[:space:]]+\\'" "" (replace-regexp-in-string "\\`[[:space:]]+" "" str))) (defun editorconfig-core-handle--parse-file (conf) "Parse EditorConfig file CONF. This function returns cons of its top properties alist and alist of patterns and its properties alist. The list returned will be ordered by the lines they appear. If CONF is not found return nil." (when (file-readable-p conf) (with-temp-buffer ;; NOTE: Use this instead of insert-file-contents-literally to enable ;; code conversion (insert-file-contents conf) (goto-char (point-min)) (let ((point-max (point-max)) (sections ()) (top-props nil) ;; String of current line (line "") ;; nil when pattern not appeared yet, "" when pattern is empty ("[]") (pattern nil) ;; Alist of properties for current PATTERN (props ()) ;; Current line num (current-line-number 1) ) (while (not (eq (point) point-max)) (setq line (buffer-substring-no-properties (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 editorconfig-emacs-0.8.2/editorconfig-core.el000066400000000000000000000167351410546646200212330ustar00rootroot00000000000000;;; editorconfig-core.el --- EditorConfig Core library in Emacs Lisp -*- lexical-binding: t -*- ;; Copyright (C) 2011-2021 EditorConfig Team ;; Author: EditorConfig Team ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors ;; or the CONTRIBUTORS file for the list of contributors. ;; This file is part of EditorConfig Emacs Plugin. ;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ;; Public License for more details. ;; You should have received a copy of the GNU General Public License along with ;; EditorConfig Emacs Plugin. If not, see . ;;; Commentary: ;; This library is one implementation of EditorConfig Core, which parses ;; .editorconfig files and returns properties for given files. ;; This can be used in place of, for example, editorconfig-core-c. ;; Use from EditorConfig Emacs Plugin ;; Emacs plugin (v0.5 or later) can utilize this implementation. ;; By default, the plugin first search for any EditorConfig executable, ;; and fallback to this library if not found. ;; If you always want to use this library, add following lines to your init.el: ;; (setq editorconfig-get-properties-function ;; 'editorconfig-core-get-properties-hash) ;; Functions ;; editorconfig-core-get-properties (&optional file confname confversion) ;; Get EditorConfig properties for FILE. ;; If FILE is not given, use currently visiting file. ;; Give CONFNAME for basename of config file other than .editorconfig. ;; If need to specify config format version, give CONFVERSION. ;; This functions returns alist of properties. Each element will look like ;; (KEY . VALUE) . ;; editorconfig-core-get-properties-hash (&optional file confname confversion) ;; Get EditorConfig properties for FILE. ;; This function is almost same as `editorconfig-core-get-properties', but ;; returns hash object instead. ;;; Code: (require 'cl-lib) (require 'editorconfig-core-handle) (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 editorconfig-emacs-0.8.2/editorconfig-fnmatch.el000066400000000000000000000256261410546646200217220ustar00rootroot00000000000000;;; editorconfig-fnmatch.el --- Glob pattern matching in Emacs lisp -*- lexical-binding: t -*- ;; Copyright (C) 2011-2021 EditorConfig Team ;; Author: EditorConfig Team ;; See ;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors ;; or the CONTRIBUTORS file for the list of contributors. ;; This file is part of EditorConfig Emacs Plugin. ;; EditorConfig Emacs Plugin is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or (at your ;; option) any later version. ;; EditorConfig Emacs Plugin is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General ;; Public License for more details. ;; You should have received a copy of the GNU General Public License along with ;; EditorConfig Emacs Plugin. If not, see . ;;; Commentary: ;; editorconfig-fnmatch.el provides a fnmatch implementation with a few ;; extensions. ;; The main usage of this library is glob pattern matching for EditorConfig, but ;; it can also act solely. ;; editorconfig-fnmatch-p (name pattern) ;; Test whether NAME match PATTERN. ;; PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings ;; can be used: ;; * Matches any string of characters, except path separators (/) ;; ** Matches any string of characters ;; ? Matches any single character ;; [name] Matches any single character in name ;; [^name] Matches any single character not in name ;; {s1,s2,s3} Matches any of the strings given (separated by commas) ;; {min..max} Matches any number between min and max ;; This library is a port from editorconfig-core-py library. ;; https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/fnmatch.py ;;; Code: (require 'cl-lib) (defvar editorconfig-fnmatch--cache-hashtable nil "Cache of shell pattern and its translation.") ;; Clear cache on file reload (setq editorconfig-fnmatch--cache-hashtable (make-hash-table :test 'equal)) (defconst editorconfig-fnmatch--left-brace-regexp "\\(^\\|[^\\]\\){" "Regular expression for left brace ({).") (defconst editorconfig-fnmatch--right-brace-regexp "\\(^\\|[^\\]\\)}" "Regular expression for right brace (}).") (defconst editorconfig-fnmatch--numeric-range-regexp "\\([+-]?[0-9]+\\)\\.\\.\\([+-]?[0-9]+\\)" "Regular expression for numeric range (like {-3..+3}).") (defun editorconfig-fnmatch--match-num (regexp string) "Return how many times REGEXP is found in STRING." (let ((num 0)) ;; START arg does not work as expected in this case (while (string-match regexp string) (setq num (1+ num) string (substring string (match-end 0)))) num)) ;;;###autoload (defun editorconfig-fnmatch-p (string pattern) "Test whether STRING match PATTERN. Matching ignores case if `case-fold-search' is non-nil. PATTERN should be a shell glob pattern, and some zsh-like wildcard matchings can be used: * Matches any string of characters, except path separators (/) ** Matches any string of characters ? Matches any single character [name] Matches any single character in name [^name] Matches any single character not in name {s1,s2,s3} Matches any of the strings given (separated by commas) {min..max} Matches any number between min and max" (string-match (editorconfig-fnmatch-translate pattern) string)) ;;(editorconfig-fnmatch-translate "{a,{-3..3}}.js") ;;(editorconfig-fnmatch-p "1.js" "{a,{-3..3}}.js") (defun editorconfig-fnmatch-translate (pattern) "Translate a shell PATTERN to a regular expression. Translation result will be cached, so same translation will not be done twice." (let ((cached (gethash pattern editorconfig-fnmatch--cache-hashtable))) (or cached (puthash pattern (editorconfig-fnmatch--do-translate pattern) editorconfig-fnmatch--cache-hashtable)))) (defun editorconfig-fnmatch--do-translate (pattern &optional nested) "Translate a shell PATTERN to a regular expression. Set NESTED to t when this function is called from itself. This function is called from `editorconfig-fnmatch-translate', when no cached translation is found for PATTERN." (let ((index 0) (length (length pattern)) (brace-level 0) (in-brackets nil) ;; List of strings of resulting regexp (result ()) (is-escaped nil) (matching-braces (= (editorconfig-fnmatch--match-num editorconfig-fnmatch--left-brace-regexp pattern) (editorconfig-fnmatch--match-num editorconfig-fnmatch--right-brace-regexp pattern))) current-char pos has-slash has-comma num-range) (while (< index length) (if (and (not is-escaped) (string-match "[^]\\*?[{},/\\-]+" ;;(string-match "[^]\\*?[{},/\\-]+" "?.a") pattern index) (eq index (match-beginning 0))) (setq result `(,@result ,(regexp-quote (match-string 0 pattern))) index (match-end 0) is-escaped nil) (setq current-char (aref pattern index) index (1+ index)) (cl-case current-char (?* (setq pos index) (if (and (< pos length) (= (aref pattern pos) ?*)) (setq result `(,@result ".*")) (setq result `(,@result "[^/]*")))) (?? (setq result `(,@result "[^/]"))) (?\[ (if in-brackets (setq result `(,@result "\\[")) (if (= (aref pattern index) ?/) ;; Slash after an half-open bracket (setq result `(,@result "\\[/") index (+ index 1)) (setq pos index has-slash nil) (while (and (< pos length) (not (= (aref pattern pos) ?\])) (not has-slash)) (if (and (= (aref pattern pos) ?/) (not (= (aref pattern (- pos 1)) ?\\))) (setq has-slash t) (setq pos (1+ pos)))) (if has-slash (setq result `(,@result ,(concat "\\[" (substring pattern index (1+ pos)) "\\]")) index (+ pos 2)) (if (and (< index length) (memq (aref pattern index) '(?! ?^))) (setq index (1+ index) result `(,@result "[^")) (setq result `(,@result "["))) (setq in-brackets t))))) (?- (if in-brackets (setq result `(,@result "-")) (setq result `(,@result "\\-")))) (?\] (setq result `(,@result "]") in-brackets nil)) (?{ (setq pos index has-comma nil) (while (and (or (and (< pos length) (not (= (aref pattern pos) ?}))) is-escaped) (not has-comma)) (if (and (eq (aref pattern pos) ?,) (not is-escaped)) (setq has-comma t) (setq is-escaped (and (eq (aref pattern pos) ?\\) (not is-escaped)) pos (1+ pos)))) (if (and (not has-comma) (< pos length)) (let ((pattern-sub (substring pattern index pos))) (setq num-range (string-match editorconfig-fnmatch--numeric-range-regexp pattern-sub)) (if num-range (let ((number-start (string-to-number (match-string 1 pattern-sub))) (number-end (string-to-number (match-string 2 pattern-sub)))) (setq result `(,@result ,(concat "\\(?:" (mapconcat 'number-to-string (cl-loop for i from number-start to number-end collect i) "\\|") "\\)")))) (let ((inner (editorconfig-fnmatch--do-translate pattern-sub t))) (setq result `(,@result ,(format "{%s}" inner))))) (setq index (1+ pos))) (if matching-braces (setq result `(,@result "\\(?:") brace-level (1+ brace-level)) (setq result `(,@result "{"))))) (?, (if (and (> brace-level 0) (not is-escaped)) (setq result `(,@result "\\|")) (setq result `(,@result "\\,")))) (?} (if (and (> brace-level 0) (not is-escaped)) (setq result `(,@result "\\)") brace-level (- brace-level 1)) (setq result `(,@result "}")))) (?/ (if (and (<= (+ index 3) (length pattern)) (string= (substring pattern index (+ index 3)) "**/")) (setq result `(,@result "\\(?:/\\|/.*/\\)") index (+ index 3)) (setq result `(,@result "/")))) (t (unless (= current-char ?\\) (setq result `(,@result ,(regexp-quote (char-to-string current-char))))))) (if (= current-char ?\\) (progn (when is-escaped (setq result `(,@result "\\\\"))) (setq is-escaped (not is-escaped))) (setq is-escaped nil)))) (unless nested (setq result `("^" ,@result "\\'"))) (apply 'concat result))) (provide 'editorconfig-fnmatch) ;;; editorconfig-fnmatch.el ends here editorconfig-emacs-0.8.2/editorconfig.el000066400000000000000000001211771410546646200203020ustar00rootroot00000000000000;;; editorconfig.el --- EditorConfig Emacs Plugin -*- lexical-binding: t -*- ;; Copyright (C) 2011-2021 EditorConfig Team ;; Author: EditorConfig Team ;; 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 . ;;; 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: editorconfig-emacs-0.8.2/ert-tests/000077500000000000000000000000001410546646200172255ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/editorconfig-2.el000066400000000000000000000104101410546646200223560ustar00rootroot00000000000000(require 'editorconfig) (defun display-warning (type message &optional level buffer-name) "When testing overwrite this function to throw error when called." (unless (eq level :debug) (error "display-warning called: %S %S %S %S" type message level buffer-name))) (defmacro with-visit-file (path &rest body) "Visit PATH and evaluate BODY." (declare (indent 1) (debug t)) `(let ((buf (find-file-noselect ,path))) (unwind-protect (with-current-buffer buf ,@body) (kill-buffer buf)))) ;;; interactive (ert-deftest interactive-test-01 nil "This test should not run on Travis" :tags '(:interactive) (should t)) ;;; noninteractive, will run on Travis (ert-deftest has-feature-01 nil "minimally working - provides 'editorconfig" (should (featurep 'editorconfig))) (defvar editorconfig-ert-dir (concat default-directory "ert-tests/plugin-tests/test_files/")) (defvar editorconfig-secondary-ert-dir (concat default-directory "ert-tests/test_files_secondary/")) (ert-deftest test-editorconfig-2 nil "Check if properties are applied." (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (with-visit-file (concat editorconfig-ert-dir "3_space.txt") (should (eq tab-width 3)) (should (eq indent-tabs-mode nil))) (with-visit-file (concat editorconfig-ert-dir "4_space.py") (should (eq python-indent-offset 4)) (should (eq tab-width 8)) (should (eq indent-tabs-mode nil))) (editorconfig-mode -1))) (ert-deftest test-lisp-use-default-indent-2 nil (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset 2))) (let ((editorconfig-lisp-use-default-indent t)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset nil)))) (let ((editorconfig-lisp-use-default-indent 2)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset nil)))) (let ((editorconfig-lisp-use-default-indent 4)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset 2)))) (editorconfig-mode -1))) (ert-deftest test-trim-trailing-ws-2 nil (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (with-visit-file (concat editorconfig-ert-dir "trim.txt") (should (memq 'delete-trailing-whitespace write-file-functions))) (with-visit-file (concat editorconfig-ert-dir "trim.txt") (read-only-mode 1) (should (not (memq 'delete-trailing-whitespace write-file-functions)))) (editorconfig-mode -1))) (ert-deftest test-file-type-emacs-2 nil :expected-result t ;; Ignore failure (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "c.txt") (should (eq major-mode 'conf-unix-mode))) (editorconfig-mode -1))) (ert-deftest test-file-type-ext-2 nil :expected-result t ;; Ignore failure (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "a.txt") (should (eq major-mode 'conf-unix-mode))) (with-visit-file (concat editorconfig-secondary-ert-dir "bin/perlscript") (should (eq major-mode 'perl-mode)) (should (eq perl-indent-level 5))) (editorconfig-mode -1))) (ert-deftest test-hack-properties-functions-2 nil (let ((editorconfig--enable-20210221-testing t)) (editorconfig-mode 1) (add-hook 'editorconfig-hack-properties-functions (lambda (props) (puthash 'indent_size "5" props))) (with-visit-file (concat editorconfig-ert-dir "4_space.py") (should (eq python-indent-offset 5))) (setq editorconfig-hack-properties-functions nil) (editorconfig-mode -1))) editorconfig-emacs-0.8.2/ert-tests/editorconfig-core-handle.el000066400000000000000000000052551410546646200244110ustar00rootroot00000000000000(require 'editorconfig-core-handle) (defconst fixtures (concat (file-name-directory load-file-name) "fixtures/")) (ert-deftest test-editorconfig-core-handle () ;; handle.ini (let* ((conf (concat fixtures "handle.ini")) (handle (editorconfig-core-handle conf))) (should (editorconfig-core-handle-root-p handle)) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "b.js")) '((("key2" . "value2"))))) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "a.js")) '((("key1" . "value1")) (("key2" . "value2")))))) ;; Test twice for checking cache (let* ((conf (concat fixtures "handle.ini")) (handle (editorconfig-core-handle conf))) (should (editorconfig-core-handle-root-p handle)) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "b.js")) '((("key2" . "value2"))))) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "a.js")) '((("key1" . "value1")) (("key2" . "value2")))))) ;; handle2.ini (let* ((conf (concat fixtures "handle2.ini")) (handle (editorconfig-core-handle conf))) (should-not (editorconfig-core-handle-root-p handle)) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "b.js")) nil)) (should (equal (editorconfig-core-handle-get-properties handle (concat fixtures "a.js")) '((("key" . "value")))))) ;; For checking various normal whitespace (line breaks, horizontal space, vertical space, etc.) (let* ((conf (concat default-directory "ert-tests/whitespaces/example-editorconfig.txt")) (handle (editorconfig-core-handle conf))) (should (editorconfig-core-handle-p handle))) ) editorconfig-emacs-0.8.2/ert-tests/editorconfig-core.el000066400000000000000000000010551410546646200231520ustar00rootroot00000000000000(require 'editorconfig-core) (ert-deftest test-editorconfig-core--get-handles () (let* ((fixtures (concat default-directory "/ert-tests/fixtures/")) (dir (concat fixtures "dir1")) (confname "parent.ini") (handles (editorconfig-core--get-handles dir confname))) (should (= 2 (length handles))) (should (editorconfig-core-handle-p (car handles))) (should (editorconfig-core-handle-p (cadr handles))))) editorconfig-emacs-0.8.2/ert-tests/editorconfig-fnmatch.el000066400000000000000000000165301410546646200236460ustar00rootroot00000000000000(require 'editorconfig-fnmatch) (ert-deftest test-editorconfig-fnmatch-p () (let ((cases-t '(("a.js" "a.js") ("/dir/a.js" "/dir/a.js") ("a.js" "*.js") ("a.js" "**.js") ("/dir/a.js" "/dir/*.js") ("/dir/a.js" "/dir/*") ("/dir/sub/a.js" "**.js") ("/dir/sub/a.py" "/dir/**.py") ("a.js" "?.js") ("abc.js" "a?c.js") ("/dir/a.js" "/dir/?.js") ("a.js" "[abc].js") ("b.js" "[abc].js") ("ab.js" "[abc]b.js") ("/dir/a.js" "/dir/[abc].js") ("ab[e/]cd.i" "ab[e/]cd.i") ("a.js" "[a-c].js") ("1.js" "[1-3].js") ("a.js" "[a-c1-3].js") ("1.js" "[a-c1-3].js") ("d.js" "[!abc].js") ("db.js" "[!abc]b.js") ("/dir/d.js" "/dir/[!abc].js") ("d.js" "[!a-c].js") ("a.js" "a.{py,js}") ("a.py" "a.{py,js}") ("/dir/a.py" "/dir/a.{py,js}") ("/dir/a.py" "/dir/a.{py,js}") ("a.js" "*.{py,js}") ("a.py" "*.{py,js}") ("/dir/a.js" "/dir/*.{py,js}") ("/dir/a.py" "/dir/*.{py,js}") ("/dir/sub/a.py" "**.{py,js}") ("/dir/sub/a.py" "/dir/**.{py,js}") ("{single}.b" "{single}.b") ("{.f" "{.f") ("}.f" "}.f") ("a.js" "{a,[0-9]}.js") ("1.js" "{a,[0-9]}.js") ("-3.py" "{-3..3}.{js,py}") ("1.js" "{0..3}.js") ("1.js" "{0..+3}.js") ("-1.js" "{-3..3}.js") ("-1.js" "{-3..3}.js") ("test3" "{test3,test0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003}") ("ab[e/]cd.i" "ab[e/]cd.i") ("ab[/c" "ab[/c") )) (cases-nil '(("a.js" "b.js") ("a.js" "*.py") ("/dir/a.js" "/dir/*.py") ("/dir/sub/a.js" "/dir/*.js") ("/dir/a.js" "/sub/**.js") ("/dir/sub/a.js" "/sub/**.js") ("ab.js" "?.js") ("ab.js" "?a.js") ("/dir/ab.js" "/dir/?.js") ("/dir/ab.js" "/dir/?a.js") ("d.js" "[abc].js") ("db.js" "[abc]b.js") ("/dir/d.js" "/dir/[abc].js") ("d.js" "[a-c].js") ("4.js" "[1-3].js") ("d.js" "[a-c1-3].js") ("4.js" "[a-c1-3].js") ("a.js" "[!abc].js") ("ab.js" "[!abc]b.js") ("/dir/a.js" "/dir/[!abc].js") ("a.js" "[!a-c].js") ("a.js" "[!a-c1-3].js") ("1.js" "[!a-c1-3].js") ("a.el" "a.{py,js}") ("a.el" "*.{py,js}") ("/dir/a.el" "/dir/a.{py,js}") ("/dir/a.el" "/dir/*.{py,js}") ("/dir/a.el" "**.{py,js}") ("1.js" "{3..6}.js") ("-1.js" "{0..3}.js") ("-1.js" "{3..-3}.js") ))) (dolist (args cases-t) (message "-> t: %S" `(editorconfig-fnmatch-p ,@args)) (message " Elapsed: %S" (car (benchmark-run 3 (should (apply 'editorconfig-fnmatch-p args)))))) (dolist (args cases-nil) (message "-> nil: %S" `(editorconfig-fnmatch-p ,@args)) (message " Elapsed: %S" (car (benchmark-run 3 (should-not (apply 'editorconfig-fnmatch-p args))))))) ) editorconfig-emacs-0.8.2/ert-tests/editorconfig.el000066400000000000000000000076431410546646200222350ustar00rootroot00000000000000(require 'editorconfig) (defun display-warning (type message &optional level buffer-name) "When testing overwrite this function to throw error when called." (unless (eq level :debug) (error "display-warning called: %S %S %S %S" type message level buffer-name))) (defmacro with-visit-file (path &rest body) "Visit PATH and evaluate BODY." (declare (indent 1) (debug t)) `(let ((buf (find-file-noselect ,path))) (unwind-protect (with-current-buffer buf ,@body) (kill-buffer buf)))) ;;; interactive (ert-deftest interactive-test-01 nil "This test should not run on Travis" :tags '(:interactive) (should t)) ;;; noninteractive, will run on Travis (ert-deftest has-feature-01 nil "minimally working - provides 'editorconfig" (should (featurep 'editorconfig))) (defvar editorconfig-ert-dir (concat default-directory "ert-tests/plugin-tests/test_files/")) (defvar editorconfig-secondary-ert-dir (concat default-directory "ert-tests/test_files_secondary/")) (ert-deftest test-editorconfig nil "Check if properties are applied." (editorconfig-mode 1) (with-visit-file (concat editorconfig-ert-dir "3_space.txt") (should (eq tab-width 3)) (should (eq indent-tabs-mode nil))) (with-visit-file (concat editorconfig-ert-dir "4_space.py") (should (eq python-indent-offset 4)) (should (eq tab-width 8)) (should (eq indent-tabs-mode nil))) (editorconfig-mode -1)) (ert-deftest test-lisp-use-default-indent nil (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset 2))) (let ((editorconfig-lisp-use-default-indent t)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset nil)))) (let ((editorconfig-lisp-use-default-indent 2)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset nil)))) (let ((editorconfig-lisp-use-default-indent 4)) (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el") (should (eq lisp-indent-offset 2)))) (editorconfig-mode -1)) (ert-deftest test-trim-trailing-ws nil (editorconfig-mode 1) (with-visit-file (concat editorconfig-ert-dir "trim.txt") (should (memq 'delete-trailing-whitespace write-file-functions))) (with-visit-file (concat editorconfig-ert-dir "trim.txt") (read-only-mode 1) (should (not (memq 'delete-trailing-whitespace write-file-functions)))) (editorconfig-mode -1)) (ert-deftest test-file-type-emacs nil :expected-result t ;; Ignore failure (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "c.txt") (should (eq major-mode 'conf-unix-mode))) (editorconfig-mode -1)) (ert-deftest test-file-type-ext nil :expected-result t ;; Ignore failure (editorconfig-mode 1) (with-visit-file (concat editorconfig-secondary-ert-dir "a.txt") (should (eq major-mode 'conf-unix-mode))) (with-visit-file (concat editorconfig-secondary-ert-dir "bin/perlscript") (should (eq major-mode 'perl-mode)) (should (eq perl-indent-level 5))) (editorconfig-mode -1)) (ert-deftest test-hack-properties-functions nil (editorconfig-mode 1) (add-hook 'editorconfig-hack-properties-functions (lambda (props) (puthash 'indent_size "5" props))) (with-visit-file (concat editorconfig-ert-dir "4_space.py") (should (eq python-indent-offset 5))) (setq editorconfig-hack-properties-functions nil) (editorconfig-mode -1)) editorconfig-emacs-0.8.2/ert-tests/fixtures/000077500000000000000000000000001410546646200210765ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/fixtures/dir1/000077500000000000000000000000001410546646200217355ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/fixtures/dir1/parent.ini000066400000000000000000000000201410546646200237170ustar00rootroot00000000000000[a.js] key=none editorconfig-emacs-0.8.2/ert-tests/fixtures/handle.ini000066400000000000000000000001101410546646200230220ustar00rootroot00000000000000root = true [a.js] key1=value1 [*.js] key2=value2 [*.py] key3=value3 editorconfig-emacs-0.8.2/ert-tests/fixtures/handle2.ini000066400000000000000000000000241410546646200231100ustar00rootroot00000000000000[a.js] key = value editorconfig-emacs-0.8.2/ert-tests/fixtures/parent.ini000066400000000000000000000000351410546646200230660ustar00rootroot00000000000000root=true [a.js] key=value1 editorconfig-emacs-0.8.2/ert-tests/metadata.el000066400000000000000000000004271410546646200213320ustar00rootroot00000000000000(require 'package) (defvar metadata-el-files nil) (ert-deftest test-metadata () (dolist (el metadata-el-files) (message "Loading info: %s" el) (with-temp-buffer (insert-file-contents el) (message "%S" (package-buffer-info))))) editorconfig-emacs-0.8.2/ert-tests/plugin-tests/000077500000000000000000000000001410546646200216635ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/test_files_secondary/000077500000000000000000000000001410546646200234355ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/test_files_secondary/.editorconfig000066400000000000000000000002471410546646200261150ustar00rootroot00000000000000root = true [2_space.el] indent_size = 2 indent_style = tab [c.txt] file_type_emacs = conf [a.txt] file_type_ext = ini [/bin/*] file_type_ext = pl indent_size = 5 editorconfig-emacs-0.8.2/ert-tests/test_files_secondary/2_space.el000066400000000000000000000000261410546646200252710ustar00rootroot00000000000000(print "hello world") editorconfig-emacs-0.8.2/ert-tests/whitespaces/000077500000000000000000000000001410546646200215445ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/whitespaces/example-editorconfig.txt000066400000000000000000000002201410546646200264040ustar00rootroot00000000000000root = true [*] # Text encoding name. charset = utf-8 # Page Break # Remove trailing whitespace on lines? trim_trailing_whitespace = true pax_global_header00006660000000000000000000000064135532143620014516gustar00rootroot0000000000000052 comment=48610d43b7455af12195473377f93c4ceea654f5 editorconfig-emacs-0.8.2/core-test/000077500000000000000000000000001355321436200171745ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/.editorconfig000066400000000000000000000002661355321436200216550ustar00rootroot00000000000000[{CMakeLists.txt,*.cmake}] trim_trailing_whitespace = true indent_style = space indent_size = 4 [*.in] trim_trailing_whitespace = false [*.md] indent_style = space indent_size = 4 editorconfig-emacs-0.8.2/core-test/.gitignore000066400000000000000000000003131355321436200211610ustar00rootroot00000000000000# Generated by CMake CMakeCache.txt CMakeFiles Makefile cmake_install.cmake install_manifest.txt # Generated by CTest /Testing CTestTestfile.cmake # Eclipse .project # Editor backup files ~* *~ *.swp editorconfig-emacs-0.8.2/core-test/CMakeLists.txt000066400000000000000000000130161355321436200217350ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # New escape-sequence processing. cmake_minimum_required(VERSION 3.5) cmake_policy(VERSION 3.5.1) # Don't check any language compiler. This project is for EditorConfig Core # testing only. project(editorconfig-core-test NONE) # Where this file lives set(tests_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}") message(STATUS "Tests are in ${tests_cmakelists_dir}") # Only when we are using editorconfig-core-test independently should we check # cmake version, set EDITORCONFIG_CMD as cache string, and enable_testing() # here. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) set(EDITORCONFIG_CMD "editorconfig" CACHE STRING "editorconfig command.") set(EDITORCONFIG_CMD_IS_TARGET OFF CACHE BOOL "EDITORCONFIG_CMD names a CMake target rather than an executable.") enable_testing() message(STATUS "tests: Standalone testing enabled") endif() if(${EDITORCONFIG_CMD_IS_TARGET}) message(STATUS "tests: Using editorconfig target ${EDITORCONFIG_CMD}") else() message(STATUS "tests: Using editorconfig binary ${EDITORCONFIG_CMD}") endif() # The most common test function function(new_ec_test name ec_file src_file regex) add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -f ${ec_file} "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}") set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}") endfunction() # A test that requires a version specified function(new_ec_test_version name ec_file src_file regex version) add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -b ${version} -f ${ec_file} "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}") set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}") endfunction() # A test that requires the full path to the EditorConfig files function(new_ec_test_full_ec_file_path name ec_file src_file regex) add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -f ${ec_file} ${src_file}) set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}") endfunction() # A test that returns multiple lines of output. CAUTION: filenames used in # these tests may not contain semicolons. function(new_ec_test_multiline name ec_file src_file regex) #message(STATUS "Building multiline test ${name} with tests_cmakelists_dir ${tests_cmakelists_dir}") #message(STATUS "List dir ${CMAKE_CURRENT_LIST_DIR}, source dir ${CMAKE_CURRENT_SOURCE_DIR}") if(${EDITORCONFIG_CMD_IS_TARGET}) add_test(NAME ${name} COMMAND "cmake" "-D" "EDITORCONFIG_CMD=$" # Since variables aren't automatically passed to the inner cmake "-D" "ECARGS:LIST=-f;${ec_file};${CMAKE_CURRENT_SOURCE_DIR}/${src_file}" # Note: the semicolons separate list elements. "-P" "${tests_cmakelists_dir}/cmake/ec_sort.cmake") else() add_test(NAME ${name} COMMAND "cmake" "-D" "EDITORCONFIG_CMD=${EDITORCONFIG_CMD}" # Since variables aren't automatically passed to the inner cmake "-D" "ECARGS:LIST=-f;${ec_file};${CMAKE_CURRENT_SOURCE_DIR}/${src_file}" # Note: the semicolons separate list elements. "-P" "${tests_cmakelists_dir}/cmake/ec_sort.cmake") endif() set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "^[\r\n]*${regex}$") # Permit leading \n's because I can't always get rid of them using # only CMake-provided facilities. endfunction() # Tests for other CLI arguments. Usage: # new_ec_cli_test(NAME name MATCH pass_regex ARGS arguments...) function(new_ec_cli_test) # Parse args set(one_value_keywords NAME MATCH) set(multi_value_keywords ARGS) cmake_parse_arguments(P "" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) # Add test add_test(NAME ${P_NAME} COMMAND ${EDITORCONFIG_CMD} ${P_ARGS}) set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${P_MATCH}") endfunction() # First, make sure the test harness works. add_subdirectory(meta) # Then test the core. add_subdirectory(glob) add_subdirectory(properties) add_subdirectory(parser) add_subdirectory(filetree) add_subdirectory(cli) editorconfig-emacs-0.8.2/core-test/LICENSE.txt000066400000000000000000000024351355321436200210230ustar00rootroot00000000000000Copyright (c) 2011-2018 EditorConfig Team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. editorconfig-emacs-0.8.2/core-test/README.md000066400000000000000000000023301355321436200204510ustar00rootroot00000000000000This project is a series of testing for [EditorConfig Core][editorconfig]. Please have [cmake][] installed before using this project. ### Use editorconfig-core-test independently After installing cmake, switch to the root dir of this project, and execute: cmake -DEDITORCONFIG_CMD=the_editorconfig_core_cmd_you_want_to_test . After that, if testing files are generated successfully, execute `ctest .` to start testings. ### Use editorconfig-core-test in your project as a git submodule If you are using [git][] and cmake to manage your project, this method should be suitable for you. Suppose that you will add editorconfig-core-test repo as a submodule in your root directory. First add editorconfig-core-test as a gitsubmodule in your repo by execute: git submodule add git://github.com/editorconfig/editorconfig-core-test.git tests Then add the following lines to your project root `CMakeLists.txt`: ```cmake enable_testing() set(EDITORCONFIG_CMD the_editorconfig_core_path) add_subdirectory(tests) ``` Now after executing `cmake .` in you project root dir, you should be able to run the testings by executing `ctest .`. [cmake]: http://www.cmake.org [editorconfig]: http://editorconfig.org [git]: http://git-scm.com editorconfig-emacs-0.8.2/core-test/cli/000077500000000000000000000000001355321436200177435ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/cli/CMakeLists.txt000066400000000000000000000047361355321436200225150ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Tests for version switches # test --version option returns version information new_ec_cli_test(NAME test_long_version_switch ARGS --version MATCH "^EditorConfig.* Version [0-9]+\\.[0-9]+\\.[0-9]+(-[a-z]+)?[ \t\n\r]$") # test -v option returns version information new_ec_cli_test(NAME test_short_version_switch ARGS -v MATCH "^EditorConfig.* Version [0-9]+\\.[0-9]+\\.[0-9]+(-[a-z]+)?[ \t\n\r]$") # Test for multiple input files # when files are specified on command line. The files can appear in either # order in the output, but each file's output line must be grouped with its # file header. Handle this by listing both possibilities manually in the regex. new_ec_cli_test(NAME multiple_files_on_command_line ARGS -f cli.in "${CMAKE_CURRENT_SOURCE_DIR}/file1.c" "${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp" MATCH "^(\\[${CMAKE_CURRENT_SOURCE_DIR}/file1.c\\][ \t]*[\n\r]+key1=value1[ \t]*[\n\r]+\\[${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp\\][ \t]*[\n\r]+key2=value2)|(\\[${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp\\][ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+\\[${CMAKE_CURRENT_SOURCE_DIR}/file1.c\\][ \t]*[\n\r]+key1=value1)[ \t\n\r]*$" ) editorconfig-emacs-0.8.2/core-test/cli/cli.in000066400000000000000000000000701355321436200210370ustar00rootroot00000000000000root = true [*.c] key1 = value1 [*.cpp] key2 = value2 editorconfig-emacs-0.8.2/core-test/cmake/000077500000000000000000000000001355321436200202545ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/cmake/almostcat.cmake000077500000000000000000000037761355321436200232650ustar00rootroot00000000000000# almostcat.cmake: print the file named in ${WHICH} to **stderr**. Puts an # extra space at the beginning to suppress CMake's word wrapping. May add # an extra \n at the end because that's what message() does. # BSD-2-Clause # Copyright 2018 Christopher White (cxw42 at GitHub; http://devwrench.com) # All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.5) if("${WHICH}" STREQUAL "") message(FATAL_ERROR "No WHICH parameter specified") return() endif() #message(FATAL_ERROR " Reading ${WHICH}") # Uncomment for debugging file(READ "${WHICH}" contents) # message() will give us an extra \n, so trim one if we can. string(REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}") # Print, with a leading space as noted above. message(" ${contents}") editorconfig-emacs-0.8.2/core-test/cmake/ec_sort.cmake000077500000000000000000000055771355321436200227350ustar00rootroot00000000000000# ec_sort.cmake: Run editorconfig and sort its output # For use in editorconfig; see # https://github.com/editorconfig/editorconfig/issues/375 . # Call as, e.g.: # cmake -D EDITORCONFIG_CMD="../editorconfig" -D ECARGS:LIST="-f;.editorconfig;foo" -P cmake/ec_sort.cmake # EDITORCONFIG_CMD may also be list-valued. EDITORCONFIG_CMD and ECARGS # are put together on the command line, in that order, and split by CMake. # BSD-2-Clause # Copyright 2018 Christopher White (cxw42 at GitHub; http://devwrench.com) # All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.5) # See documentation links at https://stackoverflow.com/q/12802377/2877364 set(tests_cmake_ec_sort_dir "${CMAKE_CURRENT_LIST_DIR}") list(APPEND CMAKE_MODULE_PATH "${tests_cmake_ec_sort_dir}/../cmake") include(runandsort) # Required parameters are in variables: EDITORCONFIG_CMD and ECARGS if("${EDITORCONFIG_CMD}" STREQUAL "") message(FATAL_ERROR "No EDITORCONFIG_CMD parameter specified") return() endif() if("${ECARGS}" STREQUAL "") message(FATAL_ERROR "No ECARGS parameter specified") return() endif() # Uncomment for debugging #message(FATAL_ERROR " Running ${EDITORCONFIG_CMD} with ${ECARGS}") run_and_sort(RETVAL lines RETVAL_FAILURE did_fail CMDLINE ${EDITORCONFIG_CMD} ${ECARGS} ) if(${did_fail}) message(FATAL_ERROR "${EDITORCONFIG_CMD} ${ECARGS} returned a nonzero exit code") return() endif() # message() will give us an extra \n, so trim one if we can. string(REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}") # Output **to stderr**. If we used message(STATUS...), it would print to # stdout but also emit a leading "--". message("${lines}") editorconfig-emacs-0.8.2/core-test/cmake/runandsort.cmake000077500000000000000000000124271355321436200234660ustar00rootroot00000000000000# runandsort.cmake: Run a program and sort its output # For use in editorconfig; see # https://github.com/editorconfig/editorconfig/issues/375 . # BSD-2-Clause # Copyright 2018 Christopher White (cxw42 at GitHub; http://devwrench.com) # All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.5) # Conventions: # - "P_*" are parameters parsed using cmake_parse_arguments # - Any parameter called "RETVAL", "RETVAL_*", or "*_NAME" should be given # the name of a variable in the caller's scope into which to # store results. # Run a program with the given arguments, and return its sorted output as # a string. # CAUTION 1: May not produce correct output if any output line includes # a semicolon, because that is a list separator in CMake. # CAUTION 2: Depends on sort order of CMake; see discussion at # https://gitlab.kitware.com/cmake/cmake/issues/18551 # # Limitations: # Any \x01 in the string will be corrupted - this routine uses those to work # around CMake limitations. # Arguments: # RETVAL . . . . . . . The name of the variable to store the result in # CMDLINE . . . . . . . The program to run, and any arguments # RETVAL_FAILURE . . . . If present, a variable that will be set to TRUE # if PGM returns a non-zero exit code. # CAPTURE_STDERR . . . . If present, capture stderr instead of stdout # TRIM_INITIAL_LEADING_SPACE If present, remove initial spaces from the # first line. This is to work around a hack # in almostcat.cmake. # # Returns: # The sorted stdout of PGM, or the FAILURE string if PGM failed. # PGM's stderr is ignored. function(run_and_sort) # Argument parsing set(option_keywords CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE) set(one_value_keywords RETVAL RETVAL_FAILURE) set(multi_value_keywords CMDLINE ARGS) cmake_parse_arguments(P "${option_keywords}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) #message(STATUS "Running ${P_CMDLINE}") # DEBUG execute_process(COMMAND ${P_CMDLINE} RESULT_VARIABLE ep_retval OUTPUT_VARIABLE ep_stdout ERROR_VARIABLE ep_stderr ) # Which one are we processing? if(${P_CAPTURE_STDERR}) set(ep_out "${ep_stderr}") else() set(ep_out "${ep_stdout}") endif() #message(STATUS "Got retval =${ep_retval}=") # DEBUG #message(STATUS "Got stdout =${ep_stdout}=") # DEBUG #message(STATUS "Got stderr =${ep_stderr}=") # DEBUG # Early bail on failure if(NOT("${ep_retval}" EQUAL "0")) set(${P_RETVAL} "" PARENT_SCOPE) if("${P_RETVAL_FAILURE}" MATCHES ".") # if we got a name set(${P_RETVAL_FAILURE} TRUE PARENT_SCOPE) endif() return() endif() # Trim hack if(${P_TRIM_INITIAL_LEADING_SPACE}) string(REGEX REPLACE "^[ ]+" "" ep_out "${ep_out}") endif() # Change all the semicolons in the output to \x01 string(ASCII 1 ONE) string(REPLACE ";" "${ONE}" ep_out "${ep_out}") #message(STATUS "After escaping =${ep_out}=") # DEBUG # Normalize line endings, just in case string(REGEX REPLACE "\r|\n|\r\n" "\n" ep_out "${ep_out}") #message(STATUS "After line-endings =${ep_out}=") # DEBUG # Turn the string into a list string(REPLACE "\n" ";" ep_out "${ep_out}") #message(STATUS "After listifying =${ep_out}=") # DEBUG # Sort the list list(SORT ep_out) # Back to individual lines string(REPLACE ";" "\n" ep_out "${ep_out}") #message(STATUS "After back to lines =${ep_out}=") # DEBUG # And back to semicolons. Note: I am not trying to reverse line endings. string(REPLACE "${ONE}" ";" ep_out "${ep_out}") #message(STATUS "After unescaping =${ep_out}=") # DEBUG # Out to the caller set(${P_RETVAL} "${ep_out}" PARENT_SCOPE) #message(STATUS "Returned =${ep_out}=") # DEBUG endfunction(run_and_sort) editorconfig-emacs-0.8.2/core-test/filetree/000077500000000000000000000000001355321436200207735ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/CMakeLists.txt000066400000000000000000000123451355321436200235400ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # cmake_minimum_required(VERSION 3.5) # Test for EditorConfig file in parent directory new_ec_test(parent_directory parent_directory.in parent_directory/test.a "^key=value[ \t\n\r]*$") # Test for EditorConfig file in parent directory and current directory new_ec_test_multiline(parent_and_current_dir_ML parent_directory.in parent_directory/test.b "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*") # Test for file in parent directory and overloaded by file in current directory new_ec_test(parent_dir_overload parent_directory.in parent_directory/test.c "^key=valueB[ \t\n\r]*$") # Test for file in parent directory and overloaded by file in current directory and repeated in current directory new_ec_test(parent_dir_overload_repeat parent_directory.in parent_directory/test.d "^key=value_c[ \t\n\r]*$") # Test for file in parent directory and overloaded by file in current directory and repeated in current directory, with different patterns new_ec_test(parent_dir_overload_repeat2 parent_directory.in parent_directory/test.e "^key=value_g[ \t\n\r]*$") # Test that search stops at root EditorConfig file new_ec_test(root_file root_file.in root_file/test.a "^[ \t\n\r]*$") # Test that search stops at root EditorConfig file new_ec_test(root_file_mixed_case root_file.in root_mixed/test.a "^child=true[ \t\n\r]*$") # Test that search stops at root EditorConfig file new_ec_test(root_pattern root_file.in root "^name=root[ \t\n\r]*$") # Tests path separator match new_ec_test(path_separator path_separator.in path/separator "^key1=value1[ \t\n\r]*$") # Windows style path separator in the command line should work on Windows, but # should not work on other systems (including Cygwin) if(WIN32) set(path_separator_backslash_in_cmd_line_regex "^key1=value1[ \t\n\r]*$") else(WIN32) set(path_separator_backslash_in_cmd_line_regex "^[ \t\n\r]*$") endif(WIN32) new_ec_test_full_ec_file_path(path_separator_backslash_in_cmd_line path_separator.in "${CMAKE_CURRENT_SOURCE_DIR}\\path\\separator" ${path_separator_backslash_in_cmd_line_regex}) # Tests path separator match below top of path new_ec_test(nested_path_separator path_separator.in nested/path/separator "^[ \t\n\r]*$") # Tests path separator match top of path only new_ec_test(top_level_path_separator path_separator.in top/of/path "^key2=value2[ \t\n\r]*$") # Tests path separator match top of path only new_ec_test(top_level_path_separator_neg path_separator.in not/top/of/path "^[ \t\n\r]*$") # Test Windows-style path separator (backslash) does not work new_ec_test(windows_separator path_separator.in windows/separator "^[ \t\n\r]*$") # Test again that Windows-style path separator (backslash) does not work new_ec_test(windows_separator2 path_separator.in windows/separator2 "^[ \t\n\r]*$") # Globs with backslash in it but should be considered as file name on Non-Windows system if((NOT WIN32) AND (NOT CYGWIN)) new_ec_test(backslash_not_on_windows path_separator.in "windows\\separator2" "^key4=value4[ \t\n\r]*$") endif() new_ec_test(path_with_special_chars path_with_special_chars.in "path_with_special_[chars/test.a" "^key=value[ \t\n\r]*$") ## " <-- resync the syntax highlighter # Test the unset value with various common properties new_ec_test(unset_charset unset.in unset/charset.txt "^charset=unset[ \t\n\r]*$") new_ec_test(unset_end_of_line unset.in unset/end_of_line.txt "^end_of_line=unset[ \t\n\r]*$") new_ec_test_multiline(unset_indent_size_ML unset.in unset/indent_size.txt "indent_size=unset[ \t\n\r]*tab_width=unset[ \t\n\r]*") new_ec_test(unset_indent_style unset.in unset/indent_style.txt "^indent_style=unset[ \t\n\r]*$") new_ec_test(unset_insert_final_newline unset.in unset/insert_final_newline.txt "^insert_final_newline=unset[ \t\n\r]*$") new_ec_test(unset_tab_width unset.in unset/tab_width.txt "^tab_width=unset[ \t\n\r]*$") new_ec_test(unset_trim_trailing_whitespace unset.in unset/trim_trailing_whitespace.txt "^trim_trailing_whitespace=unset[ \t\n\r]*$") editorconfig-emacs-0.8.2/core-test/filetree/parent_directory.in000066400000000000000000000001671355321436200247040ustar00rootroot00000000000000root = true [test.a] key=value [test.b] key1=value1 [test.c] key=valueA [test.d] key=value_a [test.e] key=value_e editorconfig-emacs-0.8.2/core-test/filetree/parent_directory/000077500000000000000000000000001355321436200243505ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/parent_directory/parent_directory.in000066400000000000000000000001771355321436200302620ustar00rootroot00000000000000[test.b] key2=value2 [test.c] key=valueB [test.d] key=value_b [test.d] key=value_c [test.e] key=value_f [*.e] key=value_g editorconfig-emacs-0.8.2/core-test/filetree/path_separator.in000066400000000000000000000002431355321436200243360ustar00rootroot00000000000000; test for path separator root=true [path/separator] key1=value1 [/top/of/path] key2=value2 [windows\separator] key3=value3 [windows\\separator2] key4=value4 editorconfig-emacs-0.8.2/core-test/filetree/path_with_special_[chars/000077500000000000000000000000001355321436200257755ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/path_with_special_[chars/path_with_special_chars.in000066400000000000000000000000401355321436200331660ustar00rootroot00000000000000root = true [test.a] key=value editorconfig-emacs-0.8.2/core-test/filetree/root_file.in000066400000000000000000000000621355321436200233030ustar00rootroot00000000000000root = true [test.a] key=value [root] name=root editorconfig-emacs-0.8.2/core-test/filetree/root_file/000077500000000000000000000000001355321436200227555ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/root_file/root_file.in000066400000000000000000000000141355321436200252620ustar00rootroot00000000000000root = true editorconfig-emacs-0.8.2/core-test/filetree/root_mixed/000077500000000000000000000000001355321436200231445ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/root_mixed/root_file.in000066400000000000000000000000551355321436200254560ustar00rootroot00000000000000root = TrUe ignore = false [*.a] child=true editorconfig-emacs-0.8.2/core-test/filetree/unset.in000066400000000000000000000004441355321436200224630ustar00rootroot00000000000000root = true [charset.txt] charset=utf-8 [end_of_line.txt] end_of_line=lf [indent_size.txt] indent_size=2 [indent_style.txt] indent_style=space [insert_final_newline.txt] insert_final_newline=true [tab_width.txt] tab_width=4 [trim_trailing_whitespace.txt] trim_trailing_whitespace=true editorconfig-emacs-0.8.2/core-test/filetree/unset/000077500000000000000000000000001355321436200221315ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/filetree/unset/unset.in000066400000000000000000000004451355321436200236220ustar00rootroot00000000000000 [charset.txt] charset=unset [end_of_line.txt] end_of_line=unset [indent_size.txt] indent_size=unset [indent_style.txt] indent_style=unset [insert_final_newline.txt] insert_final_newline=unset [tab_width.txt] tab_width=unset [trim_trailing_whitespace.txt] trim_trailing_whitespace=unset editorconfig-emacs-0.8.2/core-test/glob/000077500000000000000000000000001355321436200201175ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/glob/CMakeLists.txt000066400000000000000000000267721355321436200226750ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Tests for * # matches a single characters new_ec_test_multiline(star_single_ML star.in ace.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") # matches zero characters new_ec_test_multiline(star_zero_ML star.in ae.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") # matches multiple characters new_ec_test_multiline(star_multiple_ML star.in abcde.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*") # does not match path separator new_ec_test(star_over_slash star.in a/e.c "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$") # star after a slash new_ec_test_multiline(star_after_slash_ML star.in Bar/foo.txt "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*") # star matches a dot file after slash new_ec_test_multiline(star_matches_dot_file_after_slash_ML star.in Bar/.editorconfig "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*") # star matches a dot file new_ec_test(star_matches_dot_file star.in .editorconfig "^keyc=valuec[ \t\n\r]*$") # Tests for ? # matches a single character new_ec_test(question_single question.in some.c "^key=value[ \t\n\r]*$") # does not match zero characters new_ec_test(question_zero question.in som.c "^[ \t\n\r]*$") # does not match multiple characters new_ec_test(question_multiple question.in something.c "^[ \t\n\r]*$") # does not match slash new_ec_test(question_slash question.in som/.c "^[ \t\n\r]*$") # Tests for [ and ] # close bracket inside new_ec_test(brackets_close_inside brackets.in ].g "^close_inside=true[ \t\n\r]*$") # close bracket outside new_ec_test(brackets_close_outside brackets.in b].g "^close_outside=true[ \t\n\r]*$") # negative close bracket inside new_ec_test(brackets_nclose_inside brackets.in c.g "^close_inside=false[ \t\n\r]*$") # negative close bracket outside new_ec_test(brackets_nclose_outside brackets.in c].g "^close_outside=false[ \t\n\r]*$") # character choice new_ec_test(brackets_choice brackets.in a.a "^choice=true[ \t\n\r]*$") # character choice 2 new_ec_test(brackets_choice2 brackets.in c.a "^[ \t\n\r]*$") # negative character choice new_ec_test(brackets_nchoice brackets.in c.b "^choice=false[ \t\n\r]*$") # negative character choice 2 new_ec_test(brackets_nchoice2 brackets.in a.b "^[ \t\n\r]*$") # character range new_ec_test(brackets_range brackets.in f.c "^range=true[ \t\n\r]*$") # character range 2 new_ec_test(brackets_range2 brackets.in h.c "^[ \t\n\r]*$") # negative character range new_ec_test(brackets_nrange brackets.in h.d "^range=false[ \t\n\r]*$") # negative character range 2 new_ec_test(brackets_nrange2 brackets.in f.d "^[ \t\n\r]*$") # range and choice new_ec_test(brackets_range_and_choice brackets.in e.e "^range_and_choice=true[ \t\n\r]*$") # character choice with a dash new_ec_test(brackets_choice_with_dash brackets.in -.f "^choice_with_dash=true[ \t\n\r]*$") # slash inside brackets new_ec_test(brackets_slash_inside1 brackets.in ab/cd.i "^[ \t\n\r]*$") new_ec_test(brackets_slash_inside2 brackets.in abecd.i "^[ \t\n\r]*$") new_ec_test(brackets_slash_inside3 brackets.in ab[e/]cd.i "^slash_inside=true[ \t\n\r]*$") new_ec_test(brackets_slash_inside4 brackets.in ab[/c "^slash_half_open=true[ \t\n\r]*$") # Tests for { and } # word choice new_ec_test(braces_word_choice1 braces.in test.py "^choice=true[ \t\n\r]*$") new_ec_test(braces_word_choice2 braces.in test.js "^choice=true[ \t\n\r]*$") new_ec_test(braces_word_choice3 braces.in test.html "^choice=true[ \t\n\r]*$") new_ec_test(braces_word_choice4 braces.in test.pyc "^[ \t\n\r]*$") # single choice new_ec_test(braces_single_choice braces.in {single}.b "^choice=single[ \t\n\r]*$") new_ec_test(braces_single_choice_negative braces.in .b "^[ \t\n\r]*$") # empty choice new_ec_test(braces_empty_choice braces.in {}.c "^empty=all[ \t\n\r]*$") new_ec_test(braces_empty_choice_negative braces.in .c "^[ \t\n\r]*$") # choice with empty word new_ec_test(braces_empty_word1 braces.in a.d "^empty=word[ \t\n\r]*$") new_ec_test(braces_empty_word2 braces.in ab.d "^empty=word[ \t\n\r]*$") new_ec_test(braces_empty_word3 braces.in ac.d "^empty=word[ \t\n\r]*$") new_ec_test(braces_empty_word4 braces.in a,.d "^[ \t\n\r]*$") # choice with empty words new_ec_test(braces_empty_words1 braces.in a.e "^empty=words[ \t\n\r]*$") new_ec_test(braces_empty_words2 braces.in ab.e "^empty=words[ \t\n\r]*$") new_ec_test(braces_empty_words3 braces.in ac.e "^empty=words[ \t\n\r]*$") new_ec_test(braces_empty_words4 braces.in a,.e "^[ \t\n\r]*$") # no closing brace new_ec_test(braces_no_closing braces.in {.f "^closing=false[ \t\n\r]*$") new_ec_test(braces_no_closing_negative braces.in .f "^[ \t\n\r]*$") # nested braces new_ec_test(braces_nested1 braces.in word,this}.g "^[ \t\n\r]*$") new_ec_test(braces_nested2 braces.in {also,this}.g "^[ \t\n\r]*$") new_ec_test(braces_nested3 braces.in word.g "^nested=true[ \t\n\r]*$") new_ec_test(braces_nested4 braces.in {also}.g "^nested=true[ \t\n\r]*$") new_ec_test(braces_nested5 braces.in this.g "^nested=true[ \t\n\r]*$") # closing inside beginning new_ec_test(braces_closing_in_beginning braces.in {},b}.h "^closing=inside[ \t\n\r]*$") # missing closing braces new_ec_test(braces_unmatched1 braces.in {{,b,c{d}.i "^unmatched=true[ \t\n\r]*$") new_ec_test(braces_unmatched2 braces.in {.i "^[ \t\n\r]*$") new_ec_test(braces_unmatched3 braces.in b.i "^[ \t\n\r]*$") new_ec_test(braces_unmatched4 braces.in c{d.i "^[ \t\n\r]*$") new_ec_test(braces_unmatched5 braces.in .i "^[ \t\n\r]*$") # escaped comma new_ec_test(braces_escaped_comma1 braces.in a,b.txt "^comma=yes[ \t\n\r]*$") new_ec_test(braces_escaped_comma2 braces.in a.txt "^[ \t\n\r]*$") new_ec_test(braces_escaped_comma3 braces.in cd.txt "^comma=yes[ \t\n\r]*$") # escaped closing brace new_ec_test(braces_escaped_brace1 braces.in e.txt "^closing=yes[ \t\n\r]*$") new_ec_test(braces_escaped_brace2 braces.in }.txt "^closing=yes[ \t\n\r]*$") new_ec_test(braces_escaped_brace3 braces.in f.txt "^closing=yes[ \t\n\r]*$") # escaped backslash new_ec_test(braces_escaped_backslash1 braces.in g.txt "^backslash=yes[ \t\n\r]*$") if((NOT WIN32) AND (NOT CYGWIN)) # this case is impossible on Windows. new_ec_test(braces_escaped_backslash2 braces.in "\\.txt" "^backslash=yes[ \t\n\r]*$") endif() new_ec_test(braces_escaped_backslash3 braces.in i.txt "^backslash=yes[ \t\n\r]*$") # patterns nested in braces new_ec_test(braces_patterns_nested1 braces.in some.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested2 braces.in abe.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested3 braces.in abf.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested4 braces.in abg.j "^[ \t\n\r]*$") new_ec_test(braces_patterns_nested5 braces.in ace.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested6 braces.in acf.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested7 braces.in acg.j "^[ \t\n\r]*$") new_ec_test(braces_patterns_nested8 braces.in abce.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested9 braces.in abcf.j "^patterns=nested[ \t\n\r]*$") new_ec_test(braces_patterns_nested10 braces.in abcg.j "^[ \t\n\r]*$") new_ec_test(braces_patterns_nested11 braces.in ae.j "^[ \t\n\r]*$") new_ec_test(braces_patterns_nested12 braces.in .j "^[ \t\n\r]*$") # numeric brace range new_ec_test(braces_numeric_range1 braces.in 1 "^[ \t\n\r]*$") new_ec_test(braces_numeric_range2 braces.in 3 "^number=true[ \t\n\r]*$") new_ec_test(braces_numeric_range3 braces.in 15 "^number=true[ \t\n\r]*$") new_ec_test(braces_numeric_range4 braces.in 60 "^number=true[ \t\n\r]*$") new_ec_test(braces_numeric_range5 braces.in 5a "^[ \t\n\r]*$") new_ec_test(braces_numeric_range6 braces.in 120 "^number=true[ \t\n\r]*$") new_ec_test(braces_numeric_range7 braces.in 121 "^[ \t\n\r]*$") new_ec_test(braces_numeric_range8 braces.in 060 "^[ \t\n\r]*$") # alphabetical brace range: letters should not be considered for ranges new_ec_test(braces_alpha_range1 braces.in {aardvark..antelope} "^words=a[ \t\n\r]*$") new_ec_test(braces_alpha_range2 braces.in a "^[ \t\n\r]*$") new_ec_test(braces_alpha_range3 braces.in aardvark "^[ \t\n\r]*$") new_ec_test(braces_alpha_range4 braces.in agreement "^[ \t\n\r]*$") new_ec_test(braces_alpha_range5 braces.in antelope "^[ \t\n\r]*$") new_ec_test(braces_alpha_range6 braces.in antimatter "^[ \t\n\r]*$") # Tests for ** # test EditorConfig files with UTF-8 characters larger than 127 new_ec_test(utf_8_char utf8char.in "中文.txt" "^key=value[ \t\n\r]*$") # matches over path separator new_ec_test(star_star_over_separator1 star_star.in a/z.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator2 star_star.in amnz.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator3 star_star.in am/nz.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator4 star_star.in a/mnz.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator5 star_star.in amn/z.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator6 star_star.in a/mn/z.c "^key1=value1[ \t\n\r]*$") new_ec_test(star_star_over_separator7 star_star.in b/z.c "^key2=value2[ \t\n\r]*$") new_ec_test(star_star_over_separator8 star_star.in b/mnz.c "^key2=value2[ \t\n\r]*$") new_ec_test(star_star_over_separator9 star_star.in b/mn/z.c "^key2=value2[ \t\n\r]*$") new_ec_test(star_star_over_separator10 star_star.in bmnz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator11 star_star.in bm/nz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator12 star_star.in bmn/z.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator13 star_star.in c/z.c "^key3=value3[ \t\n\r]*$") new_ec_test(star_star_over_separator14 star_star.in cmn/z.c "^key3=value3[ \t\n\r]*$") new_ec_test(star_star_over_separator15 star_star.in c/mn/z.c "^key3=value3[ \t\n\r]*$") new_ec_test(star_star_over_separator16 star_star.in cmnz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator17 star_star.in cm/nz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator18 star_star.in c/mnz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator19 star_star.in d/z.c "^key4=value4[ \t\n\r]*$") new_ec_test(star_star_over_separator20 star_star.in d/mn/z.c "^key4=value4[ \t\n\r]*$") new_ec_test(star_star_over_separator21 star_star.in dmnz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator22 star_star.in dm/nz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator23 star_star.in d/mnz.c "^[ \t\n\r]*$") new_ec_test(star_star_over_separator24 star_star.in dmn/z.c "^[ \t\n\r]*$") editorconfig-emacs-0.8.2/core-test/glob/braces.in000066400000000000000000000013601355321436200217060ustar00rootroot00000000000000; test { and } root=true ; word choice [*.{py,js,html}] choice=true ; single choice [{single}.b] choice=single ; empty choice [{}.c] empty=all ; choice with empty word [a{b,c,}.d] empty=word ; choice with empty words [a{,b,,c,}.e] empty=words ; no closing brace [{.f] closing=false ; nested braces [{word,{also},this}.g] nested=true ; closing inside beginning [{},b}.h] closing=inside ; opening inside beginning [{{,b,c{d}.i] unmatched=true ; escaped comma [{a\,b,cd}.txt] comma=yes ; escaped closing brace [{e,\},f}.txt] closing=yes ; escaped backslash [{g,\\,i}.txt] backslash=yes ; patterns nested in braces [{some,a{*c,b}[ef]}.j] patterns=nested ; numeric braces [{3..120}] number=true ; alphabetical [{aardvark..antelope}] words=a editorconfig-emacs-0.8.2/core-test/glob/brackets.in000066400000000000000000000012421355321436200222440ustar00rootroot00000000000000; test [ and ] root=true ; Character choice [[ab].a] choice=true ; Negative character choice [[!ab].b] choice=false ; Character range [[d-g].c] range=true ; Negative character range [[!d-g].d] range=false ; Range and choice [[abd-g].e] range_and_choice=true ; Choice with dash [[-ab].f] choice_with_dash=true ; Close bracket inside [[\]ab].g] close_inside=true ; Close bracket outside [[ab]].g] close_outside=true ; Negative close bracket inside [[!\]ab].g] close_inside=false ; Negative¬close bracket outside [[!ab]].g] close_outside=false ; Slash inside brackets [ab[e/]cd.i] slash_inside=true ; Slash after an half-open bracket [ab[/c] slash_half_open=true editorconfig-emacs-0.8.2/core-test/glob/question.in000066400000000000000000000000511355321436200223120ustar00rootroot00000000000000; test ? root=true [som?.c] key=value editorconfig-emacs-0.8.2/core-test/glob/star.in000066400000000000000000000001151355321436200214150ustar00rootroot00000000000000; test * root=true [a*e.c] key=value [Bar/*] keyb=valueb [*] keyc=valuec editorconfig-emacs-0.8.2/core-test/glob/star_star.in000066400000000000000000000001611355321436200224470ustar00rootroot00000000000000; test ** root=true [a**z.c] key1=value1 [b/**z.c] key2=value2 [c**/z.c] key3=value3 [d/**/z.c] key4=value4 editorconfig-emacs-0.8.2/core-test/glob/utf8char.in000066400000000000000000000001471355321436200221750ustar00rootroot00000000000000; test EditorConfig files with UTF-8 characters larger than 127 root = true [中文.txt] key = value editorconfig-emacs-0.8.2/core-test/meta/000077500000000000000000000000001355321436200201225ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/meta/CMakeLists.txt000077500000000000000000000043001355321436200226620ustar00rootroot00000000000000# tests/meta/CMakeLists.txt: Test of the test harness for editorconfig. # BSD-2-Clause # Copyright 2018 Christopher White (cxw42 at GitHub; http://devwrench.com) # All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.5) set(tests_meta_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}") # Line separator regex, for convenience set(L "[ \t\n\r]+") message(STATUS "meta: Using editorconfig ${EDITORCONFIG_CMD}") # Test run_and_sort() add_test(meta_runandsort cmake -P "${tests_meta_cmakelists_dir}/sample.cmake") set_tests_properties(meta_runandsort PROPERTIES PASS_REGULAR_EXPRESSION "^[\r\n]*0${L}a;b${L}b;c${L}b;e${L}b;f${L}c;b;a${L}d${L}$") # Have to permit leading \n's - I don't know how to get rid of them # Test the new multiline macro on a simple case. The new_ec_test_multiline # function adds /^[\r\n]*/ to the beginning of the provided regex, and # /$/ to the end. new_ec_test_multiline(meta_multiline meta.in meta.c "answer=42${L}") editorconfig-emacs-0.8.2/core-test/meta/meta.in000077500000000000000000000000231355321436200213760ustar00rootroot00000000000000[meta.c] answer=42 editorconfig-emacs-0.8.2/core-test/meta/sample.cmake000066400000000000000000000023171355321436200224100ustar00rootroot00000000000000# sample.cmake: Tests run_and_sort to make sure it's working. cmake_minimum_required(VERSION 3.5) # See documentation links at https://stackoverflow.com/q/12802377/2877364 set( tests_meta_sample_dir "${CMAKE_CURRENT_LIST_DIR}" ) list( APPEND CMAKE_MODULE_PATH "${tests_meta_sample_dir}/../cmake" ) include( runandsort ) run_and_sort( RETVAL lines RETVAL_FAILURE did_fail CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE # since we're using almostcat CMDLINE "cmake" "-DWHICH:STRING=${tests_meta_sample_dir}/sample.txt" "-P" "${tests_meta_sample_dir}/../cmake/almostcat.cmake" ) # Don't use cat(1) since we might be running on Windows if( ${did_fail} ) message( FATAL_ERROR "Program returned a nonzero exit code" ) return() endif() # message() will give us an extra \n, so trim one if we can. string( REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}" ) message( "${lines}" ) # This outputs to stderr, and prints nothing extra except for a \n at the end # Note that message( STATUS "${lines}" ) doesn't work because it outputs a "--" # before the actual content. # You could also use execute_process( COMMAND "echo" "${lines}" ) # or cmake -E echo, but I think the message() call is good enough. editorconfig-emacs-0.8.2/core-test/meta/sample.txt000077500000000000000000000000321355321436200221420ustar00rootroot00000000000000b;f b;c b;e a;b c;b;a d 0 editorconfig-emacs-0.8.2/core-test/parser/000077500000000000000000000000001355321436200204705ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/parser/CMakeLists.txt000066400000000000000000000146411355321436200232360ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Basic parser tests # test repeat sections new_ec_test_multiline(repeat_sections_ML basic.in a.a "option1=value1[ \t]*[\n\r]+option2=value2[ \t\n\r]*") new_ec_test_multiline(basic_cascade_ML basic.in b.b "option1=c[ \t]*[\n\r]+option2=b[ \t\n\r]*") # Tests for whitespace parsing # test no whitespaces in property assignment new_ec_test(no_whitespace whitespace.in test1.c "^key=value[ \t\n\r]*$") # test single spaces around equals sign new_ec_test(single_spaces_around_equals whitespace.in test2.c "^key=value[ \t\n\r]*$") # test multiple spaces around equals sign new_ec_test(multiple_spaces_around_equals whitespace.in test3.c "^key=value[ \t\n\r]*$") # test spaces before property name new_ec_test(spaces_before_property_name whitespace.in test4.c "^key=value[ \t\n\r]*$") # test spaces before after property value new_ec_test(spaces_after_property_value whitespace.in test5.c "^key=value[ \t\n\r]*$") # test blank lines between properties new_ec_test_multiline(blank_lines_between_properties_ML whitespace.in test6.c "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*") # test spaces in section name new_ec_test(spaces_in_section_name whitespace.in " test 7 " "^key=value[ \t\n\r]*$") # test spaces before section name are ignored new_ec_test(spaces_before_section_name whitespace.in test8.c "^key=value[ \t\n\r]*$") # test spaces after section name new_ec_test(spaces_after_section_name whitespace.in test9.c "^key=value[ \t\n\r]*$") # test spaces at beginning of line between properties new_ec_test_multiline(spaces_before_middle_property_ML whitespace.in test10.c "key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*") # test colon seperator with no whitespaces in property assignment new_ec_test(colon_sep_no_whitespace whitespace.in test1.d "^key=value[ \t\n\r]*$") # test colon seperator with single spaces around equals sign new_ec_test(colon_sep_single_spaces_around_equals whitespace.in test2.d "^key=value[ \t\n\r]*$") # test colon seperator with multiple spaces around equals sign new_ec_test(colon_sep_multiple_spaces_around_equals whitespace.in test3.d "^key=value[ \t\n\r]*$") # test colon seperator with spaces before property name new_ec_test(colon_sep_spaces_before_property_name whitespace.in test4.d "^key=value[ \t\n\r]*$") # test colon seperator with spaces before after property value new_ec_test(colon_sep_spaces_after_property_value whitespace.in test5.d "^key=value[ \t\n\r]*$") # Tests for comment parsing # test comments ignored after property name new_ec_test(comments_after_property comments.in test1.c "^key=value[ \t\n\r]*$") # test comments ignored after section name new_ec_test(comments_after_section comments.in test2.c "^key=value[ \t\n\r]*$") # test comments ignored before properties new_ec_test(comment_before_props comments.in test3.c "^key=value[ \t\n\r]*$") # test comments ignored between properties new_ec_test_multiline(comment_between_props_ML comments.in test4.c "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*") # test semicolons at end of property value are included in value new_ec_test(semicolon_in_property comments.in test5.c "^key=value; not comment[ \t\n\r]*$") # test escaped semicolons are included in section names new_ec_test(escaped_semicolon_in_section comments.in "test;.c" "^key=value[ \t\n\r]*$") # test octothorpe comments ignored after property name new_ec_test(octothorpe_comments_after_property comments.in test7.c "^key=value[ \t\n\r]*$") # test octothorpe comments ignored after section name new_ec_test(octothorpe_comments_after_section comments.in test8.c "^key=value[ \t\n\r]*$") # test octothorpe comments ignored before properties new_ec_test(octothorpe_comment_before_props comments.in test9.c "^key=value[ \t\n\r]*$") # test octothorpe comments ignored between properties new_ec_test_multiline(octothorpe_comment_between_props_ML comments.in test10.c "key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*") # test octothorpe at end of property value are included in value new_ec_test(octothorpe_in_value comments.in test11.c "^key=value# not comment[ \t\n\r]*$") # test escaped octothorpes are included in section names new_ec_test(escaped_octothorpe_in_section comments.in "test\#.c" "^key=value[ \t\n\r]*$") # test EditorConfig files with BOM at the head new_ec_test(bom_at_head bom.in "a.c" "^key=value[ \t\n\r]*$") # test EditorConfig files with CRLF line separators new_ec_test(crlf_linesep crlf.in "a.c" "^key=value[ \t\n\r]*$") # Test max property name and values new_ec_test(max_property_name limits.in test1 "^00000000000000000000000000000000000000000000000001=50[ \t\n\r]*$") new_ec_test(max_property_value limits.in test2 "^k255=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001[ \t\n\r]*$") # Test max section names new_ec_test(max_section_name_ok limits.in test3 "^key=value[ \t\n\r]*$") new_ec_test(max_section_name_ignore limits.in test4 "^[ \t\n\r]*$") editorconfig-emacs-0.8.2/core-test/parser/basic.in000066400000000000000000000002011355321436200220720ustar00rootroot00000000000000[*.a] option1=value1 ; repeat section [*.a] option2=value2 [*.b] option1 = a option2 = a [b.b] option2 = b [*.b] option1 = c editorconfig-emacs-0.8.2/core-test/parser/bom.in000066400000000000000000000001041355321436200215700ustar00rootroot00000000000000; test EditorConfig files with BOM root = true [*] key = value editorconfig-emacs-0.8.2/core-test/parser/comments.in000066400000000000000000000016611355321436200226510ustar00rootroot00000000000000; test comments root = true [test1.c] key=value ; Comment after property is ignored [test2.c] ; Comment ignored, even with ] character key=value [test3.c] ; Comment before properties ignored key=value [test4.c] key1=value1 ; Comment between properties ignored key2=value2 ; Semicolon at end of value read as part of value [test5.c] key=value; not comment ; Escaped semicolon in value [test6.c] key=value \; not comment ; Escaped semicolon in section name [test\;.c] key=value [test7.c] key=value # Comment after property is ignored [test8.c] # Comment ignored, even with ] character key=value [test9.c] # Comment before properties ignored key=value [test10.c] key1=value1 # Comment between properties ignored key2=value2 # Octothorpe at end of value read as part of value [test11.c] key=value# not comment # Escaped octothorpe in value [test12.c] key=value \# not comment # Escaped octothorpe in section name [test\#.c] key=value editorconfig-emacs-0.8.2/core-test/parser/crlf.in000066400000000000000000000001301355321436200217400ustar00rootroot00000000000000; test EditorConfig files with CRLF line separators root = true [*] key = value editorconfig-emacs-0.8.2/core-test/parser/limits.in000066400000000000000000000212631355321436200223250ustar00rootroot00000000000000root = true [test1] 00000000000000000000000000000000000000000000000001=50 000000000000000000000000000000000000000000000000002=51 [test2] k255=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 k256=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 [{test3,test0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003}] key=value [{test4,test00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004}] key=value editorconfig-emacs-0.8.2/core-test/parser/whitespace.in000066400000000000000000000016021355321436200231530ustar00rootroot00000000000000; test whitespace usage root = true ; no whitespace [test1.c] key=value ; spaces around equals [test2.c] key = value ; lots of space after equals [test3.c] key = value ; spaces before property name [test4.c] key=value ; spaces after property value [test5.c] key=value ; blank lines between properties [test6.c] key1=value1 key2=value2 ; spaces in section name [ test 7 ] key=value ; spaces before section name [test8.c] key=value ; spaces after section name [test9.c] key=value ; spacing before middle property [test10.c] key1=value1 key2=value2 key3=value3 ; colon separator with no spaces [test1.d] key:value ; colon separator with space after [test2.d] key: value ; colon separator with space before and after [test3.d] key : value ; colon separator with spaces before [test4.d] key:value ; colon seperator with spaces after property value [test5.d] key:value editorconfig-emacs-0.8.2/core-test/properties/000077500000000000000000000000001355321436200213705ustar00rootroot00000000000000editorconfig-emacs-0.8.2/core-test/properties/CMakeLists.txt000066400000000000000000000066751355321436200241460ustar00rootroot00000000000000# # Copyright (c) 2011-2018 EditorConfig Team # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # test tab_width default new_ec_test_multiline(tab_width_default_ML tab_width_default.in test.c "indent_size=4[ \t]*[\n\r]+indent_style=space[ \t]*[\n\r]+tab_width=4[\t\n\r]*") # Tab_width should not be set to any value if indent_size is "tab" and # tab_width is not set new_ec_test_multiline(tab_width_default_indent_size_tab_ML tab_width_default.in test2.c "indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*") # Test indent_size default. When indent_style is "tab", indent_size defaults to # "tab". new_ec_test_multiline(indent_size_default_ML indent_size_default.in test.c "indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*") # Test indent_size default. When indent_style is "tab", indent_size should have # no default value for version prior than 0.9.0. new_ec_test_version(indent_size_default_pre_0_9_0 indent_size_default.in test.c "^indent_style=tab[ \t\n\r]*$" 0.8.0) # Test indent_size default. When indent_style is "space", indent_size has no # default value. new_ec_test(indent_size_default_space indent_size_default.in test2.c "^indent_style=space[ \t\n\r]*$") # Test indent_size default. When indent_style is "tab" and tab_width is set, # indent_size should default to tab_width new_ec_test_multiline(indent_size_default_with_tab_width_ML indent_size_default.in test3.c "indent_size=2[ \t]*[\n\r]+indent_style=tab[ \t]*[\n\r]+tab_width=2[ \t\n\r]*") # test that same property values are lowercased (v0.9.0 properties) new_ec_test_multiline(lowercase_values1_ML lowercase_values.in test1.c "end_of_line=crlf[ \t]*[\n\r]+indent_style=space[ \t\n\r]*") # test that same property values are lowercased (v0.9.0 properties) new_ec_test_multiline(lowercase_values2_ML lowercase_values.in test2.c "charset=utf-8[ \t]*[\n\r]+insert_final_newline=true[ \t]*[\n\r]+trim_trailing_whitespace=false[ \t\n\r]*$") # test that same property values are not lowercased new_ec_test(lowercase_values3 lowercase_values.in test3.c "^test_property=TestValue[ \t\n\r]*$") # test that all property names are lowercased new_ec_test(lowercase_names lowercase_names.in test.c "^testproperty=testvalue[ \t\n\r]*$") editorconfig-emacs-0.8.2/core-test/properties/indent_size_default.in000066400000000000000000000001651355321436200257410ustar00rootroot00000000000000root = true [test.c] indent_style = tab [test2.c] indent_style = space [test3.c] indent_style = tab tab_width = 2 editorconfig-emacs-0.8.2/core-test/properties/lowercase_names.in000066400000000000000000000001321355321436200250630ustar00rootroot00000000000000; test that property names are lowercased root = true [test.c] TestProperty = testvalue editorconfig-emacs-0.8.2/core-test/properties/lowercase_values.in000066400000000000000000000003361355321436200252650ustar00rootroot00000000000000; test property name lowercasing root = true [test1.c] indent_style = Space end_of_line = CRLF [test2.c] insert_final_newline = TRUE trim_trailing_whitespace = False charset = UTF-8 [test3.c] test_property = TestValue editorconfig-emacs-0.8.2/core-test/properties/tab_width_default.in000066400000000000000000000001531355321436200253700ustar00rootroot00000000000000root = true [test.c] indent_style = space indent_size = 4 [test2.c] indent_style = tab indent_size = tab pax_global_header00006660000000000000000000000064133266250470014522gustar00rootroot0000000000000052 comment=cb7ae15d16ab3d72a1139f7a629b11cfe16d972f editorconfig-emacs-0.8.2/ert-tests/plugin-tests/000077500000000000000000000000001332662504700216635ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/plugin-tests/.editorconfig000066400000000000000000000003131332662504700243350ustar00rootroot00000000000000; EditorConfig is awesome: http://EditorConfig.org root = true [*.rst] indent_style = space indent_size = 4 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 editorconfig-emacs-0.8.2/ert-tests/plugin-tests/.gitignore000066400000000000000000000002741332662504700236560ustar00rootroot00000000000000test_files/lf.txt test_files/crlf.txt test_files/cr.txt test_files/utf-16be.txt test_files/utf-16le.txt test_files/utf-8-bom.txt test_files/with_newline.txt test_files/without_newline.txt editorconfig-emacs-0.8.2/ert-tests/plugin-tests/LICENSE000066400000000000000000000443531332662504700227010ustar00rootroot00000000000000Creative Commons Attribution 4.0 International ======================================================================= Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. Using Creative Commons Public Licenses Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors: wiki.creativecommons.org/Considerations_for_licensors Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations for the public: wiki.creativecommons.org/Considerations_for_licensees ======================================================================= Creative Commons Attribution 4.0 International Public License By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 -- Definitions. a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 -- Scope. a. License grant. 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: a. reproduce and Share the Licensed Material, in whole or in part; and b. produce, reproduce, and Share Adapted Material. 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3. Term. The term of this Public License is specified in Section 6(a). 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material. 5. Downstream recipients. a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. b. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b. Other rights. 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2. Patent and trademark rights are not licensed under this Public License. 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. Section 3 -- License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a. Attribution. 1. If You Share the Licensed Material (including in modified form), You must: a. retain the following if it is supplied by the Licensor with the Licensed Material: i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii. a copyright notice; iii. a notice that refers to this Public License; iv. a notice that refers to the disclaimer of warranties; v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. Section 4 -- Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 -- Disclaimer of Warranties and Limitation of Liability. a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 -- Term and Termination. a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2. upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 -- Other Terms and Conditions. a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 -- Interpretation. a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. ======================================================================= Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org. editorconfig-emacs-0.8.2/ert-tests/plugin-tests/README.rst000066400000000000000000000021541332662504700233540ustar00rootroot00000000000000Tests for EditorConfig Plugins ============================== There is currently no way to automate tests for EditorConfig plugins like there is for the EditorConfig core libraries. This repository contains instructions to help developers manually test their EditorConfig plugins. Running Tests ------------- The ``tests`` directory contains instructions for testing various EditorConfig properties. The ``test_files`` directory contains the test files referenced in these instructions. Tests should be run by opening up each relevant file in the ``tests`` directory, running through the tests in the file and verifying that the expected behavior is observed. After running each test the files in the git repository should be reverted and any newly created files should be deleted. To revert files in the git repository use: git checkout -- test_files/ License ------- This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. editorconfig-emacs-0.8.2/ert-tests/plugin-tests/templates/000077500000000000000000000000001332662504700236615ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/plugin-tests/templates/linux.editorconfig000066400000000000000000000002431332662504700274150ustar00rootroot00000000000000; This file is the EditorConfig template file for Linux style. [*] indent_style = tab tab_width = 8 charset = utf-8 insert_final_newline = true end_of_line = lf editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/000077500000000000000000000000001332662504700240245ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/.editorconfig000066400000000000000000000014441332662504700265040ustar00rootroot00000000000000root = true [3_space.txt] indent_style = space indent_size = 3 tab_width = 3 [4_space.py] indent_style = space indent_size = 4 tab_width = 8 [space.txt] indent_style = space indent_size = tab [tab.txt] indent_style = tab [4_tab.txt] indent_style = tab indent_size = 4 tab_width = 4 [4_tab_width_of_8.txt] indent_style = tab indent_size = 4 tab_width = 8 [lf.txt] end_of_line = lf [crlf.txt] end_of_line = crlf [cr.txt] end_of_line = cr [utf-8.txt] charset = utf-8 [utf-8-bom.txt] charset = utf-8-bom [utf-16be.txt] charset = utf-16be [utf-16le.txt] charset = utf-16le [latin1.txt] charset = latin1 [with_newline.txt] insert_final_newline = true [without_newline.txt] insert_final_newline = false [trim.txt] trim_trailing_whitespace = true [no_trim.txt] trim_trailing_whitespace = false editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/3_space.txt000066400000000000000000000001271332662504700261020ustar00rootroot00000000000000 this line is indented 6 characters 123456789 this line is indented 3 characters editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/4_space.py000066400000000000000000000001671332662504700257200ustar00rootroot00000000000000def main(): if True: print "single 8 column tab for indentation" print "this lines up with previous line" editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/4_tab.txt000066400000000000000000000000131332662504700255500ustar00rootroot000000000000000123456789 editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/4_tab_width_of_8.txt000066400000000000000000000000131332662504700276620ustar00rootroot00000000000000unindented editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/latin1.txt000066400000000000000000000000261332662504700257530ustar00rootroot00000000000000This is a Latin1 file editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/no_trim.txt000066400000000000000000000001201332662504700262250ustar00rootroot00000000000000This line ends in whitespace So does this one And this one But not this one editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/space.txt000066400000000000000000000000211332662504700256510ustar00rootroot00000000000000 tab indentation editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/tab.txt000066400000000000000000000000001332662504700253210ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/trim.txt000066400000000000000000000001201332662504700255310ustar00rootroot00000000000000This line ends in whitespace So does this one And this one But not this one editorconfig-emacs-0.8.2/ert-tests/plugin-tests/test_files/utf-8.txt000066400000000000000000000000251332662504700255250ustar00rootroot00000000000000This is a UTF-8 file editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/000077500000000000000000000000001332662504700230255ustar00rootroot00000000000000editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/charset.rst000066400000000000000000000046121332662504700252130ustar00rootroot00000000000000Tests for Character Set Property ============================== The following tests are for the ``charset`` EditorConfig property. Verifying Character Set ----------------------- In general the character set used in a file may not be conclusively verified, but it can often be verified with reasonable accuracy. The ``file`` command can be used to guess the character set used. Verifying LF newlines: ``file test_files/latin1.txt`` should return something like: test_files/utf-8.txt: ASCII text ``file test_files/utf-8.txt`` should return something like: test_files/utf-8.txt: UTF-8 Unicode text ``file test_files/utf-8-bom.txt`` should return something like: test_files/utf-8-bom.txt: UTF-8 Unicode (with BOM) text ``file test_files/utf-16be.txt`` should return something like: test_files/utf-16be.txt: Big-endian UTF-16 Unicode text ``file test_files/utf-16le.txt`` should return something like: test_files/utf-16le.txt: Little-endian UTF-16 Unicode text, with no line terminators Note that UTF-8 files without any unicode characters are indistinguishable from Latin1 files. Tests for Newlines ------------------ To ensure that the newlines added to files are not affected by the newlines already present in the files, new files should be created. Latin1 Character Set ~~~~~~~~~~~~~~~~~~~~ 1. Open file ``latin1.txt``. 2. Add a line without unicode characters to the file and save it. 3. Confirm that the file is an ASCII file. Latin1 Character Set with Unicode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open file ``latin1.txt``. 1. Add this line to the file: "Here is a unicode character: ★" and save it 2. Confirm that either: a. an error was raised b. the file was saved as UTF-8 without BOM UTF-8 Character Set ~~~~~~~~~~~~~~~~~~~ 1. Open file ``utf-8.txt``. 2. Add this line to the file: "Here is a unicode character: ★" and save it 3. Confirm that the file was saved as UTF-8 (without BOM) UTF-8 with BOM Character Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Create file ``utf-8-bom.txt``. 2. Add a line to the file and save it 3. Confirm that the file was saved as UTF-8 with BOM UTF-16BE Character Set ~~~~~~~~~~~~~~~~~~~~~~ 1. Create file ``utf-16be.txt``. 2. Add a line to the file and save it 3. Confirm that the file was saved as UTF-16BE UTF-16LE Character Set ~~~~~~~~~~~~~~~~~~~~~~ 1. Create file ``utf-16le.txt``. 2. Add a line to the file and save it 3. Confirm that the file was saved as UTF-16LE editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/end_of_line.rst000066400000000000000000000023341332662504700260220ustar00rootroot00000000000000Tests for End of Line Property ============================== The following tests are for the ``end_of_line`` EditorConfig property. Verifying Newline Style ----------------------- The style of newlines in a file can be verified with the ``file`` command. Verifying LF newlines: ``file test_files/lf.txt`` should return something like: test_files/lf.txt: ASCII text ``file test_files/crlf.txt`` should return something like: test_files/crlf.txt: ASCII text, with CRLF line terminators ``file test_files/cr.txt`` should return something like: test_files/cr.txt: ASCII text, with CR line terminators Tests for Newlines ------------------ To ensure that the newlines added to files are not affected by the newlines already present in the files, new files should be created. Unix-style Newlines ~~~~~~~~~~~~~~~~~~~ 1. Create file ``lf.txt``. 2. Add two lines to the the file and save it. 3. Confirm that new lines use LF Windows-style Newlines ~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``crlf.txt``. 2. Add a new line to the end of the file and save it. 3. Confirm that new lines use CRLF Old Mac-style Newlines ~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``cr.txt``. 2. Add a new line to the end of the file and save it. 3. Confirm that new lines use CR editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/indentation.rst000066400000000000000000000050671332662504700261030ustar00rootroot00000000000000Tests for Indentation Properties ================================ The following tests are for ``indent_style``, ``indent_size``, and ``tab_width`` EditorConfig properties. Space-based indentation ----------------------- The following tests are for space-based indentation (``indent_style = space``). 3-space indentation ~~~~~~~~~~~~~~~~~~~ 1. Open ``3_space.txt``. 2. Add a new line to the end of the file and indent it twice. 3. Confirm that new line is indented 6 spaces. 4. Confirm that mixed indentation on first line of file is indented 6 columns. 4-space indentation with tab width of 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``4_space.py``. 2. Add a new line of code to the end of the file and indent it once. 3. Confirm that new last line is indented with 4 spaces. 4. Add a second new line of code to the end of the file and indent it twice. 5. Confirm that new last line is indented with 8 spaces. 6. Confirm that indentation on third line of file uses a single 8 column tab. Space-based indentation with no size specified ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``space.txt``. 2. Confirm that no errors occur and EditorConfig file is read properly. 3. Add a new line of text to the end of the file and indent it once. 4. Confirm that new last line is indented with spaces. 5. Confirm that new last line indentation is the same size as the first line. Tab-based indentation ----------------------- The following tests are for tab-based indentation (``indent_style = tab``). Tab-based indentation with no size specified ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``tab.txt``. 2. Confirm that no errors occur and EditorConfig file is read properly. 3. Add a new line of text to the end of the file and indent it once. 4. Confirm that new last line is indented with a single tab. Tab-based indentation with size of 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``4_tab.txt``. 2. Confirm that no errors occur and EditorConfig file is read properly. 3. Add a new line of text to the end of the file and indent it once. 4. Confirm that new last line is indented with a single tab. Tab-based indentation with size of 4 and tab width of 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Open ``4_tab_width_of_8.txt``. 2. Confirm that no errors occur and EditorConfig file is read properly. 3. Add a new line of text to the end of the file and indent it once. 4. Confirm that new last line is indented with 4 spaces. 5. Add a second new line of text to the end of the file and indent it twice. 6. Confirm that new last line is indented with a single tab. editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/insert_final_newline.rst000066400000000000000000000016271332662504700277630ustar00rootroot00000000000000Insert Final Newline Property ============================= The following tests are for the ``insert_final_newline`` EditorConfig property. Checking for Final Newline -------------------------- Files can be tested for a newline at the end with the ``file`` command. ``file test_files/with_newline.txt`` should return something like: test_files/with_newline.txt: ASCII text ``file test_files/without_newline.txt`` should return something like: test_files/without_newline.txt: ASCII text, with no line terminators Tests for Newline at end of File -------------------------------- Test for Newline ~~~~~~~~~~~~~~~~ 1. Create file with_newline.txt 2. Add a single line to the file and save the file 3. Confirm that file ends in a newline Test for No Newline ~~~~~~~~~~~~~~~~~~~ 1. Create file without_newline.txt 2. Add a single line to the file and save the file 3. Confirm that file does not end in a newline editorconfig-emacs-0.8.2/ert-tests/plugin-tests/tests/trim_trailing_whitespace.rst000066400000000000000000000012031332662504700306330ustar00rootroot00000000000000Trim Trailing Whitespace Property ================================= The following tests are for the ``trim_trailing_whitespace`` EditorConfig property. Finding Trailing Whitespace --------------------------- The following command can be used to locate lines with trailing whitespace in a file named file.txt: grep "[ \t]$" file.txt Trimming Whitespace ------------------- 1. Open trim.txt 2. Add a line to the file and save the file 3. Confirm that no lines end with whitespace Not Trimming Whitespace ----------------------- 1. Open no_trim.txt 2. Add a line to the file and save the file 3. Confirm that some lines end with whitespace