aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Baugh2024-03-16 17:11:24 +0000
committerEli Zaretskii2024-03-23 19:07:49 +0200
commitabc2d39e0102f8bb554d89da3c0ffe57188220ff (patch)
tree46e800583c4356def8ca045b459b2206a059f55d
parent8d7a3ed3495968fd3e95a6126e7c23e25b7c495f (diff)
downloademacs-abc2d39e0102f8bb554d89da3c0ffe57188220ff.tar.gz
emacs-abc2d39e0102f8bb554d89da3c0ffe57188220ff.zip
Use 'regexp-opt' in 'dired-omit-regexp'
In my benchmarking, for large dired buffers, using 'regexp-opt' provides around a 3x speedup in omitting. 'regexp-opt' takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase 'dired-omit-size-limit' by 3x. Also, document 'dired-omit-size-limit' better. * doc/misc/dired-x.texi (Omitting Variables): Document 'dired-omit-size-limit'. * etc/NEWS: Announce increase of 'dired-omit-size-limit'. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use 'regexp-opt'. (Bug#69775) (dired-omit-size-limit): Increase and improve docs.
-rw-r--r--doc/misc/dired-x.texi9
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/dired-x.el26
3 files changed, 35 insertions, 6 deletions
diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi
index 4cad016a0f6..726b6653d0d 100644
--- a/doc/misc/dired-x.texi
+++ b/doc/misc/dired-x.texi
@@ -346,6 +346,15 @@ only match against the non-directory part of the file name. Set it to
346match the file name relative to the buffer's top-level directory. 346match the file name relative to the buffer's top-level directory.
347@end defvar 347@end defvar
348 348
349@defvar dired-omit-size-limit
350If non-@code{nil}, @code{dired-omit-mode} will be effectively disabled
351in directories whose listing has size (in bytes) larger than the value
352of this option. Since omitting can be slow for very large directories,
353this avoids having to wait before seeing the directory. This variable
354is ignored when @code{dired-omit-mode} is called interactively, such as
355by @code{C-x M-o}, so you can still enable omitting in the directory
356after the initial display.
357
349@cindex omitting additional files 358@cindex omitting additional files
350@defvar dired-omit-marker-char 359@defvar dired-omit-marker-char
351Temporary marker used by Dired to implement omitting. Should never be used 360Temporary marker used by Dired to implement omitting. Should never be used
diff --git a/etc/NEWS b/etc/NEWS
index f4b4c30855c..e9cb455aa40 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -705,6 +705,12 @@ marked or clicked on files according to the OS conventions. For
705example, on systems supporting XDG, this runs 'xdg-open' on the 705example, on systems supporting XDG, this runs 'xdg-open' on the
706files. 706files.
707 707
708*** The default value of 'dired-omit-size-limit' was increased.
709After performance improvements to omitting in large directories, the new
710default value is 300k, up from 100k. This means 'dired-omit-mode' will
711omit files in directories whose directory listing is up to 300 kilobytes
712in size.
713
708+++ 714+++
709*** 'dired-listing-switches' handles connection-local values if exist. 715*** 'dired-listing-switches' handles connection-local values if exist.
710This allows to customize different switches for different remote machines. 716This allows to customize different switches for different remote machines.
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 62fdd916e69..753d3054d2f 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -77,12 +77,17 @@ files not writable by you are visited read-only."
77 (other :tag "non-writable only" if-file-read-only)) 77 (other :tag "non-writable only" if-file-read-only))
78 :group 'dired-x) 78 :group 'dired-x)
79 79
80(defcustom dired-omit-size-limit 100000 80(defcustom dired-omit-size-limit 300000
81 "Maximum size for the \"omitting\" feature. 81 "Maximum buffer size for `dired-omit-mode'.
82
83Omitting will be disabled if the directory listing exceeds this size in
84bytes. This variable is ignored when `dired-omit-mode' is called
85interactively.
86
82If nil, there is no maximum size." 87If nil, there is no maximum size."
83 :type '(choice (const :tag "no maximum" nil) integer) 88 :type '(choice (const :tag "no maximum" nil) integer)
84 :group 'dired-x 89 :group 'dired-x
85 :version "29.1") 90 :version "30.1")
86 91
87(defcustom dired-omit-case-fold 'filesystem 92(defcustom dired-omit-case-fold 'filesystem
88 "Determine whether \"omitting\" patterns are case-sensitive. 93 "Determine whether \"omitting\" patterns are case-sensitive.
@@ -506,14 +511,23 @@ status message."
506 (re-search-forward dired-re-mark nil t)))) 511 (re-search-forward dired-re-mark nil t))))
507 count))) 512 count)))
508 513
514(defvar dired-omit--extension-regexp-cache
515 nil
516 "A cache of `regexp-opt' applied to `dired-omit-extensions'.
517
518This is a cons whose car is a list of strings and whose cdr is a
519regexp produced by `regexp-opt'.")
520
509(defun dired-omit-regexp () 521(defun dired-omit-regexp ()
522 (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache))
523 (setq dired-omit--extension-regexp-cache
524 (cons dired-omit-extensions (regexp-opt dired-omit-extensions))))
510 (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") 525 (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "")
511 (if (and dired-omit-files dired-omit-extensions) "\\|" "") 526 (if (and dired-omit-files dired-omit-extensions) "\\|" "")
512 (if dired-omit-extensions 527 (if dired-omit-extensions
513 (concat ".";; a non-extension part should exist 528 (concat ".";; a non-extension part should exist
514 "\\(" 529 (cdr dired-omit--extension-regexp-cache)
515 (mapconcat 'regexp-quote dired-omit-extensions "\\|") 530 "$")
516 "\\)$")
517 ""))) 531 "")))
518 532
519;; Returns t if any work was done, nil otherwise. 533;; Returns t if any work was done, nil otherwise.