Mercurial > emacs
changeset 1091:3302f6e93ce5
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 11 Sep 1992 09:04:24 +0000 |
parents | 676310a31777 |
children | c2259db856ee |
files | lisp/dired.el |
diffstat | 1 files changed, 34 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/dired.el Fri Sep 11 07:05:14 1992 +0000 +++ b/lisp/dired.el Fri Sep 11 09:04:24 1992 +0000 @@ -1146,6 +1146,37 @@ (set-marker (dired-get-subdir-min (car dired-subdir-alist)) nil) (setq dired-subdir-alist (cdr dired-subdir-alist)))) +(defun dired-subdir-index (dir) + ;; Return an index into alist for use with nth + ;; for the sake of subdir moving commands. + (let (found (index 0) (alist dired-subdir-alist)) + (while alist + (if (string= dir (car (car alist))) + (setq alist nil found t) + (setq alist (cdr alist) index (1+ index)))) + (if found index nil))) + +(defun dired-next-subdir (arg &optional no-error-if-not-found no-skip) + "Go to next subdirectory, regardless of level." + ;; Use 0 arg to go to this directory's header line. + ;; NO-SKIP prevents moving to end of header line, returning whatever + ;; position was found in dired-subdir-alist. + (interactive "p") + (let ((this-dir (dired-current-directory)) + pos index) + ;; nth with negative arg does not return nil but the first element + (setq index (- (dired-subdir-index this-dir) arg)) + (setq pos (if (>= index 0) + (dired-get-subdir-min (nth index dired-subdir-alist)))) + (if pos + (progn + (goto-char pos) + (or no-skip (skip-chars-forward "^\n\r")) + (point)) + (if no-error-if-not-found + nil ; return nil if not found + (error "%s directory" (if (> arg 0) "Last" "First")))))) + (defun dired-build-subdir-alist () "Build `dired-subdir-alist' by parsing the buffer. Returns the new value of the alist." @@ -1163,9 +1194,9 @@ (save-excursion (goto-char (match-beginning 0)) (beginning-of-line) - (point-marker))) - (message "%d" count)) - (message "%d director%s" count (if (= 1 count) "y" "ies")) + (point-marker)))) + (if (> count 1) + (message "Buffer includes %d directories" count)) ;; We don't need to sort it because it is in buffer order per ;; constructionem. Return new alist: dired-subdir-alist)))