From 6014a416b3e19b025694c7a7f32f3ac82db38834 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 30 Jun 2018 13:19:08 +0200 Subject: [PATCH] Fix read-only errors in magit rebase buffers Magit would refuse to abort/commit rebases due to delete-trailing-whitespace in write-file-functions, placed there by editorconfig. --- modules/tools/editorconfig/config.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/tools/editorconfig/config.el b/modules/tools/editorconfig/config.el index 82d4966f0..ab0892ed4 100644 --- a/modules/tools/editorconfig/config.el +++ b/modules/tools/editorconfig/config.el @@ -55,5 +55,12 @@ extension, try to guess one." (delq (assq mode editorconfig-indentation-alist) editorconfig-indentation-alist)) + (defun +editorconfig|disable-trim-whitespace-in-read-only-buffers (props) + "`delete-trailing-whitespace' can cause disruptive read-only errors. Prevent +it from being added to read-only buffers." + (when (and buffer-read-only (gethash 'trim_trailing_whitespace props)) + (remove-hook 'write-file-functions #'delete-trailing-whitespace :local))) + (add-hook 'editorconfig-custom-hooks #'+editorconfig|disable-trim-whitespace-in-read-only-buffers) + ;; (editorconfig-mode +1))