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 23:48:00 +0200

>> is presented in diff context without the terminating
>> "End:" then opening such attachment patch raises the error:
>>
>>    "Local variables list is not properly terminated"
>
> Really?  AFAICT the code does:
>
> 		  (unless (let ((case-fold-search t))
> 			    (re-search-forward
> 			     (concat prefix "[ \t]*End:[ \t]*" suffix)
> 			     nil t))
> 		    ;; This used to be an error, but really all it means is
> 		    ;; that this may simply not be a local-variables section,
> 		    ;; so just ignore it.
> 		    (message "Local variables list is not properly terminated"))
>
> so it shouldn't signal an error but just emit a message.

Sorry, actually this is what is displayed in the echo area after I added
ignore-errors.  But before adding ignore-errors, there was such backtrace:

Debugger entered--Lisp error: (error "Malformed local variable line: \"Local Variables:\"")
  signal(error ("Malformed local variable line: \"Local Variables:\""))
  error("Malformed local variable line: %S" "Local Variables:")
  hack-local-variables(t)
  set-auto-mode()
  (let ((delay-mode-hooks t)) (set-auto-mode))
  (progn (make-local-variable 'delay-mode-hooks) (let ((delay-mode-hooks t)) (set-auto-mode)))
  diff-syntax-fontify-props(#("a/lisp/dired-aux.el" ...
  diff-syntax-fontify-hunk(136 1334 t)
  diff-syntax-fontify(136 1334)
  diff--iterate-hunks(3750 #f(compiled-function (beg end) #<bytecode 0x877598e526a1ebd>))
  diff--font-lock-syntax(3750)
  font-lock-fontify-keywords-region(1 3750 nil)
  font-lock-default-fontify-region(1 3750 nil)
  font-lock-fontify-region(1 3750)
  font-lock-ensure()
  mm-display-inline-fontify(...
  mm-display-patch-inline(...
  mm-display-inline(...
  gnus-mime-display-single(...
  gnus-mime-display-part(...
  gnus-mime-display-mixed(...
  gnus-mime-display-part(...
  gnus-display-mime()
  gnus-article-prepare-display()
  gnus-article-prepare(165466 nil)
  gnus-summary-display-article(165466 nil)
  gnus-summary-select-article(nil nil pseudo)
  gnus-summary-scroll-up(1)
  funcall-interactively(gnus-summary-scroll-up 1)
  call-interactively(gnus-summary-scroll-up nil nil)
  command-execute(gnus-summary-scroll-up)

>> Not sure if this is the right way to fix this, but it works:
>
> I think we should try and arrange for errors to really be "not normal",
> and then use `with-demoted-errors`, yes.
>
> But w.r.t file-local variables and diff-hunk, I think obeying "file-local
> variables" doesn't make much sense when we only have a hunk to go on
> since it's more common for the hunk not to include the actual file-local
> vars, so if we find something it's likely to be a false-positive.

I'll try to set enable-local-variables to nil in case of HUNK-ONLY.