2015-07-07 10:42:08 +01:00
|
|
|
(require 'cl-lib)
|
|
|
|
(require 'fg42/extension)
|
|
|
|
|
2015-07-09 12:05:26 +01:00
|
|
|
;; Vars -----------------------------------
|
|
|
|
(defvar default-theme nil "Default FG42 theme.")
|
|
|
|
|
2015-07-09 11:37:36 +01:00
|
|
|
;; Macros ---------------------------------
|
2015-07-09 12:05:26 +01:00
|
|
|
(defmacro theme (name &optional local)
|
|
|
|
"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
|
|
|
|
2015-07-09 11:05:09 +01:00
|
|
|
;; Functions ------------------------------
|
2015-07-09 12:05:26 +01:00
|
|
|
(defun load-default-theme ()
|
|
|
|
"Load the given theme name"
|
|
|
|
(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
|
|
|
|
2015-07-07 10:42:08 +01:00
|
|
|
(defun load--extension (extension)
|
|
|
|
"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))))
|
|
|
|
|
|
|
|
(defun initialize--extension (extension)
|
|
|
|
"Initialize given extension by calling its :on-initialize function."
|
|
|
|
(let ((init-func (fg42-extension-on-initialize (symbol-value extension))))
|
2015-07-07 10:42:08 +01:00
|
|
|
(funcall (symbol-function init-func))))
|
|
|
|
|
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
|
|
|
|
2015-07-07 12:25:06 +01:00
|
|
|
(defun activate-extensions (&rest extensions)
|
2015-07-07 10:42:08 +01:00
|
|
|
"Mark given plugins 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))
|
|
|
|
|
2015-07-09 11:05:09 +01:00
|
|
|
(defun load-user-config (file)
|
|
|
|
"Load the given path as user config file"
|
|
|
|
(if (file-exists-p file)
|
|
|
|
(load-file file)))
|
|
|
|
|
2016-01-09 08:21:20 +00:00
|
|
|
(defun what-face (pos)
|
|
|
|
(interactive "d")
|
|
|
|
(let ((face (or (get-char-property (point) 'read-face-name)
|
|
|
|
(get-char-property (point) 'face))))
|
|
|
|
(if face (message "Face: %s" face) (message "No face at %d" pos))))
|
2015-07-09 11:37:36 +01:00
|
|
|
|
2016-03-29 18:48:41 +01:00
|
|
|
;;;###autoload
|
|
|
|
(defun env (&rest args)
|
2016-04-23 09:55:14 +01:00
|
|
|
"setup environment variables given as params."
|
2016-03-29 18:48:41 +01:00
|
|
|
(require 'seq)
|
|
|
|
(let ((pairs (seq-partition args 2)))
|
|
|
|
(dolist (pair pairs)
|
|
|
|
(progn (setenv (substring (symbol-name (car pair)) 1) (car (cdr pair)))))))
|
|
|
|
|
|
|
|
|
2015-07-07 10:42:08 +01:00
|
|
|
(provide 'fg42/base)
|