aboutsummaryrefslogtreecommitdiff
path: root/src/combinator.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-03-22 09:38:57 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-03-22 09:38:57 -0700
commitf393eeebe8cf6a31ecc2160658bee3d2c895a98b (patch)
treeb6c85fc026ffafc58f3c1479efadebb8ba699934 /src/combinator.lisp
parent2063385338300dfb11cd1a681ba0ca9e7b1aaf37 (diff)
downloadconsfigurator-f393eeebe8cf6a31ecc2160658bee3d2c895a98b.tar.gz
untabify
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/combinator.lisp')
-rw-r--r--src/combinator.lisp130
1 files changed, 65 insertions, 65 deletions
diff --git a/src/combinator.lisp b/src/combinator.lisp
index 41c43db..c6e89e7 100644
--- a/src/combinator.lisp
+++ b/src/combinator.lisp
@@ -27,37 +27,37 @@
,@(and docstring `(,docstring))
,@declarations
(flet ((:retprop (&rest all &key args &allow-other-keys)
- (let ((psym (gensym ,(symbol-name name)))
- (setprop-args (remove-from-plist all :args)))
- (apply #'setprop psym setprop-args)
- (return-from ,name (list* psym args)))))
- ,@forms))))
+ (let ((psym (gensym ,(symbol-name name)))
+ (setprop-args (remove-from-plist all :args)))
+ (apply #'setprop psym setprop-args)
+ (return-from ,name (list* psym args)))))
+ ,@forms))))
(defmacro with-skip-failed-changes (&body forms)
`(handler-bind ((failed-change
- (lambda (c)
- (with-indented-inform
- (informat t
- (simple-condition-format-control c)
- (simple-condition-format-arguments c)))
- (invoke-restart 'skip-property))))
+ (lambda (c)
+ (with-indented-inform
+ (informat t
+ (simple-condition-format-control c)
+ (simple-condition-format-arguments c)))
+ (invoke-restart 'skip-property))))
,@forms))
(define-function-property-combinator eseqprops (&rest propapps)
(:retprop :type (collapse-types (mapcar #'propapptype propapps))
- :hostattrs (lambda () (mapc #'propappattrs propapps))
- :apply (lambda () (apply-and-print propapps))
- :unapply (lambda () (apply-and-print propapps t))))
+ :hostattrs (lambda () (mapc #'propappattrs propapps))
+ :apply (lambda () (apply-and-print propapps))
+ :unapply (lambda () (apply-and-print propapps t))))
(define-function-property-combinator seqprops (&rest propapps)
(:retprop :type (collapse-types (mapcar #'propapptype propapps))
- :hostattrs (lambda () (mapc #'propappattrs propapps))
- :apply (lambda ()
- (with-skip-failed-changes
- (apply-and-print propapps)))
- :unapply (lambda ()
- (with-skip-failed-changes
- (apply-and-print propapps t)))))
+ :hostattrs (lambda () (mapc #'propappattrs propapps))
+ :apply (lambda ()
+ (with-skip-failed-changes
+ (apply-and-print propapps)))
+ :unapply (lambda ()
+ (with-skip-failed-changes
+ (apply-and-print propapps t)))))
(defmacro with-requirements (propapp &body requirements)
"Apply PROPAPP only after applying each dependency in REQUIREMENTS.
@@ -67,46 +67,46 @@ apply the elements of REQUIREMENTS in reverse order."
(define-function-property-combinator silent-seqprops (&rest propapps)
(:retprop :type (collapse-types (mapcar #'propapptype propapps))
- :hostattrs (lambda () (mapc #'propappattrs propapps))
- :apply (lambda ()
- (with-skip-failed-changes
- (mapc #'propappapply propapps)))
- :unapply (lambda ()
- (with-skip-failed-changes
- (mapc #'propappunapply (reverse propapps))))))
+ :hostattrs (lambda () (mapc #'propappattrs propapps))
+ :apply (lambda ()
+ (with-skip-failed-changes
+ (mapc #'propappapply propapps)))
+ :unapply (lambda ()
+ (with-skip-failed-changes
+ (mapc #'propappunapply (reverse propapps))))))
;; note that the :FAILED-CHANGE value is only used within this function and
;; should not be returned by property subroutines, per the spec
(defun apply-and-print (propapps &optional unapply)
(dolist (pa (if unapply (reverse propapps) propapps))
(let* ((result (restart-case
- (with-indented-inform
- (if unapply (propappunapply pa) (propappapply pa)))
- (skip-property () :failed-change)))
- (status (case result
- (:no-change "ok")
- (:failed-change "failed")
- (t "done"))))
+ (with-indented-inform
+ (if unapply (propappunapply pa) (propappapply pa)))
+ (skip-property () :failed-change)))
+ (status (case result
+ (:no-change "ok")
+ (:failed-change "failed")
+ (t "done"))))
(informat t "~&~@[~A :: ~]~@[~A ... ~]~A~%"
- (get-hostname) (propappdesc pa) status))))
+ (get-hostname) (propappdesc pa) status))))
(define-function-property-combinator unapply (propapp)
(destructuring-bind (psym . args) propapp
(:retprop :type (proptype psym)
- :lambda (proplambda psym)
- :desc (lambda (&rest args)
- (strcat "Unapply: " (apply #'propdesc psym args)))
- :check (when-let ((check (get psym 'check)))
- (complement check))
- :hostattrs (lambda (&rest args)
- ;; run the :HOSTATTRS subroutine but throw away any
- ;; new hostattrs; when unapplying, the :HOSTATTRS
- ;; subroutine is only to check compatibility
- (with-preserve-hostattrs
- (apply #'propattrs psym args)))
- :apply (get psym 'unapply)
- :unapply (get psym 'papply)
- :args args)))
+ :lambda (proplambda psym)
+ :desc (lambda (&rest args)
+ (strcat "Unapply: " (apply #'propdesc psym args)))
+ :check (when-let ((check (get psym 'check)))
+ (complement check))
+ :hostattrs (lambda (&rest args)
+ ;; run the :HOSTATTRS subroutine but throw away any
+ ;; new hostattrs; when unapplying, the :HOSTATTRS
+ ;; subroutine is only to check compatibility
+ (with-preserve-hostattrs
+ (apply #'propattrs psym args)))
+ :apply (get psym 'unapply)
+ :unapply (get psym 'papply)
+ :args args)))
(defmacro on-change (propapp &body on-change)
"If applying PROPAPP makes a change, also apply each of of the propapps
@@ -115,18 +115,18 @@ ON-CHANGE in order."
(define-function-property-combinator on-change* (propapp &rest propapps)
(:retprop :type (collapse-types (propapptype propapp)
- (mapcar #'propapptype propapps))
- :desc (get (car propapp) 'desc)
- :hostattrs (lambda (&rest args)
- (apply #'propattrs (car propapp) args))
- :apply (lambda (&rest args)
- (unless (eq (propappapply (cons (car propapp) args))
- :no-change)
- (dolist (propapp propapps)
- (propappapply propapp))))
- :unapply (lambda (&rest args)
- (unless (eq (propappunapply (cons (car propapp) args))
- :no-change)
- (dolist (propapp (reverse propapps))
- (propappunapply propapp))))
- :args (cdr propapp)))
+ (mapcar #'propapptype propapps))
+ :desc (get (car propapp) 'desc)
+ :hostattrs (lambda (&rest args)
+ (apply #'propattrs (car propapp) args))
+ :apply (lambda (&rest args)
+ (unless (eq (propappapply (cons (car propapp) args))
+ :no-change)
+ (dolist (propapp propapps)
+ (propappapply propapp))))
+ :unapply (lambda (&rest args)
+ (unless (eq (propappunapply (cons (car propapp) args))
+ :no-change)
+ (dolist (propapp (reverse propapps))
+ (propappunapply propapp))))
+ :args (cdr propapp)))