From e13e08068b9c4cefc63c0f381accca735cef6b63 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Thu, 13 May 2021 20:43:07 +0200 Subject: [PATCH] add config-dir variable and change load-path to use it --- init | 3 ++- settings/bibliography-settings.el | 6 +++--- settings/cedet-settings.el | 2 +- settings/completion-settings.el | 6 +++--- settings/eaf-settings.el | 4 ++-- settings/ess-settings.el | 2 +- settings/filetype-settings.el | 4 ++-- settings/general-settings.el | 2 +- settings/gui-settings.el | 4 ++-- settings/ledger-settings.el | 2 +- settings/multiple-cursors-settings.el | 2 +- settings/my-settings.el | 6 +++--- settings/org-settings.el | 11 ++++++----- settings/plot-settings.el | 2 +- settings/polymode-settings.el | 2 +- settings/pre-settings.el | 20 ++++++++++---------- settings/syntax-checking-settings.el | 4 ++-- settings/theme-settings.el | 4 ++-- settings/toolbar-settings.el | 2 +- settings/treemacs-settings.el | 2 +- settings/version-control-settings.el | 4 ++-- settings/web-settings.el | 8 ++++---- 22 files changed, 52 insertions(+), 50 deletions(-) diff --git a/init b/init index 67fae6c5..f0ebadcf 100644 --- a/init +++ b/init @@ -7,7 +7,8 @@ ;; Requirements: git gnuplot ledger ;;; Code: -(require 'pre-settings "~/.config/emacs/settings/pre-settings.el") ;; use-package delight functions variables +(setq config-dir (file-name-directory (file-truename user-init-file))) ;; user-init-file: ~/.config/emacs/init, file-truename: /opt/emacs-conf/init +(require 'pre-settings (concat config-dir "settings/pre-settings.el")) ;; use-package delight functions variables (require 'which-key-settings) ;; https://melpa.org/#/which-key (require 'general-settings) ;; requires which-key (require 'my-settings) diff --git a/settings/bibliography-settings.el b/settings/bibliography-settings.el index 843e6304..204745ce 100644 --- a/settings/bibliography-settings.el +++ b/settings/bibliography-settings.el @@ -16,15 +16,15 @@ ;;; Code: (use-package pdf-tools - :load-path "lisp/pdf-tools" + :load-path (lambda() (concat config-dir "lisp/pdf-tools")) :defer t) ;; used by org-ref (use-package biblio - :load-path "lisp/biblio" + :load-path (lambda() (concat config-dir "lisp/biblio")) :defer t) ;; used by org-ref (use-package org-ref ;; used with some preamble defs and \printbibliography (biblatex/biber, no html export), see also ox-bibtex - :load-path "lisp/org-ref" + :load-path (lambda() (concat config-dir "lisp/org-ref")) :after (org) :defer 1 :init diff --git a/settings/cedet-settings.el b/settings/cedet-settings.el index 2d2e2800..2422e908 100644 --- a/settings/cedet-settings.el +++ b/settings/cedet-settings.el @@ -51,7 +51,7 @@ (setq srecode-map-save-file (concat user-cache-directory "cedet/srecode-map.el"))) (use-package srefactor ;; https://melpa.org/#/srefactor - :load-path "lisp/srefactor" + :load-path (lambda() (concat config-dir "lisp/srefactor")) :defer 2) ;; Loads after 2 seconds of idle time. (use-package srefactor-lisp diff --git a/settings/completion-settings.el b/settings/completion-settings.el index 3d03eada..ebbe8716 100644 --- a/settings/completion-settings.el +++ b/settings/completion-settings.el @@ -33,7 +33,7 @@ ;; in an ivy action minibuffer use M-o `ivy-dispatching-done' to see ;; valid actions. (use-package ivy - :load-path "lisp/ivy" + :load-path (lambda() (concat config-dir "lisp/ivy")) :delight (ivy-mode "Ⓘ") ;; Ⓘ i :defer 0.1 ;; Ivy-based interface to standard commands @@ -108,7 +108,7 @@ ;;(setq tab-always-indent 'complete) ;; use 'complete when auto-complete is disabled (use-package company - :load-path "lisp/company" + :load-path (lambda() (concat config-dir "lisp/company")) :delight (company-mode "Ⓒ") ;; Ⓒ c ;;:bind (("C-M-i" . company-complete)) :bind (([remap completion-at-point] . company-complete) @@ -212,7 +212,7 @@ Possible PACKAGE values are `company'." '(yas-popup-isearch-prompt yas-maybe-ido-prompt yas-completing-prompt yas-no-prompt))) (use-package yasnippet-snippets - :load-path "lisp/yasnippet-snippets" + :load-path (lambda() (concat config-dir "lisp/yasnippet-snippets")) :after (yasnippet) :defer 1) diff --git a/settings/eaf-settings.el b/settings/eaf-settings.el index 2a598a16..a32eb19d 100644 --- a/settings/eaf-settings.el +++ b/settings/eaf-settings.el @@ -7,11 +7,11 @@ ;;; Code: ;; required by eaf (use-package epc - :load-path "lisp/epc" + :load-path (lambda() (concat config-dir "lisp/epc")) :defer t) (use-package eaf - :load-path "lisp/emacs-application-framework" + :load-path (lambda() (concat config-dir "lisp/emacs-application-framework")) ;;:after (org) ;; eaf requires eaf-interleave requires org ;;:defer 2 :commands (eaf-open diff --git a/settings/ess-settings.el b/settings/ess-settings.el index 73799dd4..c7721ed5 100644 --- a/settings/ess-settings.el +++ b/settings/ess-settings.el @@ -18,7 +18,7 @@ ;;; Code: (use-package ess-site ;; all ESS features - :load-path "lisp/ess" + :load-path (lambda() (concat config-dir "lisp/ess")) :commands ess-r-mode) ;; only R related features (use-package ess-R-data-view diff --git a/settings/filetype-settings.el b/settings/filetype-settings.el index a543d877..1887608b 100644 --- a/settings/filetype-settings.el +++ b/settings/filetype-settings.el @@ -15,11 +15,11 @@ :mode "\\.md\\'") (use-package sql-indent - :load-path "lisp/sql-indent" + :load-path (lambda() (concat config-dir "lisp/sql-indent")) :commands sqlind-minor-mode) (use-package systemd - :load-path "lisp/systemd" + :load-path (lambda() (concat config-dir "lisp/systemd")) :commands systemd-mode :mode (("\\.service\\'" . systemd-mode) ("\\.mount\\'" . systemd-mode))) diff --git a/settings/general-settings.el b/settings/general-settings.el index 368c432f..d1cb7257 100644 --- a/settings/general-settings.el +++ b/settings/general-settings.el @@ -295,7 +295,7 @@ Version 2016-07-13" (setq bookmark-default-file (concat user-cache-directory "bookmarks")) (use-package transient - :load-path (lambda() (concat user-emacs-directory "lisp/transient")) + :load-path (lambda() (concat config-dir "lisp/transient")) :defer t :config (setq transient-levels-file (concat user-cache-directory "transient/levels.el")) diff --git a/settings/gui-settings.el b/settings/gui-settings.el index b2205caa..a71bbac2 100644 --- a/settings/gui-settings.el +++ b/settings/gui-settings.el @@ -171,7 +171,7 @@ DISPLAY-START: `integer', e.g. 3820" :defer t) (use-package all-the-icons - :load-path "lisp/all-the-icons" + :load-path (lambda() (concat config-dir "lisp/all-the-icons")) :defer t :config (when (and (not (my-font-installed-p "all-the-icons")) @@ -181,7 +181,7 @@ DISPLAY-START: `integer', e.g. 3820" )) (use-package dashboard - :load-path "lisp/dashboard" + :load-path (lambda() (concat config-dir "lisp/dashboard")) :delight (dashboard-mode "🅓") :config ;; because we use `use-package' include `use-package-statistics' if computed diff --git a/settings/ledger-settings.el b/settings/ledger-settings.el index af7255b2..743628a8 100644 --- a/settings/ledger-settings.el +++ b/settings/ledger-settings.el @@ -14,7 +14,7 @@ ;;; Code: (use-package ledger-mode - :load-path "lisp/ledger-mode" + :load-path (lambda() (concat config-dir "lisp/ledger-mode")) :delight (ledger-mode "🅛d") ; "Le " (ledger-report-mode "🅛dr") ; "LeR 🅖⒭" diff --git a/settings/multiple-cursors-settings.el b/settings/multiple-cursors-settings.el index 69f61b17..c1efce58 100644 --- a/settings/multiple-cursors-settings.el +++ b/settings/multiple-cursors-settings.el @@ -7,7 +7,7 @@ ;;; Code: (use-package multiple-cursors - :load-path "lisp/multiple-cursors" + :load-path (lambda() (concat config-dir "lisp/multiple-cursors")) :bind (;; see kbd prefix description in which-key-settings ("M-m s m a" . mc/mark-all-dwim) ("M-m s m b" . mc/mark-all-like-this) diff --git a/settings/my-settings.el b/settings/my-settings.el index 4940a7a8..db0c24f3 100644 --- a/settings/my-settings.el +++ b/settings/my-settings.el @@ -2,18 +2,18 @@ ;;; Commentary: ;;; Code: (use-package my - :load-path "lisp/my" + :load-path (lambda() (concat config-dir "lisp/my")) :config (with-eval-after-load 'org (add-hook 'org-mode-hook 'my-org-link-color-hook) (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-attr))) (use-package my-org-article - :load-path "lisp/my" + :load-path (lambda() (concat config-dir "lisp/my")) :after (org)) (use-package my-org-letter - :load-path "lisp/my" + :load-path (lambda() (concat config-dir "lisp/my")) :after (org)) (provide 'my-settings) diff --git a/settings/org-settings.el b/settings/org-settings.el index c7ee32ea..d5a034c5 100644 --- a/settings/org-settings.el +++ b/settings/org-settings.el @@ -236,7 +236,8 @@ Example defines ;; be loaded before, otherwise both versions will be loaded and will ;; conflict. (use-package org - :load-path ("lisp/org/lisp" "lisp/org/contrib/lisp") + :load-path (lambda () (list (concat config-dir "lisp/org/lisp") + (concat config-dir "lisp/org/contrib/lisp"))) :delight (org-mode "🅞") ;; "Org " :defer t :init @@ -425,7 +426,7 @@ Example defines (use-package org-cliplink :after (org) - :load-path "lisp/org-cliplink" + :load-path (lambda() (concat config-dir "lisp/org-cliplink")) :config (defun my-org-link-description-update () "." @@ -1134,10 +1135,10 @@ used as a communication channel." :defer t ;; will be loaded via `org-export-backends' see above inside `org' :config ;; #+REVEAL_EXTRA_CSS: - (setq org-reveal-extra-css (concat "file://" (expand-file-name user-emacs-directory) "scripts/flipcard/flipcard.css")) ;; multiple files seperated with \n + (setq org-reveal-extra-css (concat "file://" (expand-file-name config-dir) "scripts/flipcard/flipcard.css")) ;; multiple files seperated with \n ;; #+REVEAL_POSTAMBLE: - (setq org-reveal-postamble (replace-regexp-in-string "\n" "" (concat ""))) ;; only one line! - (setq org-reveal-root (concat "file://" (expand-file-name user-emacs-directory) "scripts/reveal.js")) + (setq org-reveal-postamble (replace-regexp-in-string "\n" "" (concat ""))) ;; only one line! + (setq org-reveal-root (concat "file://" (expand-file-name config-dir) "scripts/reveal.js")) (setq org-reveal-single-file t) ;; overwrite to implement `org-reveal-single-file' (:reveal-single-file) ;; used in `org-reveal-scripts' as reveal-4-plugin diff --git a/settings/plot-settings.el b/settings/plot-settings.el index 422d91d2..b7bd330a 100644 --- a/settings/plot-settings.el +++ b/settings/plot-settings.el @@ -11,7 +11,7 @@ ;;; Code: (use-package gnuplot-mode - :load-path "lisp/gnuplot" + :load-path (lambda() (concat config-dir "lisp/gnuplot")) :commands gnuplot-mode :mode "\\.gp\\'") diff --git a/settings/polymode-settings.el b/settings/polymode-settings.el index 130c62a4..83afd43a 100644 --- a/settings/polymode-settings.el +++ b/settings/polymode-settings.el @@ -2,7 +2,7 @@ ;;; Commentary: ;;; Code: (use-package polymode - :load-path "lisp/polymode" + :load-path (lambda() (concat config-dir "lisp/polymode")) :commands poly-python-web-mode :config diff --git a/settings/pre-settings.el b/settings/pre-settings.el index c1042d44..0ccf8177 100644 --- a/settings/pre-settings.el +++ b/settings/pre-settings.el @@ -2,15 +2,15 @@ ;;; Commentary: ;;; Code: (mapc (lambda (item) (add-to-list 'load-path item)) - '( - "~/.config/emacs/settings" ;; path where settings files are kept - "~/.config/emacs/lisp" ;; personal elisp lib dir, for manually installed packages - "~/.config/emacs/lisp/dash" - "~/.config/emacs/lisp/with-editor" - "~/.config/emacs/lisp/hydra" ;; required by treemacs org-ref - "~/.config/emacs/lisp/async" ;; https://melpa.org/#/async required by ob-async - "~/.config/emacs/lisp/persist" ;; https://elpa.gnu.org/packages/persist.html required by org-drill - "~/.config/emacs/lisp/use-package" ;; https://melpa.org/#/use-package + (list + (concat config-dir "settings") ;; path where settings files are kept + (concat config-dir "lisp") ;; personal elisp lib dir, for manually installed packages + (concat config-dir "lisp/dash") + (concat config-dir "lisp/with-editor") + (concat config-dir "lisp/hydra") ;; required by treemacs org-ref + (concat config-dir "lisp/async") ;; https://melpa.org/#/async required by ob-async + (concat config-dir "lisp/persist") ;; https://elpa.gnu.org/packages/persist.html required by org-drill + (concat config-dir "lisp/use-package") ;; https://melpa.org/#/use-package )) (setq gc-cons-threshold (* 50 1000 1000)) ;; Make startup faster by reducing the frequency of garbage collection. The default is 800 kilobytes. Measured in bytes. Will be decreased again at the end. @@ -49,7 +49,7 @@ Both Win32 and Cygwin count.") (shell-command-to-string "uname -a | sed -n 's/.*\\( *Microsoft *\\).*/\\1/ip'")) "Microsoft")) -(setq user-emacs-directory "~/.config/emacs/") +(setq user-emacs-directory "~/.config/emacs/") ;; for cache etc. (defconst user-cache-directory (file-name-as-directory (concat user-emacs-directory ".cache")) "My Emacs storage area for persistent files.") diff --git a/settings/syntax-checking-settings.el b/settings/syntax-checking-settings.el index e09f3ebf..67abf496 100644 --- a/settings/syntax-checking-settings.el +++ b/settings/syntax-checking-settings.el @@ -18,9 +18,9 @@ ;; do not load directly with e.g. (global-flycheck-mode) or via ;; after-init-hook while loading the init because flycheck will freeze ;; for a short while. Therefore better defer loading. -;;(require 'flycheck (concat user-emacs-directory "lisp/flycheck/flycheck.el")) +;;(require 'flycheck (concat config-dir "lisp/flycheck/flycheck.el")) (use-package flycheck - :load-path "lisp/flycheck" + :load-path (lambda() (concat config-dir "lisp/flycheck")) :defer 2 :init (setq flycheck-mode-line-prefix "𝓕") ;; Ⓕ 𝓕 ✈ f ;; other flycheck settings see syntax-checking-settings.el diff --git a/settings/theme-settings.el b/settings/theme-settings.el index e5e18543..62a9fc3f 100644 --- a/settings/theme-settings.el +++ b/settings/theme-settings.el @@ -12,7 +12,7 @@ ;;; Code: (use-package spacemacs-common :after (cl-lib) ;; spacemacs-common misses to load cl-lib - :load-path "lisp/spacemacs-theme" + :load-path (lambda() (concat config-dir "lisp/spacemacs-theme")) :config (load-theme 'spacemacs-dark t)) @@ -54,7 +54,7 @@ (use-package emojify :commands emojify-mode - :load-path "lisp/emojify" + :load-path (lambda() (concat config-dir "lisp/emojify")) :hook (after-init . global-emojify-mode) :init (setq emojify-emojis-dir (concat user-emacs-directory ".cache/emojify"))) diff --git a/settings/toolbar-settings.el b/settings/toolbar-settings.el index 3cc9501d..ae22af37 100644 --- a/settings/toolbar-settings.el +++ b/settings/toolbar-settings.el @@ -124,7 +124,7 @@ :defer t :config ;; add local icon folder to the image-load-path - (add-to-list 'image-load-path (concat user-emacs-directory "icon/")) + (add-to-list 'image-load-path (concat config-dir "icon/")) ;; TODO: revert after close? ;; TODO: add redo? diff --git a/settings/treemacs-settings.el b/settings/treemacs-settings.el index 74ff7950..6b0141d3 100644 --- a/settings/treemacs-settings.el +++ b/settings/treemacs-settings.el @@ -11,7 +11,7 @@ ;; hydra.el https://elpa.gnu.org/packages/hydra.html ;; treemacs-magit ;; http://melpa.org/#/treemacs-magit (use-package treemacs - :load-path "lisp/treemacs" + :load-path (lambda() (concat config-dir "lisp/treemacs")) :commands treemacs :init ;; get rid of the message: diff --git a/settings/version-control-settings.el b/settings/version-control-settings.el index 9cc1a0da..55a137a9 100644 --- a/settings/version-control-settings.el +++ b/settings/version-control-settings.el @@ -21,7 +21,7 @@ ;;; Code: ;; see also Diff-Hl (diff-hl-mode) to see VC diff highlighting in fringes. (use-package magit - :load-path "lisp/magit" + :load-path (lambda() (concat config-dir "lisp/magit")) :bind (("C-c M-g" . magit-file-dispatch)) :config ;; (setq magit-completing-read-function 'magit-builtin-completing-read) ;; if ivy-mode is on then it uses it otherwise set to 'ivy-completing-read @@ -50,7 +50,7 @@ :after (magit org)) (use-package diff-hl - :load-path "lisp/diff-hl" + :load-path (lambda() (concat config-dir "lisp/diff-hl")) :hook (((prog-mode vc-dir-mode org-mode) . turn-on-diff-hl-mode) (magit-pre-refresh . diff-hl-magit-pre-refresh) (magit-post-refresh . diff-hl-magit-post-refresh)) diff --git a/settings/web-settings.el b/settings/web-settings.el index 0b836c83..95778127 100644 --- a/settings/web-settings.el +++ b/settings/web-settings.el @@ -18,23 +18,23 @@ (setq css-indent-offset 2)) (use-package js2-mode - :load-path "lisp/js2-mode" + :load-path (lambda() (concat config-dir "lisp/js2-mode")) :commands js2-mode) (use-package php-mode - :load-path "lisp/php-mode" + :load-path (lambda() (concat config-dir "lisp/php-mode")) :commands php-mode) (use-package web-mode :commands (web-mode)) (use-package web-completion-data - :load-path "lisp/web-completion-data" + :load-path (lambda() (concat config-dir "lisp/web-completion-data")) :defer t) (use-package company-web-html :after (web-mode company) - :load-path "lisp/company-web" + :load-path (lambda() (concat config-dir "lisp/company-web")) :bind (([remap complete-symbol] . company-complete)) ;; M-C-i and :config ;;(add-to-list 'company-backends 'company-web-html)