[Top][All Lists]

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

Default share/ and lisp/ directories?

From: Kaushal Modi
Subject: Default share/ and lisp/ directories?
Date: Tue, 20 Feb 2018 18:09:43 +0000

I have probably heavily over-engineered this; it helps me derive the default path for "share/" and "lisp/" directories.

I couldn't find any internal variable that holds those values.

Here's the code:

(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)))
       (share-dir (when prefix-dir
                    (concat prefix-dir "share/")))
       (lisp-dir-1 (when share-dir ;Possibility where the lisp dir is something like ../emacs/26.0.50/lisp/
                     (concat share-dir "emacs/"
                             ;; If `emacs-version' is x.y.z.w, remove the ".w" portion
                             ;; Though, this is not needed and also will do nothing in emacs 26+
                             ;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=22b2207471807bda86534b4faf1a29b3a6447536
                             (replace-regexp-in-string "\\([0-9]+\\.[0-9]+\\.[0-9]+\\).*" "\\1" emacs-version)
       (lisp-dir-2 (when share-dir ;Possibility where the lisp dir is something like ../emacs/25.2/lisp/
                     (concat share-dir "emacs/"
                             (replace-regexp-in-string "\\([0-9]+\\.[0-9]+\\).*" "\\1" emacs-version)
  (defvar modi/default-share-directory (when (file-exists-p share-dir)
    "Share directory for this Emacs installation.")
  (defvar modi/default-lisp-directory (cond
                                       ((file-exists-p lisp-dir-1)
                                       ((file-exists-p lisp-dir-2)
    "Directory containing lisp files for the Emacs installation.

This value must match the path to the lisp/ directory of the
Emacs installation.  If Emacs is installed using
--prefix=\"${PREFIX_DIR}\" this value would typically be

- Are there internal variables that hold those values?
- Is there a better way to do the same?

Kaushal Modi

reply via email to

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