forked from FG42/FG42
Add the :flag-default to cubes to activate them by default
This commit is contained in:
parent
a29d364257
commit
08e9826818
|
@ -25,9 +25,11 @@
|
||||||
(require 'fg42/cube)
|
(require 'fg42/cube)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defcube fg42/projectile-cube
|
(defcube fg42/projectile-cube
|
||||||
(:docs "cubes/fg42/projectile-cube.org"
|
(:docs "cubes/fg42/projectile-cube.org"
|
||||||
:flag projectile)
|
:flag projectile
|
||||||
|
:flag-default t)
|
||||||
|
|
||||||
(let ((project-dirs (or (plist-get fg42/projectile-cube-params :project-dirs)
|
(let ((project-dirs (or (plist-get fg42/projectile-cube-params :project-dirs)
|
||||||
())))
|
())))
|
||||||
|
@ -48,5 +50,7 @@
|
||||||
:after projectile)))
|
:after projectile)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'cubes/project)
|
(provide 'cubes/project)
|
||||||
;;; project.el ends here
|
;;; project.el ends here
|
||||||
|
|
|
@ -52,13 +52,15 @@
|
||||||
(flag-var (or (plist-get props :flag) cube-name))
|
(flag-var (or (plist-get props :flag) cube-name))
|
||||||
(flag-docstring-var (or (plist-get props :flag-doc)
|
(flag-docstring-var (or (plist-get props :flag-doc)
|
||||||
(format "The flag to enable/disable the '%s' cube." cube-name)))
|
(format "The flag to enable/disable the '%s' cube." cube-name)))
|
||||||
|
(flag-default (plist-get props :flag-default))
|
||||||
|
(flag-conflict (plist-get props :conflicts-with))
|
||||||
(no-flag? (or (plist-get props :no-flag) ())))
|
(no-flag? (or (plist-get props :no-flag) ())))
|
||||||
|
|
||||||
`(progn
|
`(progn
|
||||||
|
|
||||||
;; Create a new flag for each cube to control the cubes systemwide.
|
;; Create a new flag for each cube to control the cubes systemwide.
|
||||||
(when (not ,no-flag?)
|
(when (not ,no-flag?)
|
||||||
(defflag ,flag-var ,flag-docstring-var))
|
(defflag ,flag-var ,flag-docstring-var ,flag-default))
|
||||||
|
|
||||||
;; Params variable contains the list of params the is passed to
|
;; Params variable contains the list of params the is passed to
|
||||||
;; the current cube call
|
;; the current cube call
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(require 'cl-lib)
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'fg42/core)
|
(require 'fg42/core)
|
||||||
|
|
||||||
|
@ -44,15 +45,16 @@ the documentation of each flag simply use \\[describe-flag]."
|
||||||
:tag "FG42 Flags")
|
:tag "FG42 Flags")
|
||||||
|
|
||||||
|
|
||||||
(defmacro use-flags (&rest flags)
|
(defmacro use-flags (flags)
|
||||||
"Set the given FLAGS to activate their functionalities in FG42."
|
"Set the given FLAGS to activate their functionalities in FG42."
|
||||||
(setq fg42/flags flags)
|
`(progn
|
||||||
t)
|
(setq fg42/flags ,flags)
|
||||||
|
t))
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/-merge-flags (flags-set &rest new-flags)
|
(defun fg42/-merge-flags (flags-set &rest new-flags)
|
||||||
"Merge the given NEW-FLAGS into the FLAGS-SET and return the result."
|
"Merge the given NEW-FLAGS into the FLAGS-SET and return the result."
|
||||||
(remove-duplicates
|
(cl-remove-duplicates
|
||||||
(seq-reduce
|
(seq-reduce
|
||||||
(lambda (result flag)
|
(lambda (result flag)
|
||||||
(let ((flag-str (symbol-name flag)))
|
(let ((flag-str (symbol-name flag)))
|
||||||
|
@ -80,6 +82,11 @@ For example, `(fg42/merge-flags (list f1 f2 f3) f4 -f2)' will return `(f1 f3 f4)
|
||||||
`(fg42/-merge-flags ,flags-set ,@(mapcar (lambda (x) `',x) new-flags)))
|
`(fg42/-merge-flags ,flags-set ,@(mapcar (lambda (x) `',x) new-flags)))
|
||||||
|
|
||||||
|
|
||||||
|
(defmacro fg42/merge-with-default-flags (&rest new-flags)
|
||||||
|
"Merge the given list of NEW-FLAGS with default flags of FG42 and return the new set."
|
||||||
|
`(fg42/merge-flags fg42/flags ,@new-flags))
|
||||||
|
|
||||||
|
|
||||||
(defmacro defflag (flag-name docstring &optional default-value)
|
(defmacro defflag (flag-name docstring &optional default-value)
|
||||||
"Define a new flag FLAG-NAME with the given DOCSTRING.
|
"Define a new flag FLAG-NAME with the given DOCSTRING.
|
||||||
If the DEFAULT-VALUE is a non nil value, then the flag will be
|
If the DEFAULT-VALUE is a non nil value, then the flag will be
|
||||||
|
|
Loading…
Reference in New Issue