Improve depends-on macro to accept the pkg name as a symbol only
This commit is contained in:
parent
bb75c499e3
commit
5715a21cbd
|
@ -31,6 +31,9 @@
|
||||||
(require 'fg42/utils)
|
(require 'fg42/utils)
|
||||||
|
|
||||||
;; Variables -----------------------------
|
;; Variables -----------------------------
|
||||||
|
(defvar fg42/extensions '()
|
||||||
|
"A list of official FG42 extensions.")
|
||||||
|
|
||||||
(defvar activated-extensions ()
|
(defvar activated-extensions ()
|
||||||
"A list of all activated extensions.")
|
"A list of all activated extensions.")
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ with is the buffer."
|
||||||
|
|
||||||
(defmacro comment (&rest body)
|
(defmacro comment (&rest body)
|
||||||
"A macro similar to Clojure's comment macro that ignore the BODY."
|
"A macro similar to Clojure's comment macro that ignore the BODY."
|
||||||
(declare (indent 1))
|
(declare (indent 0))
|
||||||
`nil)
|
`nil)
|
||||||
|
|
||||||
|
|
||||||
|
|
46
lib/fpkg.el
46
lib/fpkg.el
|
@ -26,6 +26,8 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
|
(require 'fg42/extension)
|
||||||
|
(require 'fg42/utils)
|
||||||
(require 'fpkg/installers)
|
(require 'fpkg/installers)
|
||||||
|
|
||||||
;; Variables ---------------------------------
|
;; Variables ---------------------------------
|
||||||
|
@ -51,8 +53,6 @@
|
||||||
(defvar required-packages (make-hash-table)
|
(defvar required-packages (make-hash-table)
|
||||||
"A hash of `fg42-package structure representing required packages.")
|
"A hash of `fg42-package structure representing required packages.")
|
||||||
|
|
||||||
(defvar fg42/extensions '(devops-extension)
|
|
||||||
"A list of official FG42 extensions.")
|
|
||||||
|
|
||||||
;; Functions ----------------------------------
|
;; Functions ----------------------------------
|
||||||
(defun fpkg-initialize ()
|
(defun fpkg-initialize ()
|
||||||
|
@ -63,6 +63,7 @@
|
||||||
|
|
||||||
(make-directory fpkg-packages-path t)
|
(make-directory fpkg-packages-path t)
|
||||||
(setq straight-base-dir fpkg-packages-path)
|
(setq straight-base-dir fpkg-packages-path)
|
||||||
|
(setq straight-use-package-by-default t)
|
||||||
(if (not (file-exists-p bootstrap-file))
|
(if (not (file-exists-p bootstrap-file))
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
(url-retrieve-synchronously
|
(url-retrieve-synchronously
|
||||||
|
@ -72,46 +73,51 @@
|
||||||
(eval-print-last-sexp))
|
(eval-print-last-sexp))
|
||||||
(load bootstrap-file nil 'nomessage))))
|
(load bootstrap-file nil 'nomessage))))
|
||||||
|
|
||||||
(setq straight-use-package-by-default t)
|
|
||||||
(defun fpkg-initialize-once ()
|
(defun fpkg-initialize-once ()
|
||||||
"Initilize FPKG only once."
|
"Initilize FPKG only once."
|
||||||
(when (not fpkg-initilized-p)
|
(when (not fpkg-initilized-p)
|
||||||
(fpkg-initialize)
|
(fpkg-initialize)
|
||||||
(straight-use-package 'use-package)))
|
(straight-use-package 'use-package)))
|
||||||
|
|
||||||
|
|
||||||
(defun official-extension-p (args)
|
(defun official-extension-p (args)
|
||||||
"Predicate to say if ARGS is an official FG42 extension."
|
"Predicate to say if ARGS is an official FG42 extension."
|
||||||
(member args fg42/extensions))
|
(member args fg42/extensions))
|
||||||
|
|
||||||
|
|
||||||
(defun get-receipe (name)
|
(defun get-receipe (name)
|
||||||
"Get the receipe for given NAME if that is an official extension."
|
"Get the receipe for given NAME if that is an official extension."
|
||||||
(list name :host 'gitlab :repo (format "FG42/%s" name)))
|
(list name :host 'gitlab :repo (format "FG42/%s" name)))
|
||||||
|
|
||||||
|
|
||||||
(defmacro fg42-install-extension (args)
|
(defmacro fg42-install-extension (args)
|
||||||
"Install if given ARGS is an official extension."
|
"Install if given ARGS is an official extension."
|
||||||
|
;; TODO: Straight supports reciepe registery it might worth
|
||||||
|
;; using it.
|
||||||
(let ((reciepe (get-receipe args)))
|
(let ((reciepe (get-receipe args)))
|
||||||
`(use-package ,args :straight ,reciepe)))
|
`(use-package ,args :straight ,reciepe)))
|
||||||
|
|
||||||
|
|
||||||
(defun old-depends-on-calls-adapter (args)
|
(defmacro depends-on (pkgname &rest details)
|
||||||
(if (listp (car args))
|
"Install the given PKGNAME with the optional DETAILS."
|
||||||
(progn (add-to-list 'args (car (cdr (pop args)))) args))
|
(if (official-extension-p pkgname)
|
||||||
args)
|
`(fg42-install-extension ,(eval pkgname))
|
||||||
|
`(use-package ,(eval pkgname) ,@details)))
|
||||||
|
|
||||||
(defmacro depends-on (&rest args)
|
(comment
|
||||||
"Install given ARGS."
|
;; depends on now is a wrapper around use-package
|
||||||
(let ((adapted-args (old-depends-on-calls-adapter args)))
|
(macroexpand-1 '(depends-on 'exwm))
|
||||||
(if (official-extension-p (car args))
|
(macroexpand-1 '(depends-on 'go-mode :mode "\\.go\\'"))
|
||||||
`(fg42-install-extension ,@adapted-args)
|
(macroexpand-1 '(depends-on 'devops-extension))
|
||||||
`(use-package ,@adapted-args))))
|
(macroexpand-1 '(fg42-install-extension devops-extension))
|
||||||
|
;; compatible with old calls
|
||||||
|
(macroexpand-1 '(depends-on 'cyberpunk-theme))
|
||||||
|
;; official extension
|
||||||
|
(depends-on 'devops-extension)
|
||||||
|
;; 3rd party extension
|
||||||
|
(depends-on 'go-extension :straight (go-extension :host gitlab :repo "amirrezaask/go-extension")))
|
||||||
|
|
||||||
;; depends on now is a wrapper around use-package
|
|
||||||
;; (macroexpand-1 '(depends-on go-mode :mode "\\.go\\'"))
|
|
||||||
;; (macroexpand-1 '(depends-on devops-extension))
|
|
||||||
;; (macroexpand-1 '(fg42-install-extension devops-extension))
|
|
||||||
;; (depends-on 'cyberpunk-theme) ;; compatible with old calls
|
|
||||||
;; (depends-on devops-extension) ;; official extension
|
|
||||||
;; (depends-on go-extension :straight (go-extension :host gitlab :repo "amirrezaask/go-extension")) ;; 3rd party extension
|
|
||||||
|
|
||||||
(provide 'fpkg)
|
(provide 'fpkg)
|
||||||
;;; fpkg.el ends here
|
;;; fpkg.el ends here
|
||||||
|
|
Loading…
Reference in New Issue