diff options
| author | Stefan Kangas | 2019-11-10 22:15:31 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2019-11-10 22:15:31 +0100 |
| commit | 0154e41b184a0b9938fafd9eca15399b4d5e477f (patch) | |
| tree | 23e42bb30db69d78eaf2bddd535107b467c4e882 | |
| parent | f216f38870c14ba995cd004b1e98c9f9ce8c2874 (diff) | |
| download | emacs-0154e41b184a0b9938fafd9eca15399b4d5e477f.tar.gz emacs-0154e41b184a0b9938fafd9eca15399b4d5e477f.zip | |
Make dired-get-subdir-min obsolete
* lisp/dired.el (dired-get-subdir-min): Redefine as obsolete function
alias for 'cdr'. (Bug#11571)
(dired-get-subdir, dired-get-subdir-max, dired-clear-alist)
(dired-next-subdir, dired-current-directory):
* lisp/dired-aux.el (dired-rename-subdir-2)
(dired-alist-sort, dired-insert-subdir-del)
(dired-insert-subdir-doupdate, dired-goto-subdir)
(dired-hide-subdir, dired-hide-all): Use 'cdr' instead of
the above obsolete function.
(dired-subdir-alist): Doc fix.
Co-authored-by: Drew Adams <drew.adams@oracle.com>
| -rw-r--r-- | lisp/dired-aux.el | 18 | ||||
| -rw-r--r-- | lisp/dired.el | 23 |
2 files changed, 22 insertions, 19 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 722d036e3fc..184b507e1de 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -1728,7 +1728,7 @@ rename them using `vc-rename-file'." | |||
| 1728 | (let ((regexp (regexp-quote (directory-file-name dir))) | 1728 | (let ((regexp (regexp-quote (directory-file-name dir))) |
| 1729 | (newtext (directory-file-name to)) | 1729 | (newtext (directory-file-name to)) |
| 1730 | buffer-read-only) | 1730 | buffer-read-only) |
| 1731 | (goto-char (dired-get-subdir-min elt)) | 1731 | (goto-char (cdr elt)) |
| 1732 | ;; Update subdir headerline in buffer | 1732 | ;; Update subdir headerline in buffer |
| 1733 | (if (not (looking-at dired-subdir-regexp)) | 1733 | (if (not (looking-at dired-subdir-regexp)) |
| 1734 | (error "%s not found where expected - dired-subdir-alist broken?" | 1734 | (error "%s not found where expected - dired-subdir-alist broken?" |
| @@ -2491,8 +2491,8 @@ This function takes some pains to conform to `ls -lR' output." | |||
| 2491 | (setq dired-subdir-alist | 2491 | (setq dired-subdir-alist |
| 2492 | (sort dired-subdir-alist | 2492 | (sort dired-subdir-alist |
| 2493 | (lambda (elt1 elt2) | 2493 | (lambda (elt1 elt2) |
| 2494 | (> (dired-get-subdir-min elt1) | 2494 | (> (cdr elt1) |
| 2495 | (dired-get-subdir-min elt2)))))) | 2495 | (cdr elt2)))))) |
| 2496 | 2496 | ||
| 2497 | (defun dired-kill-tree (dirname &optional remember-marks kill-root) | 2497 | (defun dired-kill-tree (dirname &optional remember-marks kill-root) |
| 2498 | "Kill all proper subdirs of DIRNAME, excluding DIRNAME itself. | 2498 | "Kill all proper subdirs of DIRNAME, excluding DIRNAME itself. |
| @@ -2535,7 +2535,7 @@ of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well." | |||
| 2535 | (defun dired-insert-subdir-del (element) | 2535 | (defun dired-insert-subdir-del (element) |
| 2536 | ;; Erase an already present subdir (given by ELEMENT) from buffer. | 2536 | ;; Erase an already present subdir (given by ELEMENT) from buffer. |
| 2537 | ;; Move to that buffer position. Return a mark-alist. | 2537 | ;; Move to that buffer position. Return a mark-alist. |
| 2538 | (let ((begin-marker (dired-get-subdir-min element))) | 2538 | (let ((begin-marker (cdr element))) |
| 2539 | (goto-char begin-marker) | 2539 | (goto-char begin-marker) |
| 2540 | ;; Are at beginning of subdir (and inside it!). Now determine its end: | 2540 | ;; Are at beginning of subdir (and inside it!). Now determine its end: |
| 2541 | (goto-char (dired-subdir-max)) | 2541 | (goto-char (dired-subdir-max)) |
| @@ -2566,7 +2566,7 @@ of marked files. If KILL-ROOT is non-nil, kill DIRNAME as well." | |||
| 2566 | ;; BEG-END is the subdir-region (as list of begin and end). | 2566 | ;; BEG-END is the subdir-region (as list of begin and end). |
| 2567 | (if elt ; subdir was already present | 2567 | (if elt ; subdir was already present |
| 2568 | ;; update its position (should actually be unchanged) | 2568 | ;; update its position (should actually be unchanged) |
| 2569 | (set-marker (dired-get-subdir-min elt) (point-marker)) | 2569 | (set-marker (cdr elt) (point-marker)) |
| 2570 | (dired-alist-add dirname (point-marker))) | 2570 | (dired-alist-add dirname (point-marker))) |
| 2571 | ;; The hook may depend on the subdir-alist containing the just | 2571 | ;; The hook may depend on the subdir-alist containing the just |
| 2572 | ;; inserted subdir, so run it after dired-alist-add: | 2572 | ;; inserted subdir, so run it after dired-alist-add: |
| @@ -2680,7 +2680,7 @@ The next char is \\n." | |||
| 2680 | (setq dir (file-name-as-directory dir)) | 2680 | (setq dir (file-name-as-directory dir)) |
| 2681 | (let ((elt (assoc dir dired-subdir-alist))) | 2681 | (let ((elt (assoc dir dired-subdir-alist))) |
| 2682 | (and elt | 2682 | (and elt |
| 2683 | (goto-char (dired-get-subdir-min elt)) | 2683 | (goto-char (cdr elt)) |
| 2684 | ;; dired-subdir-hidden-p and dired-add-entry depend on point being | 2684 | ;; dired-subdir-hidden-p and dired-add-entry depend on point being |
| 2685 | ;; at \n after this function succeeds. | 2685 | ;; at \n after this function succeeds. |
| 2686 | (progn (end-of-line) | 2686 | (progn (end-of-line) |
| @@ -2778,7 +2778,7 @@ Use \\[dired-hide-all] to (un)hide all directories." | |||
| 2778 | (end-pos (1- (dired-get-subdir-max elt))) | 2778 | (end-pos (1- (dired-get-subdir-max elt))) |
| 2779 | buffer-read-only) | 2779 | buffer-read-only) |
| 2780 | ;; keep header line visible, hide rest | 2780 | ;; keep header line visible, hide rest |
| 2781 | (goto-char (dired-get-subdir-min elt)) | 2781 | (goto-char (cdr elt)) |
| 2782 | (end-of-line) | 2782 | (end-of-line) |
| 2783 | (if hidden-p | 2783 | (if hidden-p |
| 2784 | (dired--unhide (point) end-pos) | 2784 | (dired--unhide (point) end-pos) |
| @@ -2797,14 +2797,14 @@ Use \\[dired-hide-subdir] to (un)hide a particular subdirectory." | |||
| 2797 | ;; hide | 2797 | ;; hide |
| 2798 | (let ((pos (point-max))) ; pos of end of last directory | 2798 | (let ((pos (point-max))) ; pos of end of last directory |
| 2799 | (dolist (subdir dired-subdir-alist) | 2799 | (dolist (subdir dired-subdir-alist) |
| 2800 | (let ((start (dired-get-subdir-min subdir)) ; pos of prev dir | 2800 | (let ((start (cdr subdir)) ; pos of prev dir |
| 2801 | (end (save-excursion | 2801 | (end (save-excursion |
| 2802 | (goto-char pos) ; current dir | 2802 | (goto-char pos) ; current dir |
| 2803 | ;; we're somewhere on current dir's line | 2803 | ;; we're somewhere on current dir's line |
| 2804 | (forward-line -1) | 2804 | (forward-line -1) |
| 2805 | (point)))) | 2805 | (point)))) |
| 2806 | (dired--hide start end)) | 2806 | (dired--hide start end)) |
| 2807 | (setq pos (dired-get-subdir-min subdir))))))) ; prev dir gets current dir | 2807 | (setq pos (cdr subdir))))))) ; prev dir gets current dir |
| 2808 | 2808 | ||
| 2809 | ;;;###end dired-ins.el | 2809 | ;;;###end dired-ins.el |
| 2810 | 2810 | ||
diff --git a/lisp/dired.el b/lisp/dired.el index 05789a35166..35d883a0115 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -354,10 +354,14 @@ The directory name must be absolute, but need not be fully expanded.") | |||
| 354 | 354 | ||
| 355 | ;; The subdirectory names in the next two lists are expanded. | 355 | ;; The subdirectory names in the next two lists are expanded. |
| 356 | (defvar dired-subdir-alist nil | 356 | (defvar dired-subdir-alist nil |
| 357 | "Association list of subdirectories and their buffer positions. | 357 | "Alist of listed directories and their buffer positions. |
| 358 | Each subdirectory has an element: (DIRNAME . STARTMARKER). | 358 | Alist elements have the form (DIRNAME . STARTMARKER), where |
| 359 | DIRNAME is the absolute name of the directory and STARTMARKER is | ||
| 360 | a marker at the beginning of DIRNAME. | ||
| 361 | |||
| 359 | The order of elements is the reverse of the order in the buffer. | 362 | The order of elements is the reverse of the order in the buffer. |
| 360 | In simple cases, this list contains one element.") | 363 | If no subdirectories are listed then the alist contains only one |
| 364 | element, for the listed directory.") | ||
| 361 | 365 | ||
| 362 | (defvar-local dired-switches-alist nil | 366 | (defvar-local dired-switches-alist nil |
| 363 | "Keeps track of which switches to use for inserted subdirectories. | 367 | "Keeps track of which switches to use for inserted subdirectories. |
| @@ -2857,21 +2861,20 @@ You can then feed the file name(s) to other commands with \\[yank]." | |||
| 2857 | (let ((cur-dir (dired-current-directory))) | 2861 | (let ((cur-dir (dired-current-directory))) |
| 2858 | (beginning-of-line) ; alist stores b-o-l positions | 2862 | (beginning-of-line) ; alist stores b-o-l positions |
| 2859 | (and (zerop (- (point) | 2863 | (and (zerop (- (point) |
| 2860 | (dired-get-subdir-min (assoc cur-dir | 2864 | (cdr (assoc cur-dir |
| 2861 | dired-subdir-alist)))) | 2865 | dired-subdir-alist)))) |
| 2862 | cur-dir)))) | 2866 | cur-dir)))) |
| 2863 | 2867 | ||
| 2864 | ;; can't use macro, must be redefinable for other alist format in dired-nstd. | 2868 | (define-obsolete-function-alias 'dired-get-subdir-min 'cdr "27.1") |
| 2865 | (defalias 'dired-get-subdir-min 'cdr) | ||
| 2866 | 2869 | ||
| 2867 | (defun dired-get-subdir-max (elt) | 2870 | (defun dired-get-subdir-max (elt) |
| 2868 | (save-excursion | 2871 | (save-excursion |
| 2869 | (goto-char (dired-get-subdir-min elt)) | 2872 | (goto-char (cdr elt)) |
| 2870 | (dired-subdir-max))) | 2873 | (dired-subdir-max))) |
| 2871 | 2874 | ||
| 2872 | (defun dired-clear-alist () | 2875 | (defun dired-clear-alist () |
| 2873 | (while dired-subdir-alist | 2876 | (while dired-subdir-alist |
| 2874 | (set-marker (dired-get-subdir-min (car dired-subdir-alist)) nil) | 2877 | (set-marker (cdr (car dired-subdir-alist)) nil) |
| 2875 | (setq dired-subdir-alist (cdr dired-subdir-alist)))) | 2878 | (setq dired-subdir-alist (cdr dired-subdir-alist)))) |
| 2876 | 2879 | ||
| 2877 | (defun dired-subdir-index (dir) | 2880 | (defun dired-subdir-index (dir) |
| @@ -2895,7 +2898,7 @@ You can then feed the file name(s) to other commands with \\[yank]." | |||
| 2895 | ;; nth with negative arg does not return nil but the first element | 2898 | ;; nth with negative arg does not return nil but the first element |
| 2896 | (setq index (- (dired-subdir-index this-dir) arg)) | 2899 | (setq index (- (dired-subdir-index this-dir) arg)) |
| 2897 | (setq pos (if (>= index 0) | 2900 | (setq pos (if (>= index 0) |
| 2898 | (dired-get-subdir-min (nth index dired-subdir-alist)))) | 2901 | (cdr (nth index dired-subdir-alist)))) |
| 2899 | (if pos | 2902 | (if pos |
| 2900 | (progn | 2903 | (progn |
| 2901 | (goto-char pos) | 2904 | (goto-char pos) |
| @@ -3116,7 +3119,7 @@ is the directory where the file on this line resides." | |||
| 3116 | (setq elt (car alist) | 3119 | (setq elt (car alist) |
| 3117 | dir (car elt) | 3120 | dir (car elt) |
| 3118 | ;; use `<=' (not `<') as subdir line is part of subdir | 3121 | ;; use `<=' (not `<') as subdir line is part of subdir |
| 3119 | alist (if (<= (dired-get-subdir-min elt) here) | 3122 | alist (if (<= (cdr elt) here) |
| 3120 | nil ; found | 3123 | nil ; found |
| 3121 | (cdr alist)))) | 3124 | (cdr alist)))) |
| 3122 | (if localp | 3125 | (if localp |