Function: dired-current-directory

dired-current-directory is a byte-compiled function defined in dired.el.gz.

Signature

(dired-current-directory &optional LOCALP)

Documentation

Return the name of the subdirectory to which this line belongs.

This returns a string with trailing slash, like default-directory. Optional argument means return a file name relative to default-directory, in which case the value could be an empty string if default-directory is the directory where the file on this line resides.

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
;; These are hooks which make tree dired work.
;; They are in this file because other parts of dired need to call them.
;; But they don't call the rest of tree dired unless there are subdirs loaded.

;; This function is called for each retrieved filename.
;; It could stand to be faster, though it's mostly function call
;; overhead.  Avoiding the function call seems to save about 10% in
;; dired-get-filename.  Make it a defsubst?
(defun dired-current-directory (&optional localp)
  "Return the name of the subdirectory to which this line belongs.
This returns a string with trailing slash, like `default-directory'.
Optional argument means return a file name relative to `default-directory',
in which case the value could be an empty string if `default-directory'
is the directory where the file on this line resides."
  (let ((here (point))
	(alist (or dired-subdir-alist
		   ;; probably because called in a non-dired buffer
		   (error "No subdir-alist in %s" (current-buffer))))
	elt dir)
    (while alist
      (setq elt (car alist)
	    dir (car elt)
	    ;; use `<=' (not `<') as subdir line is part of subdir
	    alist (if (<= (cdr elt) here)
		      nil		; found
		    (cdr alist))))
    (if localp
	(dired-make-relative dir default-directory)
      dir)))