diff options
| author | Luc Teirlinck | 2004-06-06 02:26:46 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2004-06-06 02:26:46 +0000 |
| commit | f2260f48b09bc32ae620f26e797b85165152baf8 (patch) | |
| tree | b3b0df586766f37d5453d846d81cd009cede458f | |
| parent | 5553077c1d8e3231ea9570e27b2547aa423dce5b (diff) | |
| download | emacs-f2260f48b09bc32ae620f26e797b85165152baf8.tar.gz emacs-f2260f48b09bc32ae620f26e797b85165152baf8.zip | |
(dired-do-redisplay, dired-maybe-insert-subdir): Change interactive
default switches.
(dired-rename-subdir-2): Update `dired-switches-alist'.
(dired-insert-subdir, dired-kill-subdir):
Handle `dired-switches-alist'. Do not mark buffer modified.
(dired-insert-subdir-validate): Handle `dired-subdir-switches'.
(dired-insert-subdir-doinsert): Omit messages.
Handle `dired-subdir-switches'.
(dired-hide-subdir, dired-hide-all): Do not mark buffer modified.
| -rw-r--r-- | lisp/dired-aux.el | 126 |
1 files changed, 82 insertions, 44 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index b31d20782f3..db09fc57fb7 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -895,9 +895,15 @@ a prefix arg lets you edit the `ls' switches used for the new listing." | |||
| 895 | ;; Moves point if the next ARG files are redisplayed. | 895 | ;; Moves point if the next ARG files are redisplayed. |
| 896 | (interactive "P\np") | 896 | (interactive "P\np") |
| 897 | (if (and test-for-subdir (dired-get-subdir)) | 897 | (if (and test-for-subdir (dired-get-subdir)) |
| 898 | (dired-insert-subdir | 898 | (let* ((dir (dired-get-subdir)) |
| 899 | (dired-get-subdir) | 899 | (switches (cdr (assoc-string dir dired-switches-alist)))) |
| 900 | (if arg (read-string "Switches for listing: " dired-actual-switches))) | 900 | (dired-insert-subdir |
| 901 | dir | ||
| 902 | (when arg | ||
| 903 | (read-string "Switches for listing: " | ||
| 904 | (or switches | ||
| 905 | dired-subdir-switches | ||
| 906 | dired-actual-switches))))) | ||
| 901 | (message "Redisplaying...") | 907 | (message "Redisplaying...") |
| 902 | ;; message much faster than making dired-map-over-marks show progress | 908 | ;; message much faster than making dired-map-over-marks show progress |
| 903 | (dired-uncache | 909 | (dired-uncache |
| @@ -1207,9 +1213,10 @@ Special value `always' suppresses confirmation." | |||
| 1207 | (dired-advertise))))) | 1213 | (dired-advertise))))) |
| 1208 | 1214 | ||
| 1209 | (defun dired-rename-subdir-2 (elt dir to) | 1215 | (defun dired-rename-subdir-2 (elt dir to) |
| 1210 | ;; Update the headerline and dired-subdir-alist element of directory | 1216 | ;; Update the headerline and dired-subdir-alist element, as well as |
| 1211 | ;; described by alist-element ELT to reflect the moving of DIR to TO. | 1217 | ;; dired-switches-alist element, of directory described by |
| 1212 | ;; Thus, ELT describes either DIR itself or a subdir of DIR. | 1218 | ;; alist-element ELT to reflect the moving of DIR to TO. Thus, ELT |
| 1219 | ;; describes either DIR itself or a subdir of DIR. | ||
| 1213 | (save-excursion | 1220 | (save-excursion |
| 1214 | (let ((regexp (regexp-quote (directory-file-name dir))) | 1221 | (let ((regexp (regexp-quote (directory-file-name dir))) |
| 1215 | (newtext (directory-file-name to)) | 1222 | (newtext (directory-file-name to)) |
| @@ -1223,10 +1230,12 @@ Special value `always' suppresses confirmation." | |||
| 1223 | (if (re-search-forward regexp (match-end 1) t) | 1230 | (if (re-search-forward regexp (match-end 1) t) |
| 1224 | (replace-match newtext t t) | 1231 | (replace-match newtext t t) |
| 1225 | (error "Expected to find `%s' in headerline of %s" dir (car elt)))) | 1232 | (error "Expected to find `%s' in headerline of %s" dir (car elt)))) |
| 1226 | ;; Update buffer-local dired-subdir-alist | 1233 | ;; Update buffer-local dired-subdir-alist and dired-switches-alist |
| 1227 | (setcar elt | 1234 | (let ((cons (assoc-string (car elt) dired-switches-alist)) |
| 1228 | (dired-normalize-subdir | 1235 | (cur-dir (dired-normalize-subdir |
| 1229 | (dired-replace-in-string regexp newtext (car elt))))))) | 1236 | (dired-replace-in-string regexp newtext (car elt))))) |
| 1237 | (setcar elt cur-dir) | ||
| 1238 | (when cons (setcar cons cur-dir)))))) | ||
| 1230 | 1239 | ||
| 1231 | ;; The basic function for half a dozen variations on cp/mv/ln/ln -s. | 1240 | ;; The basic function for half a dozen variations on cp/mv/ln/ln -s. |
| 1232 | (defun dired-create-files (file-creator operation fn-list name-constructor | 1241 | (defun dired-create-files (file-creator operation fn-list name-constructor |
| @@ -1722,7 +1731,8 @@ This function takes some pains to conform to `ls -lR' output." | |||
| 1722 | (interactive | 1731 | (interactive |
| 1723 | (list (dired-get-filename) | 1732 | (list (dired-get-filename) |
| 1724 | (if current-prefix-arg | 1733 | (if current-prefix-arg |
| 1725 | (read-string "Switches for listing: " dired-actual-switches)))) | 1734 | (read-string "Switches for listing: " |
| 1735 | (or dired-subdir-switches dired-actual-switches))))) | ||
| 1726 | (let ((opoint (point))) | 1736 | (let ((opoint (point))) |
| 1727 | ;; We don't need a marker for opoint as the subdir is always | 1737 | ;; We don't need a marker for opoint as the subdir is always |
| 1728 | ;; inserted *after* opoint. | 1738 | ;; inserted *after* opoint. |
| @@ -1749,14 +1759,19 @@ This function takes some pains to conform to `ls -lR' output." | |||
| 1749 | (interactive | 1759 | (interactive |
| 1750 | (list (dired-get-filename) | 1760 | (list (dired-get-filename) |
| 1751 | (if current-prefix-arg | 1761 | (if current-prefix-arg |
| 1752 | (read-string "Switches for listing: " dired-actual-switches)))) | 1762 | (read-string "Switches for listing: " |
| 1763 | (or dired-subdir-switches dired-actual-switches))))) | ||
| 1753 | (setq dirname (file-name-as-directory (expand-file-name dirname))) | 1764 | (setq dirname (file-name-as-directory (expand-file-name dirname))) |
| 1754 | (dired-insert-subdir-validate dirname switches) | ||
| 1755 | (or no-error-if-not-dir-p | 1765 | (or no-error-if-not-dir-p |
| 1756 | (file-directory-p dirname) | 1766 | (file-directory-p dirname) |
| 1757 | (error "Attempt to insert a non-directory: %s" dirname)) | 1767 | (error "Attempt to insert a non-directory: %s" dirname)) |
| 1758 | (let ((elt (assoc dirname dired-subdir-alist)) | 1768 | (let ((elt (assoc dirname dired-subdir-alist)) |
| 1759 | switches-have-R mark-alist case-fold-search buffer-read-only) | 1769 | (cons (assoc-string dirname dired-switches-alist)) |
| 1770 | (modflag (buffer-modified-p)) | ||
| 1771 | (old-switches switches) | ||
| 1772 | switches-have-R mark-alist case-fold-search buffer-read-only) | ||
| 1773 | (and (not switches) cons (setq switches (cdr cons))) | ||
| 1774 | (dired-insert-subdir-validate dirname switches) | ||
| 1760 | ;; case-fold-search is nil now, so we can test for capital `R': | 1775 | ;; case-fold-search is nil now, so we can test for capital `R': |
| 1761 | (if (setq switches-have-R (and switches (string-match "R" switches))) | 1776 | (if (setq switches-have-R (and switches (string-match "R" switches))) |
| 1762 | ;; avoid duplicated subdirs | 1777 | ;; avoid duplicated subdirs |
| @@ -1767,9 +1782,23 @@ This function takes some pains to conform to `ls -lR' output." | |||
| 1767 | (dired-insert-subdir-newpos dirname)) ; else compute new position | 1782 | (dired-insert-subdir-newpos dirname)) ; else compute new position |
| 1768 | (dired-insert-subdir-doupdate | 1783 | (dired-insert-subdir-doupdate |
| 1769 | dirname elt (dired-insert-subdir-doinsert dirname switches)) | 1784 | dirname elt (dired-insert-subdir-doinsert dirname switches)) |
| 1770 | (if switches-have-R (dired-build-subdir-alist switches)) | 1785 | (when old-switches |
| 1786 | (if cons | ||
| 1787 | (setcdr cons switches) | ||
| 1788 | (push (cons dirname switches) dired-switches-alist))) | ||
| 1789 | (when switches-have-R | ||
| 1790 | (dired-build-subdir-alist switches) | ||
| 1791 | (dolist (cur-ass dired-subdir-alist) | ||
| 1792 | (let ((cur-dir (car cur-ass))) | ||
| 1793 | (and (dired-in-this-tree cur-dir dirname) | ||
| 1794 | (not (string= cur-dir dirname)) | ||
| 1795 | (let ((cur-cons (assoc-string cur-dir dired-switches-alist))) | ||
| 1796 | (if cur-cons | ||
| 1797 | (setcdr cur-cons switches) | ||
| 1798 | (push (cons cur-dir switches) dired-switches-alist))))))) | ||
| 1771 | (dired-initial-position dirname) | 1799 | (dired-initial-position dirname) |
| 1772 | (save-excursion (dired-mark-remembered mark-alist)))) | 1800 | (save-excursion (dired-mark-remembered mark-alist)) |
| 1801 | (restore-buffer-modified-p modflag))) | ||
| 1773 | 1802 | ||
| 1774 | ;; This is a separate function for dired-vms. | 1803 | ;; This is a separate function for dired-vms. |
| 1775 | (defun dired-insert-subdir-validate (dirname &optional switches) | 1804 | (defun dired-insert-subdir-validate (dirname &optional switches) |
| @@ -1777,17 +1806,18 @@ This function takes some pains to conform to `ls -lR' output." | |||
| 1777 | ;; Signal an error if invalid (e.g. user typed `i' on `..'). | 1806 | ;; Signal an error if invalid (e.g. user typed `i' on `..'). |
| 1778 | (or (dired-in-this-tree dirname (expand-file-name default-directory)) | 1807 | (or (dired-in-this-tree dirname (expand-file-name default-directory)) |
| 1779 | (error "%s: not in this directory tree" dirname)) | 1808 | (error "%s: not in this directory tree" dirname)) |
| 1780 | (if switches | 1809 | (let ((real-switches (or switches dired-subdir-switches))) |
| 1810 | (when real-switches | ||
| 1781 | (let (case-fold-search) | 1811 | (let (case-fold-search) |
| 1782 | (mapcar | 1812 | (mapcar |
| 1783 | (function | 1813 | (function |
| 1784 | (lambda (x) | 1814 | (lambda (x) |
| 1785 | (or (eq (null (string-match x switches)) | 1815 | (or (eq (null (string-match x real-switches)) |
| 1786 | (null (string-match x dired-actual-switches))) | 1816 | (null (string-match x dired-actual-switches))) |
| 1787 | (error "Can't have dirs with and without -%s switches together" | 1817 | (error |
| 1788 | x)))) | 1818 | "Can't have dirs with and without -%s switches together" x)))) |
| 1789 | ;; all switches that make a difference to dired-get-filename: | 1819 | ;; all switches that make a difference to dired-get-filename: |
| 1790 | '("F" "b"))))) | 1820 | '("F" "b")))))) |
| 1791 | 1821 | ||
| 1792 | (defun dired-alist-add (dir new-marker) | 1822 | (defun dired-alist-add (dir new-marker) |
| 1793 | ;; Add new DIR at NEW-MARKER. Sort alist. | 1823 | ;; Add new DIR at NEW-MARKER. Sort alist. |
| @@ -1855,16 +1885,15 @@ With optional arg REMEMBER-MARKS, return an alist of marked files." | |||
| 1855 | ;; Return the boundary of the inserted text (as list of BEG and END). | 1885 | ;; Return the boundary of the inserted text (as list of BEG and END). |
| 1856 | (save-excursion | 1886 | (save-excursion |
| 1857 | (let ((begin (point))) | 1887 | (let ((begin (point))) |
| 1858 | (message "Reading directory %s..." dirname) | ||
| 1859 | (let ((dired-actual-switches | 1888 | (let ((dired-actual-switches |
| 1860 | (or switches | 1889 | (or switches |
| 1890 | dired-subdir-switches | ||
| 1861 | (dired-replace-in-string "R" "" dired-actual-switches)))) | 1891 | (dired-replace-in-string "R" "" dired-actual-switches)))) |
| 1862 | (if (equal dirname (car (car (last dired-subdir-alist)))) | 1892 | (if (equal dirname (car (car (last dired-subdir-alist)))) |
| 1863 | ;; If doing the top level directory of the buffer, | 1893 | ;; If doing the top level directory of the buffer, |
| 1864 | ;; redo it as specified in dired-directory. | 1894 | ;; redo it as specified in dired-directory. |
| 1865 | (dired-readin-insert) | 1895 | (dired-readin-insert) |
| 1866 | (dired-insert-directory dirname dired-actual-switches nil nil t))) | 1896 | (dired-insert-directory dirname dired-actual-switches nil nil t))) |
| 1867 | (message "Reading directory %s...done" dirname) | ||
| 1868 | (list begin (point))))) | 1897 | (list begin (point))))) |
| 1869 | 1898 | ||
| 1870 | (defun dired-insert-subdir-doupdate (dirname elt beg-end) | 1899 | (defun dired-insert-subdir-doupdate (dirname elt beg-end) |
| @@ -2007,10 +2036,12 @@ marks the files listed in the subdirectory that point is in." | |||
| 2007 | Lower levels are unaffected." | 2036 | Lower levels are unaffected." |
| 2008 | ;; With optional REMEMBER-MARKS, return a mark-alist. | 2037 | ;; With optional REMEMBER-MARKS, return a mark-alist. |
| 2009 | (interactive) | 2038 | (interactive) |
| 2010 | (let ((beg (dired-subdir-min)) | 2039 | (let* ((beg (dired-subdir-min)) |
| 2011 | (end (dired-subdir-max)) | 2040 | (end (dired-subdir-max)) |
| 2012 | buffer-read-only cur-dir) | 2041 | (modflag (buffer-modified-p)) |
| 2013 | (setq cur-dir (dired-current-directory)) | 2042 | (cur-dir (dired-current-directory)) |
| 2043 | (cons (assoc-string cur-dir dired-switches-alist)) | ||
| 2044 | buffer-read-only) | ||
| 2014 | (if (equal cur-dir default-directory) | 2045 | (if (equal cur-dir default-directory) |
| 2015 | (error "Attempt to kill top level directory")) | 2046 | (error "Attempt to kill top level directory")) |
| 2016 | (prog1 | 2047 | (prog1 |
| @@ -2018,7 +2049,10 @@ Lower levels are unaffected." | |||
| 2018 | (delete-region beg end) | 2049 | (delete-region beg end) |
| 2019 | (if (eobp) ; don't leave final blank line | 2050 | (if (eobp) ; don't leave final blank line |
| 2020 | (delete-char -1)) | 2051 | (delete-char -1)) |
| 2021 | (dired-unsubdir cur-dir)))) | 2052 | (dired-unsubdir cur-dir) |
| 2053 | (when cons | ||
| 2054 | (setq dired-switches-alist (delete cons dired-switches-alist))) | ||
| 2055 | (restore-buffer-modified-p modflag)))) | ||
| 2022 | 2056 | ||
| 2023 | (defun dired-unsubdir (dir) | 2057 | (defun dired-unsubdir (dir) |
| 2024 | ;; Remove DIR from the alist | 2058 | ;; Remove DIR from the alist |
| @@ -2077,19 +2111,21 @@ Optional prefix arg is a repeat factor. | |||
| 2077 | Use \\[dired-hide-all] to (un)hide all directories." | 2111 | Use \\[dired-hide-all] to (un)hide all directories." |
| 2078 | (interactive "p") | 2112 | (interactive "p") |
| 2079 | (dired-hide-check) | 2113 | (dired-hide-check) |
| 2080 | (while (>= (setq arg (1- arg)) 0) | 2114 | (let ((modflag (buffer-modified-p))) |
| 2081 | (let* ((cur-dir (dired-current-directory)) | 2115 | (while (>= (setq arg (1- arg)) 0) |
| 2082 | (hidden-p (dired-subdir-hidden-p cur-dir)) | 2116 | (let* ((cur-dir (dired-current-directory)) |
| 2083 | (elt (assoc cur-dir dired-subdir-alist)) | 2117 | (hidden-p (dired-subdir-hidden-p cur-dir)) |
| 2084 | (end-pos (1- (dired-get-subdir-max elt))) | 2118 | (elt (assoc cur-dir dired-subdir-alist)) |
| 2085 | buffer-read-only) | 2119 | (end-pos (1- (dired-get-subdir-max elt))) |
| 2086 | ;; keep header line visible, hide rest | 2120 | buffer-read-only) |
| 2087 | (goto-char (dired-get-subdir-min elt)) | 2121 | ;; keep header line visible, hide rest |
| 2088 | (skip-chars-forward "^\n\r") | 2122 | (goto-char (dired-get-subdir-min elt)) |
| 2089 | (if hidden-p | 2123 | (skip-chars-forward "^\n\r") |
| 2090 | (subst-char-in-region (point) end-pos ?\r ?\n) | 2124 | (if hidden-p |
| 2091 | (subst-char-in-region (point) end-pos ?\n ?\r))) | 2125 | (subst-char-in-region (point) end-pos ?\r ?\n) |
| 2092 | (dired-next-subdir 1 t))) | 2126 | (subst-char-in-region (point) end-pos ?\n ?\r))) |
| 2127 | (dired-next-subdir 1 t)) | ||
| 2128 | (restore-buffer-modified-p modflag))) | ||
| 2093 | 2129 | ||
| 2094 | ;;;###autoload | 2130 | ;;;###autoload |
| 2095 | (defun dired-hide-all (arg) | 2131 | (defun dired-hide-all (arg) |
| @@ -2098,7 +2134,8 @@ If there is already something hidden, make everything visible again. | |||
| 2098 | Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." | 2134 | Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." |
| 2099 | (interactive "P") | 2135 | (interactive "P") |
| 2100 | (dired-hide-check) | 2136 | (dired-hide-check) |
| 2101 | (let (buffer-read-only) | 2137 | (let ((modflag (buffer-modified-p)) |
| 2138 | buffer-read-only) | ||
| 2102 | (if (save-excursion | 2139 | (if (save-excursion |
| 2103 | (goto-char (point-min)) | 2140 | (goto-char (point-min)) |
| 2104 | (search-forward "\r" nil t)) | 2141 | (search-forward "\r" nil t)) |
| @@ -2107,7 +2144,7 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." | |||
| 2107 | ;; hide | 2144 | ;; hide |
| 2108 | (let ((pos (point-max)) ; pos of end of last directory | 2145 | (let ((pos (point-max)) ; pos of end of last directory |
| 2109 | (alist dired-subdir-alist)) | 2146 | (alist dired-subdir-alist)) |
| 2110 | (while alist ; while there are dirs before pos | 2147 | (while alist ; while there are dirs before pos |
| 2111 | (subst-char-in-region (dired-get-subdir-min (car alist)) ; pos of prev dir | 2148 | (subst-char-in-region (dired-get-subdir-min (car alist)) ; pos of prev dir |
| 2112 | (save-excursion | 2149 | (save-excursion |
| 2113 | (goto-char pos) ; current dir | 2150 | (goto-char pos) ; current dir |
| @@ -2116,7 +2153,8 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." | |||
| 2116 | (point)) | 2153 | (point)) |
| 2117 | ?\n ?\r) | 2154 | ?\n ?\r) |
| 2118 | (setq pos (dired-get-subdir-min (car alist))) ; prev dir gets current dir | 2155 | (setq pos (dired-get-subdir-min (car alist))) ; prev dir gets current dir |
| 2119 | (setq alist (cdr alist))))))) | 2156 | (setq alist (cdr alist))))) |
| 2157 | (restore-buffer-modified-p modflag))) | ||
| 2120 | 2158 | ||
| 2121 | ;;;###end dired-ins.el | 2159 | ;;;###end dired-ins.el |
| 2122 | 2160 | ||