Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variable editorconfig-exclude-modes #78

Merged
merged 1 commit into from
Mar 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions editorconfig.el
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ NOTE: Only the **buffer local** value of VARIABLE will be set."
'editorconfig-indentation-alist
"0.5")

(defcustom editorconfig-exclude-modes ()
"List of major mode symbols not to apply properties."
:type '(repeat (symbol :tag "Major Mode"))
:group 'editorconfig)

(defvar editorconfig-properties-hash nil
"Hash object of EditorConfig properties for current buffer.
Set by `editorconfig-apply' and nil if that is not invoked in current buffer
Expand Down Expand Up @@ -378,7 +383,9 @@ It calls `editorconfig-get-properties-from-exec' if

;;;###autoload
(defun editorconfig-apply ()
"Apply EditorConfig properties for current buffer."
"Apply EditorConfig properties for current buffer.
This function ignores `editorconfig-exclude-modes' and always applies available
properties."
(interactive)
(when buffer-file-name
(condition-case err
Expand All @@ -404,15 +411,27 @@ It calls `editorconfig-get-properties-from-exec' if
". Styles will not be applied.")
:error)))))

(defun editorconfig-mode-apply ()
"Apply EditorConfig properties for current buffer.
This function do the job only when the major mode is not listed in
`editorconfig-exclude-modes'."
(when (and major-mode
(not (memq major-mode
editorconfig-exclude-modes)))
(editorconfig-apply)))

;;;###autoload
(define-minor-mode editorconfig-mode
"Toggle EditorConfig feature."
"Toggle EditorConfig feature.
When enabled EditorConfig properties will be applied to buffers when first
visiting files or changing major modes if the major mode is not listed in
`editorconfig-exclude-modes'."
:global t
:lighter ""
(dolist (hook '(after-change-major-mode-hook))
(if editorconfig-mode
(add-hook hook 'editorconfig-apply)
(remove-hook hook 'editorconfig-apply))))
(add-hook hook 'editorconfig-mode-apply)
(remove-hook hook 'editorconfig-mode-apply))))



Expand Down