all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
@ 2023-04-10 12:11 Oleksandr Gavenko
  2023-04-10 12:14 ` Oleksandr Gavenko
  2023-04-10 22:23 ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Oleksandr Gavenko @ 2023-04-10 12:11 UTC (permalink / raw)
  To: 62749

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/





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-04-10 12:11 bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer Oleksandr Gavenko
@ 2023-04-10 12:14 ` Oleksandr Gavenko
  2023-04-10 22:23 ` Dmitry Gutov
  1 sibling, 0 replies; 7+ messages in thread
From: Oleksandr Gavenko @ 2023-04-10 12:14 UTC (permalink / raw)
  To: 62749

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 222 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-04-10 12:11 bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer Oleksandr Gavenko
  2023-04-10 12:14 ` Oleksandr Gavenko
@ 2023-04-10 22:23 ` Dmitry Gutov
  2023-05-14 10:59   ` Oleksandr Gavenko
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2023-04-10 22:23 UTC (permalink / raw)
  To: Oleksandr Gavenko, 62749

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-04-10 22:23 ` Dmitry Gutov
@ 2023-05-14 10:59   ` Oleksandr Gavenko
  2023-05-15 16:46     ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Oleksandr Gavenko @ 2023-05-14 10:59 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 62749

[-- Attachment #1: Type: text/plain, Size: 2717 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3568 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-05-14 10:59   ` Oleksandr Gavenko
@ 2023-05-15 16:46     ` Juri Linkov
  2023-05-16 11:46       ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2023-05-15 16:46 UTC (permalink / raw)
  To: Oleksandr Gavenko; +Cc: Dmitry Gutov, 62749

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-05-15 16:46     ` Juri Linkov
@ 2023-05-16 11:46       ` Dmitry Gutov
  2023-05-16 16:44         ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2023-05-16 11:46 UTC (permalink / raw)
  To: Juri Linkov, Oleksandr Gavenko; +Cc: 62749

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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer
  2023-05-16 11:46       ` Dmitry Gutov
@ 2023-05-16 16:44         ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2023-05-16 16:44 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 62749, Oleksandr Gavenko

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-16 16:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-10 12:11 bug#62749: 28.2; Emacs keeps opening related file from vc-diff buffer Oleksandr Gavenko
2023-04-10 12:14 ` Oleksandr Gavenko
2023-04-10 22:23 ` Dmitry Gutov
2023-05-14 10:59   ` Oleksandr Gavenko
2023-05-15 16:46     ` Juri Linkov
2023-05-16 11:46       ` Dmitry Gutov
2023-05-16 16:44         ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.