Skip to content

Commit

Permalink
user-classes: Remove pre-customize-hook---premature optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
aartaka committed Dec 6, 2023
1 parent 123d408 commit 09a5e73
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions source/configuration-commands.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ On error, return the condition as a first value and the backtrace as second valu
(define-command clean-configuration ()
"Clean all the user configuration created with `define-configuration' or `customize-instance'."
(dolist (class (sera:filter #'user-class-p (sym:package-classes* (nyxt-packages))))
(setf (hooks:handlers-alist (slot-value class 'customize-hook)) nil)
(setf (hooks:handlers-alist (slot-value class 'pre-customize-hook)) nil))
(setf (hooks:handlers-alist (slot-value class 'customize-hook)) nil))
(dolist (method (mopu:generic-function-methods #'customize-instance))
(unless (or (equal (list (find-class t)) ; Don't remove default method.
(mopu:method-specializers method))
Expand Down
4 changes: 1 addition & 3 deletions source/configuration.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ To discover the default value of a slot or all slots of a class, use the
when slot
collect
`(let ((,hook (slot-value (find-class (quote ,class))
(quote ,(if nyxt-internal-config-p
'nyxt::pre-customize-hook
'nyxt::customize-hook))))
'nyxt::customize-hook))
(,handler (make-instance
'hooks:handler
:fn (lambda (object)
Expand Down
6 changes: 1 addition & 5 deletions source/user-classes.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
Reserved for `define-configuration'.
Prefer `define-configuration' and `customize-instance' instead.")
(pre-customize-hook :initform (make-instance 'hooks:hook-any)
:accessor pre-customize-hook
:documentation "Internal hook reserved for Nyxt core `%define-configuration'."))
Prefer `define-configuration' and `customize-instance' instead."))
(:documentation "Classes using this metaclass will call `customize-instance'
on instantiation.
This is useful to expose a class configuration knob to the user.
Expand Down Expand Up @@ -71,7 +68,6 @@ Do not specialize the standard method in public code, prefer
:around ((class user-mixin-class) &rest initargs &key &allow-other-keys)
(sera:lret ((initialized-object (call-next-method)))
(mapcar (lambda (class)
(hooks:run-hook (slot-value class 'pre-customize-hook) initialized-object)
(hooks:run-hook (slot-value class 'customize-hook) initialized-object))
(sera:filter #'user-class-p (cons class (mopu:superclasses class))))
(apply #'customize-instance initialized-object initargs)))
Expand Down

0 comments on commit 09a5e73

Please sign in to comment.