diff options
| author | Stefan Monnier | 2023-12-09 23:57:35 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2023-12-09 23:57:35 -0500 |
| commit | fe67c36cd9bb2967e0c2eca3d4a31c0950130eb7 (patch) | |
| tree | e8f46a9033e35d6c7860a5b5f6f8934f005f423e | |
| parent | 29957969e5199bdab5612af68e33b3989e4bbbd2 (diff) | |
| download | emacs-fe67c36cd9bb2967e0c2eca3d4a31c0950130eb7.tar.gz emacs-fe67c36cd9bb2967e0c2eca3d4a31c0950130eb7.zip | |
(dired): Remove `ls-lisp` advice
`ls-lisp` used to advise `dired` because `dired-insert-directory`
blindly used `insert-directory-program` (together with a shell)
in order to implement the "directory wildcard" expansion.
* lisp/dired.el (dired-insert-directory): Make the "directory wildcard"
code obey `files--use-insert-directory-program-p`, using
`file-expand-wildcards`.
* lisp/ls-lisp.el (ls-lisp--dired, ls-lisp-unload-function): Delete funs.
(dired): Don't advise any more.
| -rw-r--r-- | lisp/dired.el | 17 | ||||
| -rw-r--r-- | lisp/ls-lisp.el | 36 |
2 files changed, 10 insertions, 43 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index c11b107213b..ace4bbf5776 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -1696,7 +1696,7 @@ see `dired-use-ls-dired' for more details.") | |||
| 1696 | ;; Expand directory wildcards and fill file-list. | 1696 | ;; Expand directory wildcards and fill file-list. |
| 1697 | (let ((dir-wildcard (and (null file-list) wildcard | 1697 | (let ((dir-wildcard (and (null file-list) wildcard |
| 1698 | (insert-directory-wildcard-in-dir-p dir)))) | 1698 | (insert-directory-wildcard-in-dir-p dir)))) |
| 1699 | (cond (dir-wildcard | 1699 | (cond ((and dir-wildcard (files--use-insert-directory-program-p)) |
| 1700 | (setq switches (concat "-d " switches)) | 1700 | (setq switches (concat "-d " switches)) |
| 1701 | (let* ((default-directory (car dir-wildcard)) | 1701 | (let* ((default-directory (car dir-wildcard)) |
| 1702 | (script (format "%s %s %s" | 1702 | (script (format "%s %s %s" |
| @@ -1723,12 +1723,15 @@ see `dired-use-ls-dired' for more details.") | |||
| 1723 | ;; month names; but this should not be necessary any | 1723 | ;; month names; but this should not be necessary any |
| 1724 | ;; more, with the new value of | 1724 | ;; more, with the new value of |
| 1725 | ;; `directory-listing-before-filename-regexp'. | 1725 | ;; `directory-listing-before-filename-regexp'. |
| 1726 | (file-list | 1726 | ((or file-list dir-wildcard) |
| 1727 | (dolist (f file-list) | 1727 | (let ((default-directory |
| 1728 | (let ((beg (point))) | 1728 | (or (car dir-wildcard) default-directory))) |
| 1729 | (insert-directory f switches nil nil) | 1729 | (dolist (f (or file-list |
| 1730 | ;; Re-align fields, if necessary. | 1730 | (file-expand-wildcards (cdr dir-wildcard)))) |
| 1731 | (dired-align-file beg (point))))) | 1731 | (let ((beg (point))) |
| 1732 | (insert-directory f switches nil nil) | ||
| 1733 | ;; Re-align fields, if necessary. | ||
| 1734 | (dired-align-file beg (point)))))) | ||
| 1732 | (t | 1735 | (t |
| 1733 | (insert-directory dir switches wildcard (not wildcard)))) | 1736 | (insert-directory dir switches wildcard (not wildcard)))) |
| 1734 | ;; Quote certain characters, unless ls quoted them for us. | 1737 | ;; Quote certain characters, unless ls quoted them for us. |
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 141d1f32c09..c0a52d76a25 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el | |||
| @@ -449,36 +449,6 @@ not contain `d', so that a full listing is expected." | |||
| 449 | "Directory doesn't exist or is inaccessible" | 449 | "Directory doesn't exist or is inaccessible" |
| 450 | file)))))) | 450 | file)))))) |
| 451 | 451 | ||
| 452 | (declare-function dired-read-dir-and-switches "dired" (str)) | ||
| 453 | (declare-function dired-goto-next-file "dired" ()) | ||
| 454 | |||
| 455 | (defun ls-lisp--dired (orig-fun dir-or-list &optional switches) | ||
| 456 | (interactive (dired-read-dir-and-switches "")) | ||
| 457 | (unless dir-or-list | ||
| 458 | (setq dir-or-list default-directory)) | ||
| 459 | (if (consp dir-or-list) | ||
| 460 | (funcall orig-fun dir-or-list switches) | ||
| 461 | (let ((dir-wildcard (insert-directory-wildcard-in-dir-p | ||
| 462 | (expand-file-name dir-or-list)))) | ||
| 463 | (if (not dir-wildcard) | ||
| 464 | (funcall orig-fun dir-or-list switches) | ||
| 465 | (let* ((default-directory (car dir-wildcard)) | ||
| 466 | (files (file-expand-wildcards (cdr dir-wildcard))) | ||
| 467 | (dir (car dir-wildcard))) | ||
| 468 | (if files | ||
| 469 | (let ((inhibit-read-only t) | ||
| 470 | (buf | ||
| 471 | (apply orig-fun (nconc (list dir) files) (and switches (list switches))))) | ||
| 472 | (with-current-buffer buf | ||
| 473 | (save-excursion | ||
| 474 | (goto-char (point-min)) | ||
| 475 | (dired-goto-next-file) | ||
| 476 | (forward-line 0) | ||
| 477 | (insert " wildcard " (cdr dir-wildcard) "\n")))) | ||
| 478 | (user-error "No files matching wildcard"))))))) | ||
| 479 | |||
| 480 | (advice-add 'dired :around #'ls-lisp--dired) | ||
| 481 | |||
| 482 | (defun ls-lisp-sanitize (file-alist) | 452 | (defun ls-lisp-sanitize (file-alist) |
| 483 | "Sanitize the elements in FILE-ALIST. | 453 | "Sanitize the elements in FILE-ALIST. |
| 484 | Fixes any elements in the alist for directory entries whose file | 454 | Fixes any elements in the alist for directory entries whose file |
| @@ -866,12 +836,6 @@ All ls time options, namely c, t and u, are handled." | |||
| 866 | file-size) | 836 | file-size) |
| 867 | (format " %7s" (file-size-human-readable file-size)))) | 837 | (format " %7s" (file-size-human-readable file-size)))) |
| 868 | 838 | ||
| 869 | (defun ls-lisp-unload-function () | ||
| 870 | "Unload ls-lisp library." | ||
| 871 | (advice-remove 'dired #'ls-lisp--dired) | ||
| 872 | ;; Continue standard unloading. | ||
| 873 | nil) | ||
| 874 | |||
| 875 | (defun ls-lisp--sanitize-switches (switches) | 839 | (defun ls-lisp--sanitize-switches (switches) |
| 876 | "Convert long options of GNU \"ls\" to their short form. | 840 | "Convert long options of GNU \"ls\" to their short form. |
| 877 | Conversion is done only for flags supported by ls-lisp. | 841 | Conversion is done only for flags supported by ls-lisp. |