Function: dired-make-relative

dired-make-relative is a byte-compiled function defined in dired.el.gz.

Signature

(dired-make-relative FILE &optional DIR)

Documentation

Convert FILE (an absolute file name) to a name relative to DIR.

If DIR is omitted or nil, it defaults to default-directory. If FILE is not in the directory tree of DIR, return FILE unchanged.

Source Code

;; Defined in /usr/src/emacs/lisp/dired.el.gz
(defun dired-make-relative (file &optional dir)
  "Convert FILE (an absolute file name) to a name relative to DIR.
If DIR is omitted or nil, it defaults to `default-directory'.
If FILE is not in the directory tree of DIR, return FILE
unchanged."
  (or dir (setq dir default-directory))
  ;; This case comes into play if default-directory is set to
  ;; use ~.
  (if (and (> (length dir) 0) (= (aref dir 0) ?~))
      (setq dir (expand-file-name dir)))
  (if (string-match (concat "^" (regexp-quote dir)) file)
      (substring file (match-end 0))
    file))