all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Kaushal Modi <kaushal.modi@gmail.com>,
	Emacs developers <emacs-devel@gnu.org>
Subject: RE: Default share/ and lisp/ directories?
Date: Tue, 20 Feb 2018 10:48:45 -0800 (PST)	[thread overview]
Message-ID: <31b4fa70-3cbf-4d75-8d62-4f27c8272d49@default> (raw)
In-Reply-To: <CAFyQvY3Z_vcH2OY2CkpAw8FguOwqZqGdyozaSwM2ECK9T549zA@mail.gmail.com>

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 file))))
        relparent)
    (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	other threads:[~2018-02-20 18:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 18:09 Default share/ and lisp/ directories? Kaushal Modi
2018-02-20 18:48 ` Drew Adams [this message]
2018-02-20 20:27   ` Kaushal Modi
2018-02-20 21:06     ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31b4fa70-3cbf-4d75-8d62-4f27c8272d49@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.