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.
;;
;;; Code:
(require 'fpkg)
(require 'fg42/cube)
(autoload 'fg42/elisp-hook-handler "cubes/elisp/core")
(package-as-cube paredit)
(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)

View File

@ -25,13 +25,18 @@
(require 'fg42/utils)
(defun fg42/before-initialize ()
"Initialize the package manager before rendering the window instance."
(require 'fpkg/core)
(fpkg/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
(lambda ()
(require 'fpkg)
(fpkg/initialize)
(message "DONE"))))
(when (file-exists-p user-init-file)
(load user-init-file)))))
(provide 'fg42)

View File

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

View File

@ -25,40 +25,16 @@
;;
;;; Code:
(require 'seq)
(require 'cl-lib)
(require 'package)
(require 'fg42/core)
(defvar bootstrap-version 5)
(defcustom fpkg-package-directory (concat fg42-home "/.fpkg")
"Specify the directory to store all the dependencies."
:group 'fpkg
:type 'string)
;;(require 'use-package)
(defmacro depends-on (pkg)
"Install the given package PKG via straight."
(if (list-p pkg)
`(straight-use-package ,@pkg)
`(straight-use-package ,pkg)))
(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)))
(defmacro fpkg/use (&rest pkg)
"Install the given package details PKG via use-package and straight."
(declare (indent defun))
(if (listp pkg)
`(use-package ,@pkg :straight t :defer t)
`(use-package ,pkg :straight t :defer t)))
(provide 'fpkg)

View File

@ -25,7 +25,6 @@
(defvar fg42-v3 (or (getenv "FG42_V3") '()))
(if fg42-v3
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core"))
(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 user-emacs-directory "~/.fg42/emacs.d")
(setq user-init-file
(format "%s/.fg42.%s"
(getenv "HOME")
(if fg42-v3
"v3.el"
"el")))
(if fg42-v3 "v3.el" "el")))
;; Load the customization file. In FG42 it is different than
;; the default `user-init-file'
(if (file-exists-p custom-file)
(load custom-file))
(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)
(fg42-initialize)
(fg42/initialize))
(progn
(load-user-config user-init-file)
(fg42-initialize))
(progn
(fg42/before-initialize)
(fg42/initialize)))
(provide 'fg42-config)