Showing with 378 additions and 298 deletions.
  1. +3 −4 Makefile
  2. +60 −62 README.md
  3. +4 −3 bin/editorconfig-el
  4. +10 −9 editorconfig-conf-mode.el
  5. +86 −42 editorconfig-core-handle.el
  6. +77 −85 editorconfig-core.el
  7. +2 −3 editorconfig-fnmatch.el
  8. +135 −80 editorconfig.el
  9. +0 −9 ert-tests/editorconfig-core.el
  10. +1 −1 ert-tests/plugin-tests
7 changes: 3 additions & 4 deletions Makefile
Expand Up @@ -14,8 +14,7 @@ TRAVIS_FILE = .travis.yml
BATCHFLAGS = -batch -q --no-site-file -L $(PROJECT_ROOT_DIR)

MAIN_SRC = editorconfig.el
SRCS = editorconfig.el editorconfig-core.el editorconfig-core-handle.el \
editorconfig-fnmatch.el
SRCS = $(wildcard $(PROJECT_ROOT_DIR)/*.el)
OBJS = $(SRCS:.el=.elc)

$(OBJS): %.elc: %.el
Expand Down Expand Up @@ -48,7 +47,7 @@ test-travis:

# ert test
test-ert: $(ERT_TESTS) $(OBJS)
git submodule update --init
git submodule init
$(EMACS) $(BATCHFLAGS) \
--eval "(setq debug-on-error t)" \
--eval "(require 'ert)" \
Expand All @@ -60,7 +59,7 @@ test-ert: $(ERT_TESTS) $(OBJS)

# Core test
core-test/CMakeLists.txt:
git submodule update --init
git submodule init

test-core: core-test/CMakeLists.txt $(OBJS)
cd $(PROJECT_ROOT_DIR)/core-test && \
Expand Down
122 changes: 60 additions & 62 deletions README.md
@@ -1,34 +1,24 @@
[![Build Status](https://travis-ci.org/editorconfig/editorconfig-emacs.svg?branch=master)](https://travis-ci.org/editorconfig/editorconfig-emacs)
[![MELPA](http://melpa.org/packages/editorconfig-badge.svg)](http://melpa.org/#/editorconfig)
[![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)


# EditorConfig Emacs Plugin

This is an [EditorConfig][] plugin for [Emacs](https://www.gnu.org/software/emacs/).
This is an [EditorConfig][] plugin for [Emacs][].

## Installation

Download the [EditorConfig C Core][] and follow the instructions in the README
and INSTALL files to install it.
## Setup

This plugin also has a built-in core library implemented in Emacs-Lisp, and
fallback to it when no core executable is found.

In either case, copy `.el` files in this repository to `~/.emacs.d/lisp`
and add the following to your `~/.emacs` file:
This package is available from [MELPA][] and [MELPA Stable][].
Install from there and enable global minor-mode `editorconfig-mode`:

```emacs-lisp
(add-to-list 'load-path "~/.emacs.d/lisp")
(require 'editorconfig)
(editorconfig-mode 1)
```

Alternatively, you can find the package available on
[MELPA](https://melpa.org/#/editorconfig) and [MELPA Stable](https://stable.melpa.org/#/editorconfig)
([The Marmalade package](http://marmalade-repo.org/packages/editorconfig) is deprecated).

Or if you use [**use-package**](https://www.emacswiki.org/emacs/UsePackage):
If you use [**use-package**][use-package], add the following to your
`init.el` file:

```emacs-lisp
(use-package editorconfig
Expand All @@ -37,6 +27,30 @@ Or if you use [**use-package**](https://www.emacswiki.org/emacs/UsePackage):
(editorconfig-mode 1))
```


To install manually, 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)
```

### Install a Core Program

This package requires a Core program.
The officially recommended one is [EditorConfig C Core][],
follow the instructions in the README and INSTALL files to install it.

Though using C Core is recommended, but this plugin also
includes a core library implemented in Emacs Lisp.
This plugin uses this as a fallback method when no core executable
is found, so it works out-of-the-box without explicitly installing
any other core program.



## Supported properties

Current Emacs plugin coverage for EditorConfig's [properties][]:
Expand Down Expand Up @@ -90,6 +104,12 @@ future updates. When both are specified, `file_type_ext` takes precedence.

## Customize

`editorconfig-emacs` provides some customize variables.

Here are some of these variables: for the full list of available variables,
type <kbd>M-x customize-group [RET] editorconfig [RET]</kbd>.


### `editorconfig-after-apply-functions`

(Formerly `editorconfig-custom-hooks`)
Expand All @@ -103,11 +123,12 @@ only blocks of `web-mode`: it can be achieved by adding following to your init.e

```emacs-lisp
(add-hook 'editorconfig-after-apply-functions
(lambda (hash) (setq web-mode-block-padding 0)))
(lambda (props) (setq web-mode-block-padding 0)))
```

You can also define your own custom properties and enable them here.


### `editorconfig-hack-properties-functions`

A list of function to alter property values before applying them.
Expand All @@ -128,6 +149,7 @@ overwrite \"indent_style\" property when current `major-mode` is a
```


### `editorconfig-indentation-alist`

Alist of indentation setting methods by modes.
Expand All @@ -141,71 +163,40 @@ add a pair of major-mode symbol and its indentation variables:
'(c-mode c-basic-offset))
```

You can also modify this variable with the command
<kbd>M-x customize-variable [RET] editorconfig-indentation-alist [RET]</kbd>.
For a bit more complicated cases please take a look at the docstring of this variable.

### `editorconfig-exec-path`

String of `editorconfig` executable name (command name or full path to
the executable).


### `editorconfig-get-properties-function`

Function to use to get EditorConfig properties.

For example, if you always want to use built-in core library instead
of any EditorConfig executable to get properties, add following to
your init.el:

``` emacs-lisp
(set-variable 'editorconfig-get-properties-function
#'editorconfig-core-get-properties-hash)
```

Possible known values are:

* `editorconfig-get-properties` (default)
* Use `editorconfig-get-properties-from-exec` when
`editorconfig-exec-path` executable is found, otherwise use
`editorconfig-core-get-properties-hash`
* `editorconfig-get-properties-from-exec`
* Get properties by executing EditorConfig executable specified in
`editorconfig-exec-path`
* `editorconfig-core-get-properties-hash`
* Always use built-in Emacs-Lisp implementation to get properties


### `editorconfig-trim-whitespaces-mode`

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'.
If set, enable/disable that 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 yo
only lines touched get trimmed. To use it, add following to your
init.el:

``` emacs-lisp
(setq editorconfig-trim-whitespaces-mode
'ws-butler-mode)
```

## Testing

Make and [CMake](https://cmake.org) must be installed to run the tests.
## 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

To run the tests:
Make and [CMake][] must be installed to run the tests
locally:

$ make test

## 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

## License

Expand All @@ -222,6 +213,13 @@ General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>.



[Emacs]: https://www.gnu.org/software/emacs/
[MELPA]: https://melpa.org/#/editorconfig
[MELPA Stable]: https://stable.melpa.org/#/editorconfig
[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
7 changes: 4 additions & 3 deletions bin/editorconfig-el
Expand Up @@ -5,7 +5,7 @@

;; editorconfig-el --- EditorConfig Core executable in Emacs Lisp

;; Copyright (C) 2011-2017 EditorConfig Team
;; Copyright (C) 2011-2019 EditorConfig Team

;; Author: EditorConfig Team <editorconfig@googlegroups.com>
;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
Expand Down Expand Up @@ -43,6 +43,7 @@
load-path)))

(require 'cl-lib)
(require 'editorconfig) ; For `editorconfig-version'
(require 'editorconfig-core)

(defconst editorconfig-bin-help-message
Expand Down Expand Up @@ -80,8 +81,8 @@ with required output."
(message editorconfig-bin-help-message)
(kill-emacs 0))
((-v --version)
(princ (format "EditorConfig-Core-EmacsLisp Version %s\n"
editorconfig-core-version))
(princ (format "EditorConfig-EmacsLisp Version %s\n"
(editorconfig-version)))
(kill-emacs 0))

(otherwise
Expand Down
19 changes: 10 additions & 9 deletions editorconfig-conf-mode.el
@@ -1,9 +1,8 @@
;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files
;;; editorconfig-conf-mode.el --- Major mode for editing .editorconfig files -*- lexical-binding: t -*-

;; Copyright (C) 2011-2017 EditorConfig Team
;; Copyright (C) 2011-2019 EditorConfig Team

;; Author: EditorConfig Team <editorconfig@googlegroups.com>
;; URL: https://github.com/editorconfig/editorconfig-emacs#readme

;; See
;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
Expand Down Expand Up @@ -74,16 +73,18 @@

;; Highlight all key values
(dolist (key-value key-value-list)
(add-to-list
'font-lock-value
(push
`(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value)
1 font-lock-constant-face)))
1 font-lock-constant-face)
font-lock-value
))
;; Highlight all key properties
(dolist (key-property key-property-list)
(add-to-list
'font-lock-value
(push
`(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property)
1 font-lock-builtin-face)))
1 font-lock-builtin-face)
font-lock-value
))

(conf-mode-initialize "#" font-lock-value)))

Expand Down