From 6cea8929e6a6033102110a23a12554337187baa7 Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sun, 25 Jul 2021 14:58:21 -0400 Subject: [PATCH] Conditionally respect sclang-vars Only when compiling with cmake will sclang-vars.el be written. This commit moves relevant constants into customizable vars. Only if the `sclang-system-data-dir` exists is it respected, otherwise it will guess the proper location by looking at the system-type. The purpose of this is to make it possible to build and distribute a package independent of the SuperCollider build process, while ensuring that those users who have become accustomed to the current install process are not disrupted. --- .gitignore | 1 + el/sclang-help.el | 31 +++++++++++++++++++++++++------ el/sclang-vars.el.in | 20 ++++++++++++-------- 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/el/sclang-help.el b/el/sclang-help.el index e70a864..46e1c1a 100644 --- a/el/sclang-help.el +++ b/el/sclang-help.el @@ -24,15 +24,29 @@ (require 'sclang-interp) (require 'sclang-language) (require 'sclang-mode) -(require 'sclang-vars) +(require 'sclang-vars nil 'ignore-missing-file) (require 'sclang-minor-mode) -(defcustom sclang-help-directory "~/SuperCollider/Help" - "*Directory where the SuperCollider help files are kept. OBSOLETE." +(defun sclang-system-root () + "Find the common install location for the platform." + (cond + ((boundp 'sclang-system-data-dir) + sclang-system-data-dir) + + ((eql 'darwin system-type) + (expand-file-name "~/Library/Application Support/SuperCollider")) + + ((and (eql 'gnu/linux system-type) + (file-exists-p "/usr/local/share/SuperCollider")) + "/usr/local/share/SuperCollider") + + ((eql 'gnu/linux system-type) + "/usr/share/SuperCollider"))) + +(defcustom sclang-system-help-dir (expand-file-name "Help" (sclang-system-root)) + "Installation dependent help directory." :group 'sclang-interface - :version "21.3" - :type 'directory - :options '(:must-match)) + :type 'directory) (defcustom sclang-help-path (list sclang-system-help-dir "~/.local/share/SuperCollider/Help") @@ -41,6 +55,11 @@ :version "21.4" :type '(repeat directory)) +(defcustom sclang-system-extension-dir (expand-file-name "Extensions" (sclang-system-root)) + "Installation dependent extension directory." + :group 'sclang-interface + :type 'directory) + (defconst sclang-extension-path (list sclang-system-extension-dir "~/.local/share/SuperCollider/Extensions") "List of SuperCollider extension directories.") diff --git a/el/sclang-vars.el.in b/el/sclang-vars.el.in index 57fac1b..96b1f62 100644 --- a/el/sclang-vars.el.in +++ b/el/sclang-vars.el.in @@ -16,19 +16,23 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. +;;; Commentary: +;; +;; This file is included in the distribution in order to convey system +;; installation variables which are known at compile time, but only when +;; the library is installed with cmake along with SuperCollider source. +;; +;; When using the stand-alone package, this file can be ignored and +;; the constants it defines will have no effect. + ;;; Code: (defconst sclang-system-data-dir "@PKG_DATA_DIR@" - "Installation dependent data directory.") - -(defconst sclang-system-help-dir "@PKG_DATA_DIR@/Help" - "Installation dependent help directory.") - -(defconst sclang-system-extension-dir "@PKG_DATA_DIR@/Extensions" - "Installation dependent extension directory.") + "Installation dependent data directory. +Bound only when library is installed with SuperCollider.") (provide 'sclang-vars) ;;; sclang-vars.el ends here