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

From: Stefan Monnier <[email-masked]>
Date: Wed, 19 Feb 2020 08:20:11 -0500

> 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.

        Stefan

> diff --git a/lisp/files.el b/lisp/files.el
> index 683f4a8ce7..3e1cf5e526 100644
> --- a/lisp/files.el
> +++ b/lisp/files.el
> @@ -2813,7 +2813,7 @@ auto-mode-alist
>       ("/config\\.\\(?:bat\\|log\\)\\'" . fundamental-mode)
>       ("/\\.\\(authinfo\\|netrc\\)\\'" . authinfo-mode)
>       ;; Windows candidates may be opened case sensitively on Unix
> -     ("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-mode)
> +     ("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-guess-mode)
>       ("\\.la\\'" . conf-unix-mode)
>       ("\\.ppd\\'" . conf-ppd-mode)
>       ("java.+\\.conf\\'" . conf-javaprop-mode)
> @@ -2822,15 +2822,15 @@ auto-mode-alist
>       ("\\.desktop\\'" . conf-desktop-mode)
>       ("/\\.redshift.conf\\'" . conf-windows-mode)
>       ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
> -     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
> +     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-guess-mode)
>       ;; ChangeLog.old etc.  Other change-log-mode entries are above;
>       ;; this has lower priority to avoid matching changelog.sgml etc.
>       ("[cC]hange[lL]og[-.][-0-9a-z]+\\'" . change-log-mode)
>       ;; either user's dot-files or under /etc or some such
> -     ("/\\.?\\(?:gitconfig\\|gnokiirc\\|hgrc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
> +     ("/\\.?\\(?:gitconfig\\|gnokiirc\\|hgrc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-guess-mode)
>       ;; alas not all ~/.*rc files are like this
> -     ("/\\.\\(?:asound\\|enigma\\|fetchmail\\|gltron\\|gtk\\|hxplayer\\|mairix\\|mbsync\\|msmtp\\|net\\|neverball\\|nvidia-settings-\\|offlineimap\\|qt/.+\\|realplayer\\|reportbug\\|rtorrent\\.\\|screen\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-mode)
> -     ("/\\.\\(?:gdbtkinit\\|grip\\|mpdconf\\|notmuch-config\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'" . conf-mode)
> +     ("/\\.\\(?:asound\\|enigma\\|fetchmail\\|gltron\\|gtk\\|hxplayer\\|mairix\\|mbsync\\|msmtp\\|net\\|neverball\\|nvidia-settings-\\|offlineimap\\|qt/.+\\|realplayer\\|reportbug\\|rtorrent\\.\\|screen\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-guess-mode)
> +     ("/\\.\\(?:gdbtkinit\\|grip\\|mpdconf\\|notmuch-config\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'" . conf-guess-mode)
>       ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . conf-xdefaults-mode)
>       ("/X11.+app-defaults/\\|\\.ad\\'" . conf-xdefaults-mode)
>       ("/X11.+locale/.+/Compose\\'" . conf-colon-mode)
> @@ -2920,7 +2920,7 @@ conf-mode-maybe
>  	  (goto-char (point-min))
>  	  (looking-at "<\\?xml \\|<!-- \\|<!DOCTYPE ")))
>        (xml-mode)
> -    (conf-mode)))
> +    (conf-guess-mode)))
>  
>  (defvar interpreter-mode-alist
>    ;; Note: The entries for the modes defined in cc-mode.el (awk-mode