From 5ed0b871ce40364a555eda5c6cef23529e6b6ac9 Mon Sep 17 00:00:00 2001 From: John Miller Date: Fri, 21 Apr 2017 20:29:19 -0500 Subject: [PATCH] ein-file.el: handle text encoding on windows Try to sanely decode text on windows sytems to avoid getting a buffer full of ^M EOL symbols when opening files through ein's notebooklist buffer. This doesn't appear to be necessary on Unix systems, and by extension I am going to assume it is also the same on Mac OS X. --- lisp/ein-file.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/ein-file.el b/lisp/ein-file.el index 0d67a5f..c339177 100644 --- a/lisp/ein-file.el +++ b/lisp/ein-file.el @@ -42,10 +42,16 @@ (with-current-buffer (get-buffer-create (ein:file-buffer-name (ein:$content-url-or-port content) (ein:$content-path content))) (setq ein:content-file-buffer--content content) - (insert (ein:$content-raw-content content)) + (let ((raw-content (ein:$content-raw-content content))) + (if (eql system-type 'windows-nt) + (insert (decode-coding-string raw-content 'utf-8)) + (insert raw-content))) (set-visited-file-name (buffer-name)) (set-auto-mode) - (add-hook 'write-contents-functions 'ein:content-file-save) + (add-hook 'write-contents-functions 'ein:content-file-save) ;; FIXME Brittle, will not work + ;; if user changes major mode. + (set-buffer-modified-p nil) + (goto-char (point-min)) (pop-to-buffer (buffer-name)))) (defun ein:content-file-save ()