Browse Source

Implement editorconfig-auto-apply-mode

master
10sr 5 years ago
parent
commit
789b8db7a4
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
2 changed files with 32 additions and 0 deletions
  1. +2
    -0
      .editorconfig
  2. +30
    -0
      emacs.el

+ 2
- 0
.editorconfig View File

@@ -11,6 +11,8 @@ trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

a=bhoehoe

[*.js]
indent_size = 2



+ 30
- 0
emacs.el View File

@@ -1600,6 +1600,36 @@ This mode is a simplified version of `adoc-mode'."
(buffer-substring-no-properties (point-min) (point-max))))
))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; editorconfig-auto-apply

(define-minor-mode editorconfig-auto-apply-mode
"When saving .editorconfig file update buffer configs."
:global t
:lighter ""
(if editorconfig-auto-apply-mode
(add-hook 'after-save-hook
'editorconfig-auto-apply-mode--when-save)
(remove-hook 'after-save-hook
'editorconfig-auto-apply-mode--when-save)))

(defun editorconfig-auto-apply-mode--when-save ()
"Function run when editorconfig"
(when (eq major-mode
'editorconfig-conf-mode)
(let ((dir (file-name-directory buffer-file-name)))
(cl-dolist (buf (buffer-list))
(when (and (buffer-file-name buf)
(file-in-directory-p (buffer-file-name buf)
dir))
(with-current-buffer buf
(editorconfig-mode-apply)))))))

(editorconfig-auto-apply-mode 1)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun my-file-head (filename &optional n)
"Return list of first N lines of file FILENAME."
;; Work with japanese text?


Loading…
Cancel
Save