Fix the issue with running a cube after initialization
This commit is contained in:
parent
fa0c5765eb
commit
08e52fb49d
|
@ -30,6 +30,17 @@
|
|||
"The default StatusBar modeline.")
|
||||
|
||||
|
||||
(->cube smart-mode-line
|
||||
"Smart mode line is a pretty simple yet fantastic alternative
|
||||
to Emacs modeline."
|
||||
:straight (smart-mode-line :source melpa)
|
||||
:defer nil
|
||||
:init
|
||||
(progn
|
||||
(setq sml/theme 'respectful)
|
||||
(setq sml/no-confirm-load-theme t)
|
||||
(sml/setup)))
|
||||
|
||||
;; TODO: Break this into two cubes
|
||||
(defcube fg42/modeline-cube
|
||||
"Modeline cube"
|
||||
|
@ -59,14 +70,6 @@
|
|||
(:eval (string-trim (format-mode-line mode-line-modes)))
|
||||
mode-line-misc-info ))))
|
||||
|
||||
(fpkg/use smart-mode-line
|
||||
:straight (smart-mode-line :source melpa)
|
||||
:defer nil
|
||||
:init
|
||||
(progn
|
||||
(setq sml/theme 'respectful)
|
||||
(setq sml/no-confirm-load-theme t)
|
||||
(sml/setup)))
|
||||
|
||||
(fpkg/use mini-modeline
|
||||
:straight (mini-modeline :repo "kiennq/emacs-mini-modeline"
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
(defvar fg42/-gc-cons-threshold 16777216
|
||||
"Value of GC threshold of FG42.")
|
||||
|
||||
(defvar fg42/initialized nil
|
||||
"A variable that indicates whether FG42 is passed initialization.")
|
||||
|
||||
(defun defer-garbage-collection ()
|
||||
"Disable garbage collection."
|
||||
(setq gc-cons-threshold fg42/-gc-cons-threshold))
|
||||
|
@ -53,7 +56,8 @@
|
|||
(run-hooks 'fg42/after-cubes-setup-hook)
|
||||
(run-hooks 'fg42/after-init-hook)
|
||||
(run-hooks 'fg42/after-initializing-theme-hook)
|
||||
(run-hooks 'fg42/ui-hook))))
|
||||
(run-hooks 'fg42/ui-hook)
|
||||
(setq fg42/initialized t))))
|
||||
|
||||
|
||||
(defun fg42/-startup-optimization ()
|
||||
|
|
|
@ -60,6 +60,14 @@ It will returen a pair in form of (body . props)."
|
|||
(cons body-list (cdr acc)))))
|
||||
|
||||
|
||||
(defun fg42/run-cube-after-initialization (f)
|
||||
"Run the given Cube body function F after FG42's initialization.
|
||||
If FG42 is already initialized, just run F."
|
||||
(if (null fg42/initialized)
|
||||
(add-hook 'fg42/-cubes-body-hook f)
|
||||
(funcall f)))
|
||||
|
||||
|
||||
(defmacro defcube (cube-name docs &rest props-n-body)
|
||||
"Define a cube with the given CUBE-NAME, DOCS and a PROPS-N-BODY.
|
||||
|
||||
|
@ -174,26 +182,26 @@ TODO: Docs"
|
|||
|
||||
(defun ,cube-name (&rest params)
|
||||
(interactive)
|
||||
(let ((ui-hook ,ui-hook)
|
||||
(init-hook ,init-hook))
|
||||
(let ((fg42/---f-sym
|
||||
(lambda ()
|
||||
(when (not (null ,ui-hook))
|
||||
(add-hook 'fg42/ui-hook #',ui-hook))
|
||||
|
||||
(when (not (null ,init-hook))
|
||||
(funcall #',init-hook params))
|
||||
|
||||
;; Run the cube internal after initialization or
|
||||
;; if Emacs is already up, just run it.
|
||||
(fg42/run-cube-after-initialization
|
||||
(lambda ()
|
||||
(,cube-name-internal params))))))
|
||||
|
||||
(if ,no-flag?
|
||||
(progn
|
||||
(when (not (null ui-hook))
|
||||
(add-hook 'fg42/ui-hook ui-hook))
|
||||
;; If no flag is need to control this cube
|
||||
(when (not (null init-hook))
|
||||
(funcall init-hook params))
|
||||
(add-hook 'fg42/-cubes-body-hook (lambda ()
|
||||
(,cube-name-internal params))))
|
||||
;; If no flag is need to control this cube
|
||||
(funcall fg42/---f-sym)
|
||||
;; Otherwise check for the flag to be active
|
||||
(if-flag ,flag-var
|
||||
(progn
|
||||
(when (not (null ui-hook))
|
||||
(add-hook 'fg42/ui-hook ,ui-hook))
|
||||
(when (not (null init-hook))
|
||||
(funcall init-hook params))
|
||||
(add-hook 'fg42/-cubes-body-hook (lambda ()
|
||||
(,cube-name-internal params))))
|
||||
(funcall fg42/---f-sym)
|
||||
(fg42/info "The flag for '%s' cube is disabled. Skiping." ,(symbol-name cube-name))))))
|
||||
|
||||
;; Set the symbol-plist of the cube-name to its props
|
||||
|
@ -210,7 +218,8 @@ TODO: Docs"
|
|||
|
||||
(defmacro ->cube (pkg docs &rest body)
|
||||
"A wrapper to create a cube that use only a PKG.
|
||||
It passes the BODY to `fpkg/use'."
|
||||
It passes the BODY to `fpkg/use'.
|
||||
And passes DOCS to `defcube' as the cube documentation."
|
||||
(declare (indent defun) (doc-string 2))
|
||||
`(defcube ,(intern (format "fg42/%s-cube" pkg))
|
||||
,docs
|
||||
|
|
|
@ -884,8 +884,12 @@ and to enable it we can pass a positive integer.
|
|||
- ~minor-mode-list~: The value of this variable is a list of all minor mode commands.
|
||||
* Episode 14 - Editing Modes, Part 2
|
||||
** Quick overview:
|
||||
*** A simple minor mode
|
||||
*** Interactive functions
|
||||
*** Hooks
|
||||
*** Keymaps
|
||||
*** Interactive functions
|
||||
** A quick and useless minor mode
|
||||
** Let's do it
|
||||
** Resources:
|
||||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Headers
|
||||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Hooks.html
|
||||
- https://www.gnu.org/software/emacs/manual/html_node/elisp/Keymaps.html
|
||||
|
|
Loading…
Reference in New Issue