Add fpkg/use as a wrapper for use-package and a simple elisp cube

This commit is contained in:
Sameer Rahmani 2021-03-06 18:40:57 +00:00
parent 112bb31b8e
commit 34260927bc
5 changed files with 38 additions and 56 deletions

View File

@ -25,16 +25,20 @@
;; way. Cubes are composable and a composition of cubes creates an editor. ;; way. Cubes are composable and a composition of cubes creates an editor.
;; ;;
;;; Code: ;;; Code:
(require 'fpkg)
(require 'fg42/cube) (require 'fg42/cube)
(autoload 'fg42/elisp-hook-handler "cubes/elisp/core")
(package-as-cube paredit)
(defcube fg42/elisp-cube (defcube fg42/elisp-cube
(depends-on 'blah)) (fpkg/use rainbow-delimiters
;; It doesn't work due to a problem/conflict in rainbow-delimiters
;; But we use it any way they might fix it
:hook (prog-mode . rainbow-delimiters-mode))
(fpkg/use paredit
:hook (emacs-lisp-mode . paredit-mode))
(add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode))
(provide 'cubes/elisp) (provide 'cubes/elisp)

View File

@ -25,13 +25,18 @@
(require 'fg42/utils) (require 'fg42/utils)
(defun fg42/before-initialize ()
"Initialize the package manager before rendering the window instance."
(require 'fpkg/core)
(fpkg/initialize))
(defun fg42/initialize () (defun fg42/initialize ()
"Initialize the FG42 instance." "Initialize FG42 after the Emacs window is rendered by loading the user init file."
(add-hook 'window-setup-hook (add-hook 'window-setup-hook
(lambda () (lambda ()
(require 'fpkg) (when (file-exists-p user-init-file)
(fpkg/initialize) (load user-init-file)))))
(message "DONE"))))
(provide 'fg42) (provide 'fg42)

View File

@ -37,7 +37,7 @@
(defvar ,params-var nil (defvar ,params-var nil
,(format "Parameters for the '%s' cube." cube-name)) ,(format "Parameters for the '%s' cube." cube-name))
(defun ,cube-name (&rest params) (defun ,cube-name (&rest params)
(when (not (boundp ,active-var)) (when (not (boundp (quote ,active-var)))
(progn (progn
(setq ,active-var t) (setq ,active-var t)
(setq ,params-var params) (setq ,params-var params)

View File

@ -25,40 +25,16 @@
;; ;;
;;; Code: ;;; Code:
(require 'seq)
(require 'cl-lib)
(require 'package)
(require 'fg42/core)
(defvar bootstrap-version 5) ;;(require 'use-package)
(defcustom fpkg-package-directory (concat fg42-home "/.fpkg")
"Specify the directory to store all the dependencies."
:group 'fpkg
:type 'string)
(defmacro depends-on (pkg) (defmacro fpkg/use (&rest pkg)
"Install the given package PKG via straight." "Install the given package details PKG via use-package and straight."
(if (list-p pkg) (declare (indent defun))
`(straight-use-package ,@pkg) (if (listp pkg)
`(straight-use-package ,pkg))) `(use-package ,@pkg :straight t :defer t)
`(use-package ,pkg :straight t :defer t)))
(defun fpkg/initialize ()
"Initialize FPKG."
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)))
(provide 'fpkg) (provide 'fpkg)

View File

@ -25,7 +25,6 @@
(defvar fg42-v3 (or (getenv "FG42_V3") '())) (defvar fg42-v3 (or (getenv "FG42_V3") '()))
(if fg42-v3 (if fg42-v3
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core")) (add-to-list 'load-path (concat (getenv "FG42_HOME") "/core"))
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/lib"))) (add-to-list 'load-path (concat (getenv "FG42_HOME") "/lib")))
@ -35,30 +34,28 @@
(setq custom-file (format "%s/.fg42.custom.el" (getenv "HOME"))) (setq custom-file (format "%s/.fg42.custom.el" (getenv "HOME")))
(setq user-emacs-directory "~/.fg42/emacs.d") (setq user-emacs-directory "~/.fg42/emacs.d")
(setq user-init-file (setq user-init-file
(format "%s/.fg42.%s" (format "%s/.fg42.%s"
(getenv "HOME") (getenv "HOME")
(if fg42-v3 (if fg42-v3 "v3.el" "el")))
"v3.el"
"el")))
;; Load the customization file. In FG42 it is different than
;; the default `user-init-file'
(if (file-exists-p custom-file) (if (file-exists-p custom-file)
(load custom-file)) (load custom-file))
(require 'fg42) (require 'fg42)
(load-user-config
(if fg42-v3
"~/.fg42.v3.el"
"~/.fg42.el"))
;; NOTE: It's important to use ~/.fg42.el instead of this file
;; because updating fg42 will discard your changes in
;; this file.
(if (not fg42-v3) (if (not fg42-v3)
(fg42-initialize) (progn
(fg42/initialize)) (load-user-config user-init-file)
(fg42-initialize))
(progn
(fg42/before-initialize)
(fg42/initialize)))
(provide 'fg42-config) (provide 'fg42-config)