GNU bug report logs - #39190
28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)

Previous Next

Package: emacs;

Reported by: Felician Nemeth <felician.nemeth <at> gmail.com>

Date: Sun, 19 Jan 2020 11:15:02 UTC

Severity: normal

Found in version 28.0.50

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Felician Nemeth <felician.nemeth <at> gmail.com>
Cc: 39190 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: bug#39190: 28.0.50; two buffers with same buffer-file-name (diff-syntax-fontify-props)
Date: Tue, 18 Feb 2020 02:06:48 +0200
>>> delay-mode-hooks was intended as the safest workaround to install in emacs-27.
>>
>> delay-mode-hooks is now in emacs-27.
>
> This makes the original problem disappear.  Thank you.

Unfortunately, this change broke diff-syntax font-lock of conf-space-mode -
font-lock from files in conf-space-mode is not displayed in diffs anymore.

First, these steps show how it used to work when set-auto-mode was called
from diff-syntax-fontify-props without wrapping in delay-mode-hooks macro:

- diff-syntax-fontify-props calls set-auto-mode
- in auto-mode-alist a file extension is associated with conf-mode-maybe
- conf-mode-maybe calls conf-mode
- conf-mode checks for the variable 'delay-mode-hooks':
- initially delay-mode-hooks is nil, so call conf-space-mode
- conf-space-mode calls its parent mode conf-mode again
- when conf-mode is called again, its delay-mode-hooks is t
  and it sets its mode variables.

Now the failure caused by wrapping (delay-mode-hooks (set-auto-mode))
in diff-syntax-fontify-props is because on the first call of conf-mode,
the variable 'delay-mode-hooks' is already t, not nil as it was before
the change.

All this due to such trick used in conf-mode with these comments:

(defun conf-mode ()
  ...
  ;; `conf-mode' plays two roles: it's the parent of several sub-modes
  ;; but it's also the function that chooses between those submodes.
  ;; To tell the difference between those two cases where the function
  ;; might be called, we check `delay-mode-hooks'.
  ;; (adopted from tex-mode.el)
  (if (not delay-mode-hooks)
      ;; try to guess sub-mode of conf-mode based on buffer content

So it detects the situation when define-derived-mode runs the parent
with delay-mode-hooks.

I have no idea what to do in this case.




This bug report was last modified 5 years and 83 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.