Subject: bug#22906: 24.5; eww SGML validate error

From: Simen Heggestøyl <[email-masked]>
Date: Wed, 07 Sep 2016 18:49:51 +0200

I can reproduce this on the current master branch (ec12c670).

The issue seems to be that `sgml-validate' assumes that the buffer is
visiting a file, which is not the case when you view a web page's source
from eww.

Maybe we could offer to save the buffer when it's not visiting a file?

diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 990c09b..b98db7e 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1109,8 +1109,10 @@ sgml-validate
 				  " "
 				  (shell-quote-argument
 				   (let ((name (buffer-file-name)))
-				     (and name
-					  (file-name-nondirectory name)))))))))
+                                     (unless name
+                                       (save-buffer)
+                                       (setq name (buffer-file-name)))
+				     (file-name-nondirectory name))))))))
   (setq sgml-saved-validate-command command)
   (save-some-buffers (not compilation-ask-about-save) nil)
   (compilation-start command))

-- Simen