GNU bug report logs - #62749
28.2; Emacs keeps opening related file from vc-diff buffer

Previous Next

Package: emacs;

Reported by: Oleksandr Gavenko <gavenkoa <at> gmail.com>

Date: Mon, 10 Apr 2023 12:12:01 UTC

Severity: normal

Found in version 28.2

To reply to this bug, email your comments to 62749 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Mon, 10 Apr 2023 12:12:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleksandr Gavenko <gavenkoa <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 Apr 2023 12:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; Emacs keeps opening related file from vc-diff buffer
Date: Mon, 10 Apr 2023 15:11:24 +0300
In GNU Emacs 28.2 (build 1, x86_64-pc-cygwin)
 of 2022-09-16 built on fv-az140-985
Repository revision: 70134aa8264ded36d80248204b2ba43ae3d8f599

Whenever I open vc-diff buffer by "d" (log-view-diff) to read repository
history from "C-x v L" (vc-print-root-log) Emacs opens all files referenced by
diff.

The diff might be very big so:

* I end with lots of opened files that I need eventually close.
* Emacs pollutes recentf history - I don't want robotically opened file mixed
  with human opened files.
* Cygwin is slow (especially under antivirus supervision) file opening delays
  Emacs for many seconds.

Initially I asked for help in Emacs 27.1:

  https://emacs.stackexchange.com/questions/61760/lags-when-navigating-vc-root-diff-buffer/

and found workaround with:

  (setq diff-font-lock-syntax nil)

But with Emacs v28.2 it doesn't work, I asked for help once more:

  https://emacs.stackexchange.com/questions/76728/modern-emacs-keeps-opening-related-file-from-vc-diff-buffer

-- 
http://defun.work/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Mon, 10 Apr 2023 12:15:01 GMT) Full text and rfc822 format available.

Message #8 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: 62749 <at> debbugs.gnu.org
Subject: 28.2; Emacs keeps opening related file from vc-diff buffer
Date: Mon, 10 Apr 2023 15:14:40 +0300
[Message part 1 (text/plain, inline)]
Seems the problem is related to syntax highlighting parsers in diffs.

I don't need syntax highlighting at the cost of slowness and polluted
recentf history.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Mon, 10 Apr 2023 22:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Oleksandr Gavenko <gavenkoa <at> gmail.com>, 62749 <at> debbugs.gnu.org
Subject: Re: bug#62749: 28.2; Emacs keeps opening related file from vc-diff
 buffer
Date: Tue, 11 Apr 2023 01:23:19 +0300
Hi! Thanks for the report.

On 10/04/2023 15:11, Oleksandr Gavenko wrote:
> In GNU Emacs 28.2 (build 1, x86_64-pc-cygwin)
>   of 2022-09-16 built on fv-az140-985
> Repository revision: 70134aa8264ded36d80248204b2ba43ae3d8f599
> 
> Whenever I open vc-diff buffer by "d" (log-view-diff) to read repository
> history from "C-x v L" (vc-print-root-log) Emacs opens all files referenced by
> diff.
> 
> The diff might be very big so:
> 
> * I end with lots of opened files that I need eventually close.
> * Emacs pollutes recentf history - I don't want robotically opened file mixed
>    with human opened files.
> * Cygwin is slow (especially under antivirus supervision) file opening delays
>    Emacs for many seconds.
> 
> Initially I asked for help in Emacs 27.1:
> 
>    https://emacs.stackexchange.com/questions/61760/lags-when-navigating-vc-root-diff-buffer/
> 
> and found workaround with:
> 
>    (setq diff-font-lock-syntax nil)

This workaround should help, in particular to improve performance under 
Cygwin.

The thing about opened files is quite odd, though: 
diff-syntax-fontify-hunk does not visit any new files. It either uses an 
existing buffer, or fetches file contents using insert-file-contents, or 
calls vc-find-revision-no-save which, again, inserts the previous' 
revision file contents into the provided buffer, without visiting a file.

Perhaps you could edebug diff-syntax-fontify-hunk to find the exact 
place where a file is visited (and added to recentf), if that indeed 
happens.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Sun, 14 May 2023 11:01:02 GMT) Full text and rfc822 format available.

Message #14 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 62749 <at> debbugs.gnu.org
Subject: Re: bug#62749: 28.2;
 Emacs keeps opening related file from vc-diff buffer
Date: Sun, 14 May 2023 13:59:49 +0300
[Message part 1 (text/plain, inline)]
After bisecting my long .emacs config I pinpointed the culprit:

(which-func-mode 1)

During the movement through a diff buffer this mode loads corresponding
files:

  if the cursor reaches a new hunk - the corresponding file is opened ((

This is done one by one file while I scroll down with the cursor.

Removing the line significantly improved performance during scromming in VC
diff buffer in Cygwin and no more new files opened!

I think which-function-mode is broken for diff-mode, the workaround for
those who wants this mode is to deal with:

(defcustom which-func-modes t
  ;; '(emacs-lisp-mode c-mode c++-mode objc-mode perl-mode cperl-mode
python-mode
  ;;               makefile-mode sh-mode fortran-mode f90-mode ada-mode
  ;;               diff-mode)
  "List of major modes for which Which Function mode should be used.
For other modes it is disabled.  If this is equal to t,
then Which Function mode is enabled in any major mode that supports it."

What are the next actions?

On Tue, Apr 11, 2023 at 1:23 AM Dmitry Gutov <dmitry <at> gutov.dev> wrote:

> Hi! Thanks for the report.
>
> On 10/04/2023 15:11, Oleksandr Gavenko wrote:
> > In GNU Emacs 28.2 (build 1, x86_64-pc-cygwin)
> >   of 2022-09-16 built on fv-az140-985
> > Repository revision: 70134aa8264ded36d80248204b2ba43ae3d8f599
> >
> > Whenever I open vc-diff buffer by "d" (log-view-diff) to read repository
> > history from "C-x v L" (vc-print-root-log) Emacs opens all files
> referenced by
> > diff.
> >
> > The diff might be very big so:
> >
> > * I end with lots of opened files that I need eventually close.
> > * Emacs pollutes recentf history - I don't want robotically opened file
> mixed
> >    with human opened files.
> > * Cygwin is slow (especially under antivirus supervision) file opening
> delays
> >    Emacs for many seconds.
> >
> > Initially I asked for help in Emacs 27.1:
> >
> >
> https://emacs.stackexchange.com/questions/61760/lags-when-navigating-vc-root-diff-buffer/
> >
> > and found workaround with:
> >
> >    (setq diff-font-lock-syntax nil)
>
> This workaround should help, in particular to improve performance under
> Cygwin.
>
> The thing about opened files is quite odd, though:
> diff-syntax-fontify-hunk does not visit any new files. It either uses an
> existing buffer, or fetches file contents using insert-file-contents, or
> calls vc-find-revision-no-save which, again, inserts the previous'
> revision file contents into the provided buffer, without visiting a file.
>
> Perhaps you could edebug diff-syntax-fontify-hunk to find the exact
> place where a file is visited (and added to recentf), if that indeed
> happens.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Mon, 15 May 2023 17:06:01 GMT) Full text and rfc822 format available.

Message #17 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Oleksandr Gavenko <gavenkoa <at> gmail.com>
Cc: Dmitry Gutov <dmitry <at> gutov.dev>, 62749 <at> debbugs.gnu.org
Subject: Re: bug#62749: 28.2; Emacs keeps opening related file from vc-diff
 buffer
Date: Mon, 15 May 2023 19:46:36 +0300
> After bisecting my long .emacs config I pinpointed the culprit:
>
> (which-func-mode 1)
>
> During the movement through a diff buffer this mode loads corresponding
> files:
>
>   if the cursor reaches a new hunk - the corresponding file is opened ((
>
> This is done one by one file while I scroll down with the cursor.
>
> Removing the line significantly improved performance during scromming in VC
> diff buffer in Cygwin and no more new files opened!

This is an interesting problem, I can reproduce it by
'M-x which-function-mode'.

> I think which-function-mode is broken for diff-mode, the workaround for
> those who wants this mode is to deal with:
>
> (defcustom which-func-modes t
>   ;; '(emacs-lisp-mode c-mode c++-mode objc-mode perl-mode cperl-mode python-mode
>   ;;               makefile-mode sh-mode fortran-mode f90-mode ada-mode
>   ;;               diff-mode)
>   "List of major modes for which Which Function mode should be used.
> For other modes it is disabled.  If this is equal to t,
> then Which Function mode is enabled in any major mode that supports it."
>
> What are the next actions?

Maybe 'diff-syntax-fontify' could have a similar list of minor modes
that should be ignored.  Then such a list should at least contain
'which-func-mode' by default.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Tue, 16 May 2023 11:47:02 GMT) Full text and rfc822 format available.

Message #20 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>, Oleksandr Gavenko <gavenkoa <at> gmail.com>
Cc: 62749 <at> debbugs.gnu.org
Subject: Re: bug#62749: 28.2; Emacs keeps opening related file from vc-diff
 buffer
Date: Tue, 16 May 2023 14:46:36 +0300
On 15/05/2023 19:46, Juri Linkov wrote:
>> After bisecting my long .emacs config I pinpointed the culprit:
>>
>> (which-func-mode 1)
>>
>> During the movement through a diff buffer this mode loads corresponding
>> files:
>>
>>    if the cursor reaches a new hunk - the corresponding file is opened ((
>>
>> This is done one by one file while I scroll down with the cursor.
>>
>> Removing the line significantly improved performance during scromming in VC
>> diff buffer in Cygwin and no more new files opened!
> This is an interesting problem, I can reproduce it by
> 'M-x which-function-mode'.
> 
>> I think which-function-mode is broken for diff-mode, the workaround for
>> those who wants this mode is to deal with:
>>
>> (defcustom which-func-modes t
>>    ;; '(emacs-lisp-mode c-mode c++-mode objc-mode perl-mode cperl-mode python-mode
>>    ;;               makefile-mode sh-mode fortran-mode f90-mode ada-mode
>>    ;;               diff-mode)
>>    "List of major modes for which Which Function mode should be used.
>> For other modes it is disabled.  If this is equal to t,
>> then Which Function mode is enabled in any major mode that supports it."
>>
>> What are the next actions?
> Maybe 'diff-syntax-fontify' could have a similar list of minor modes
> that should be ignored.  Then such a list should at least contain
> 'which-func-mode' by default.

Do you mean that it's not feasible to fix the behavior when 
which-func-mode is enabled?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62749; Package emacs. (Tue, 16 May 2023 16:53:02 GMT) Full text and rfc822 format available.

Message #23 received at 62749 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 62749 <at> debbugs.gnu.org, Oleksandr Gavenko <gavenkoa <at> gmail.com>
Subject: Re: bug#62749: 28.2; Emacs keeps opening related file from vc-diff
 buffer
Date: Tue, 16 May 2023 19:44:25 +0300
>>> After bisecting my long .emacs config I pinpointed the culprit:
>>>
>>> (which-func-mode 1)
>>
>> Maybe 'diff-syntax-fontify' could have a similar list of minor modes
>> that should be ignored.  Then such a list should at least contain
>> 'which-func-mode' by default.
>
> Do you mean that it's not feasible to fix the behavior when which-func-mode
> is enabled?

After debugging I realized it's not related to diff-font-lock-syntax.

The problem is that 'which-func-mode' is enabled in diff-mode.
'which-function' calls 'add-log-current-defun' that calls
'add-log-current-defun-function' that is 'diff-current-defun'
in diff-mode.  Finally, 'diff-find-source-location' visits
the source files without killing them afterwards.

I guess this is related to another annoying bug: after every commit need
to spend much time killing all buffers created by the commit command.




This bug report was last modified 345 days ago.

Previous Next


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