From 34260927bc7bb1a37f75058233ddeaf411e2c66b Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sat, 6 Mar 2021 18:40:57 +0000 Subject: [PATCH] Add fpkg/use as a wrapper for use-package and a simple elisp cube --- core/cubes/elisp.el | 16 ++++++++++------ core/fg42.el | 13 +++++++++---- core/fg42/cube.el | 2 +- core/fpkg.el | 38 +++++++------------------------------- fg42-config.el | 25 +++++++++++-------------- 5 files changed, 38 insertions(+), 56 deletions(-) diff --git a/core/cubes/elisp.el b/core/cubes/elisp.el index 1143276..d13d5ad 100644 --- a/core/cubes/elisp.el +++ b/core/cubes/elisp.el @@ -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) diff --git a/core/fg42.el b/core/fg42.el index 2ad1dc5..1ea333d 100644 --- a/core/fg42.el +++ b/core/fg42.el @@ -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) diff --git a/core/fg42/cube.el b/core/fg42/cube.el index bc04076..31f53e0 100644 --- a/core/fg42/cube.el +++ b/core/fg42/cube.el @@ -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) diff --git a/core/fpkg.el b/core/fpkg.el index 275e35c..a45ad7c 100644 --- a/core/fpkg.el +++ b/core/fpkg.el @@ -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) diff --git a/fg42-config.el b/fg42-config.el index 6134715..e013947 100644 --- a/fg42-config.el +++ b/fg42-config.el @@ -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)