bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-


From: Juri Linkov
Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)
Date: Thu, 20 Feb 2020 02:58:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> I tested this with additional patch that replaces `conf-mode` calls with
>> `conf-guess-mode`, and see that syntax font-lock now is fixed in diff-mode
>> on some conf files (not tested on all possible conf submodes).
>
> This said.  Using delay-mode-hooks in the diff-syntax driver is an ugly
> hack and is the real source of the problem, so splitting conf-mode into
> two is basically a way to work around the breakage introduced by the hack.

Indeed, but it seems it's too late to redesign this in the release
branch.  So unfontified conf-mode files in diff hunks is a trade-off
for not breaking the release.

As for changes in master, I tried something like this to use in
diff-syntax-fontify-props instead of direct set-auto-mode call:

(let ((buffer (make-indirect-buffer
               (current-buffer)
               (generate-new-buffer-name (buffer-name)))))
  (funcall
   (unwind-protect
       (with-current-buffer buffer
         (let ((buffer-file-name "/tmp/foo.el"))
           (set-auto-mode)
           major-mode))
     (kill-buffer buffer))))

It calls set-auto-mode in a temporary buffer.

Do you think this is the right direction?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]