瀏覽代碼

Implement editorconfig-auto-apply-mode

master
10sr 6 年之前
父節點
當前提交
789b8db7a4
簽署人: 10sr GPG 金鑰 ID: 7BEC428194130EB2
共有 2 個檔案被更改,包括 32 行新增0 行删除
  1. +2
    -0
      .editorconfig
  2. +30
    -0
      emacs.el

+ 2
- 0
.editorconfig 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存