Subject: Re: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)

From: Juri Linkov <[email-masked]>
Date: Wed, 25 Mar 2020 22:39:59 +0200

>> (defun conf-guess-mode ()
>>   (funcall (conf--guess-mode)))
>
> That shouldn't be needed!
> [ I.e. the right fix should arrange for that not to be necessary.
>   I'm looking into it, thanks.  ]

BTW, I noticed another problem related to diff-syntax-fontify:
when diff-font-lock-syntax is customized to 'hunk-also',
and a patch displayed by Gnus contains a truncated
local variables list, e.g. only the first line

 ;; Local Variables:

is presented in diff context without the terminating
"End:" then opening such attachment patch raises the error:

   "Local variables list is not properly terminated"

Not sure if this is the right way to fix this, but it works:

diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 8171a58515..96baea8526 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2724,7 +2724,7 @@ diff-syntax-fontify-props
           (buffer-file-name file))
       ;; Don't run hooks that might assume buffer-file-name
       ;; really associates buffer with a file (bug#39190).
-      (delay-mode-hooks (set-auto-mode))
+      (delay-mode-hooks (ignore-errors (set-auto-mode)))
       ;; FIXME: Is this really worth the trouble?
       (when (and (fboundp 'generic-mode-find-file-hook)
                  (memq #'generic-mode-find-file-hook