2019-07-17 08:57:01 +01:00
|
|
|
;;; Base --- Base library of FG42
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
|
2015-07-07 10:42:08 +01:00
|
|
|
(require 'cl-lib)
|
|
|
|
(require 'fg42/extension)
|
|
|
|
|
2019-08-22 19:06:39 +01:00
|
|
|
(require 'fg42/vars)
|
|
|
|
|
2015-07-09 12:05:26 +01:00
|
|
|
|
2015-07-09 11:37:36 +01:00
|
|
|
;; Macros ---------------------------------
|
2015-07-09 12:05:26 +01:00
|
|
|
(defmacro theme (name &optional local)
|
2019-07-17 08:57:01 +01:00
|
|
|
"Mark the given theme NAME as default them.
|
|
|
|
LOCAL should be 't' if theme is on FG42 it self"
|
2015-07-09 11:37:36 +01:00
|
|
|
`(progn
|
2015-07-09 12:05:26 +01:00
|
|
|
(setq default-theme ',(intern (symbol-name name)))
|
|
|
|
(when (not (null ,local))
|
|
|
|
(depends-on default-theme))))
|
2015-07-09 11:37:36 +01:00
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-09 11:05:09 +01:00
|
|
|
;; Functions ------------------------------
|
2015-07-09 12:05:26 +01:00
|
|
|
(defun load-default-theme ()
|
2019-07-17 08:57:01 +01:00
|
|
|
"Load the given theme name."
|
2020-05-17 19:09:28 +01:00
|
|
|
(message "Load theme %s" default-theme)
|
2015-07-09 12:05:26 +01:00
|
|
|
(require default-theme)
|
2018-04-19 01:22:12 +01:00
|
|
|
|
|
|
|
;; Setup the face look up function for spaceline
|
|
|
|
(with-ability spaceline
|
|
|
|
(let ((other-face (intern (concat (symbol-name default-theme)
|
|
|
|
"-spaceline-faces"))))
|
|
|
|
(if (functionp other-face)
|
|
|
|
(setq spaceline-face-func other-face))))
|
|
|
|
|
|
|
|
;; Call the function name with same name as the them which should
|
|
|
|
;; be responsible for loading the actual "custom-theme"
|
2018-04-19 01:07:45 +01:00
|
|
|
(funcall (symbol-function default-theme)))
|
2015-07-09 12:05:26 +01:00
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-07 10:42:08 +01:00
|
|
|
(defun load--extension (extension)
|
2019-07-17 08:57:01 +01:00
|
|
|
"Load a single EXTENSION and call its :on-initialize function."
|
2015-07-07 12:25:06 +01:00
|
|
|
(let ((lib (concat "extensions/" (symbol-name extension))))
|
|
|
|
(require (intern lib))))
|
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-07 12:25:06 +01:00
|
|
|
(defun initialize--extension (extension)
|
2019-07-17 08:57:01 +01:00
|
|
|
"Initialize given EXTENSION by calling its :on-initialize function."
|
2015-07-07 12:25:06 +01:00
|
|
|
(let ((init-func (fg42-extension-on-initialize (symbol-value extension))))
|
2015-07-07 10:42:08 +01:00
|
|
|
(funcall (symbol-function init-func))))
|
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-07 12:25:06 +01:00
|
|
|
(defun initialize-extensions ()
|
|
|
|
"Call the :on-initialize function on all extensions."
|
2015-07-09 11:05:09 +01:00
|
|
|
(mapcar 'initialize--extension activated-extensions))
|
2015-07-07 10:42:08 +01:00
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-07 12:25:06 +01:00
|
|
|
(defun activate-extensions (&rest extensions)
|
2019-07-17 08:57:01 +01:00
|
|
|
"Mark given EXTENSIONS to load on FG42."
|
2015-07-07 12:25:06 +01:00
|
|
|
(setq activated-extensions extensions)
|
2015-07-07 10:42:08 +01:00
|
|
|
(mapcar 'load--extension extensions))
|
|
|
|
|
2019-07-17 08:57:01 +01:00
|
|
|
|
2015-07-09 11:05:09 +01:00
|
|
|
(defun load-user-config (file)
|
2019-07-17 08:57:01 +01:00
|
|
|
"Load the given FILE as user config file."
|
2015-07-09 11:05:09 +01:00
|
|
|
(if (file-exists-p file)
|
|
|
|
(load-file file)))
|
|
|
|
|
2016-03-29 18:48:41 +01:00
|
|
|
|
2015-07-07 10:42:08 +01:00
|
|
|
(provide 'fg42/base)
|
2019-07-17 08:57:01 +01:00
|
|
|
;;; base ends here
|