GNU bug report logs - #40332
28.0.50; dired-readin binds inhibit-modification-hooks

Previous Next

Package: emacs;

Reported by: Štěpán Němec <stepnem <at> gmail.com>

Date: Mon, 30 Mar 2020 19:20:01 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 28.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 40332 in the body.
You can then email your comments to 40332 AT debbugs.gnu.org in the normal way.

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#40332; Package emacs. (Mon, 30 Mar 2020 19:20:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Štěpán Němec <stepnem <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 30 Mar 2020 19:20:01 GMT) Full text and rfc822 format available.

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

From: Štěpán Němec <stepnem <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; dired-readin binds inhibit-modification-hooks
Date: Mon, 30 Mar 2020 21:20:04 +0200
`dired-readin' binds `inhibit-modification-hooks' to t, so the buffer
changes caused by populating dired buffers are not noticeable in
`after-change-functions'.

A practical example of the problem:

https://gitlab.com/stepnem/stripes-el/-/issues/1#note_309176403

Related discussion:

https://lists.gnu.org/archive/html/emacs-devel/2020-03/msg00921.html

In GNU Emacs 28.0.50 (build 16, x86_64-pc-linux-gnu, GTK+ Version 3.24.14, cairo version 1.17.3)
 of 2020-03-28 built on lenora
Repository revision: e27b8882e3969412876561af8fd30144820ec81a
Repository branch: master

-- 
Štěpán




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Mon, 30 Mar 2020 19:48:02 GMT) Full text and rfc822 format available.

Notification sent to Štěpán Němec <stepnem <at> gmail.com>:
bug acknowledged by developer. (Mon, 30 Mar 2020 19:48:02 GMT) Full text and rfc822 format available.

Message #10 received at 40332-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Štěpán Němec <stepnem <at> gmail.com>
Cc: 40332-done <at> debbugs.gnu.org, Yuan Fu <casouri <at> gmail.com>
Subject: Re: bug#40332: 28.0.50; dired-readin binds inhibit-modification-hooks
Date: Mon, 30 Mar 2020 15:47:17 -0400
Version: 28.1

> `dired-readin' binds `inhibit-modification-hooks' to t, so the buffer
> changes caused by populating dired buffers are not noticeable in
> `after-change-functions'.

Indeed, thanks.  I just installed into `master` the patch below which
should fix this problem.

Can you confirm it works for you?


        Stefan


diff --git a/lisp/dired.el b/lisp/dired.el
index b66bb03471..d58c37be2f 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1208,15 +1208,11 @@ dired-readin
 
   ;; default-directory and dired-actual-switches must be buffer-local
   ;; and initialized by now.
-  (let (dirname
-	;; This makes read-in much faster.
-	;; In particular, it prevents the font lock hook from running
-	;; until the directory is all read in.
-	(inhibit-modification-hooks t))
-    (if (consp dired-directory)
-	(setq dirname (car dired-directory))
-      (setq dirname dired-directory))
-    (setq dirname (expand-file-name dirname))
+  (let ((dirname
+	 (expand-file-name
+	  (if (consp dired-directory)
+	      (car dired-directory)
+	    dired-directory))))
     (save-excursion
       ;; This hook which may want to modify dired-actual-switches
       ;; based on dired-directory, e.g. with ange-ftp to a SysV host
@@ -1226,17 +1222,25 @@ dired-readin
 	  (setq buffer-undo-list nil))
       (setq-local file-name-coding-system
                   (or coding-system-for-read file-name-coding-system))
-      (let ((inhibit-read-only t)
-	    ;; Don't make undo entries for readin.
-	    (buffer-undo-list t))
-	(widen)
-	(erase-buffer)
-	(dired-readin-insert))
-      (goto-char (point-min))
-      ;; Must first make alist buffer local and set it to nil because
-      ;; dired-build-subdir-alist will call dired-clear-alist first
-      (setq-local dired-subdir-alist nil)
-      (dired-build-subdir-alist)
+      (widen)
+      ;; We used to bind `inhibit-modification-hooks' to try and speed up
+      ;; execution, in particular, to prevent the font-lock hook from running
+      ;; until the directory is all read in.
+      ;; I strongly suspect that this was only useful in Emacs<21, because
+      ;; jit-lock made it a non-issue.
+      ;; Nevertheless, I used `combine-change-calls' which provides the
+      ;; same performance advantages, just in case.
+      (combine-change-calls (point-min) (point-max)
+	(let ((inhibit-read-only t)
+	      ;; Don't make undo entries for readin.
+	      (buffer-undo-list t))
+	  (erase-buffer)
+	  (dired-readin-insert))
+	(goto-char (point-min))
+	;; Must first make alist buffer local and set it to nil because
+	;; dired-build-subdir-alist will call dired-clear-alist first
+	(setq-local dired-subdir-alist nil)
+	(dired-build-subdir-alist))
       (let ((attributes (file-attributes dirname)))
 	(if (eq (car attributes) t)
 	    (set-visited-file-modtime (file-attribute-modification-time





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40332; Package emacs. (Mon, 30 Mar 2020 20:04:01 GMT) Full text and rfc822 format available.

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

From: Štěpán Němec <stepnem <at> gmail.com>
To: monnier <at> iro.umontreal.ca
Cc: Yuan Fu <casouri <at> gmail.com>, 40332 <at> debbugs.gnu.org
Subject: Re: bug#40332: 28.0.50; dired-readin binds inhibit-modification-hooks
Date: Mon, 30 Mar 2020 22:03:30 +0200
On Mon, 30 Mar 2020 15:47:17 -0400
Stefan Monnier wrote:

> I just installed into `master` the patch below which should fix this
> problem.
>
> Can you confirm it works for you?

Confirmed, thank you!

-- 
Štěpán




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40332; Package emacs. (Tue, 31 Mar 2020 14:41:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: casouri <at> gmail.com, stepnem <at> gmail.com, 40332 <at> debbugs.gnu.org
Subject: Re: bug#40332: 28.0.50; dired-readin binds inhibit-modification-hooks
Date: Tue, 31 Mar 2020 17:40:31 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Mon, 30 Mar 2020 15:47:17 -0400
> Cc: 40332-done <at> debbugs.gnu.org, Yuan Fu <casouri <at> gmail.com>
> 
> +      ;; We used to bind `inhibit-modification-hooks' to try and speed up
> +      ;; execution, in particular, to prevent the font-lock hook from running
> +      ;; until the directory is all read in.
> +      ;; I strongly suspect that this was only useful in Emacs<21, because
> +      ;; jit-lock made it a non-issue.
> +      ;; Nevertheless, I used `combine-change-calls' which provides the
> +      ;; same performance advantages, just in case.

FWIW, according to "git log", the change which introduced
inhibit-modification-hooks was made by RMS in Dec 2008, so it's
unlikely that had anything to do with Emacs before v21.  Maybe we
should augment that part of the comment?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#40332; Package emacs. (Tue, 31 Mar 2020 15:14:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, stepnem <at> gmail.com, 40332 <at> debbugs.gnu.org
Subject: Re: bug#40332: 28.0.50; dired-readin binds inhibit-modification-hooks
Date: Tue, 31 Mar 2020 11:13:27 -0400
>> +      ;; We used to bind `inhibit-modification-hooks' to try and speed up
>> +      ;; execution, in particular, to prevent the font-lock hook from running
>> +      ;; until the directory is all read in.
>> +      ;; I strongly suspect that this was only useful in Emacs<21, because
>> +      ;; jit-lock made it a non-issue.
>> +      ;; Nevertheless, I used `combine-change-calls' which provides the
>> +      ;; same performance advantages, just in case.
>
> FWIW, according to "git log", the change which introduced
> inhibit-modification-hooks was made by RMS in Dec 2008, so it's
> unlikely that had anything to do with Emacs before v21.  Maybe we
> should augment that part of the comment?

Sounds right, yes,


        Stefan





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Apr 2020 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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