[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Default share/ and lisp/ directories?

From: Drew Adams
Subject: RE: Default share/ and lisp/ directories?
Date: Tue, 20 Feb 2018 10:48:45 -0800 (PST)

Suggestion: use functions for manipulating file/dir names.

> (let* ((bin-dir (when (and invocation-directory
>                            (file-exists-p invocation-directory))
>                   (file-truename invocation-directory)))
>        (prefix-dir (when bin-dir
>                      (replace-regexp-in-string "bin/\\'" "" bin-dir)))

Use (file-name-directory (directory-file-name (expand-file-name file)))

More generally (from dired+.el):

(defun parent-dir (file &optional relativep)
  "Return the parent directory of FILE, or nil if none.
Optional arg RELATIVEP non-nil means return a relative name, that is,
just the parent component."
  (let ((parent  (file-name-directory (directory-file-name (expand-file-name 
    (when relativep (setq relparent  (file-name-nondirectory 
(directory-file-name parent))))
    (and (not (equal parent file))  (or relparent  parent))))

> (when prefix-dir (concat prefix-dir "share/"))

Use (file-name-as-directory (expand-file-name "share" prefix-dir))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]