branch: scratch/editorconfig-cc
commit be0973c580676249119adaabc8d2645abccac40c
Author: 10sr <8.slas...@gmail.com>
Commit: Stefan Monnier <monn...@iro.umontreal.ca>

    Fix for coding-system set when remote files do not exist (#250)
---
 editorconfig.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/editorconfig.el b/editorconfig.el
index d09329d504..29d0f4e6b3 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -630,6 +630,18 @@ F is that function, and FILENAME and ARGS are arguments 
passed to F."
           (when (and props
                      ;; filename has already been checked
                      (not (editorconfig--disabled-for-majormode major-mode)))
+            (when (and (file-remote-p filename)
+                       (not (local-variable-p 'buffer-file-coding-system))
+                       (not (file-exists-p filename))
+                       coding-system
+                       (not (eq coding-system
+                                'undecided)))
+              ;; When file path indicates it is a remote file and it actually
+              ;; does not exists, `buffer-file-coding-system' will not be set.
+              ;; (Does not call `insert-file-contents'?)
+              ;; For that case, explicitly set this value so that saving will 
be done
+              ;; with expected coding system.
+              (set-buffer-file-coding-system coding-system))
             (setq editorconfig-properties-hash props)
             (editorconfig-set-variables props)
             (condition-case err

Reply via email to