From 98b5a6d30381fb1ca912c75ec812b2a3bd24bb5d Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 15 Jan 2024 09:44:45 +0200 Subject: [PATCH 1/4] command-commands: Fix indentation. --- source/command-commands.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/command-commands.lisp b/source/command-commands.lisp index 1c22dc5bc6b..0de816010b7 100644 --- a/source/command-commands.lisp +++ b/source/command-commands.lisp @@ -320,8 +320,8 @@ User input is evaluated Lisp." `(("Name" ,(str:downcase (hooks:name handler))))) (define-class disabled-handler-source (handler-source) - ((prompter:constructor (lambda (source) - (hooks:disabled-handlers (hook source)))))) + ((prompter:constructor (lambda (source) (hooks:disabled-handlers (hook source)))))) + (define-command-global disable-hook-handler () "Remove handler(s) from a hook." From 8c7ecb334ae517da6013dab7b9896857306abf5b Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 15 Jan 2024 09:44:13 +0200 Subject: [PATCH 2/4] command-commands(hook-source): Refactor. --- source/command-commands.lisp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/command-commands.lisp b/source/command-commands.lisp index 0de816010b7..e0a78c4b54c 100644 --- a/source/command-commands.lisp +++ b/source/command-commands.lisp @@ -301,12 +301,12 @@ User input is evaluated Lisp." (define-class hook-source (prompter:source) ((prompter:name "Hooks") - (prompter:constructor (get-hooks)))) + (prompter:constructor (get-hooks)) + (prompter:actions-on-return (lambda-mapped-command value)))) (defmethod prompter:object-attributes ((hook-description hook-description) (source hook-source)) (declare (ignore source)) - `(("Name" ,(name hook-description)) - ("Value" ,(value hook-description)))) + `(("Name" ,(name hook-description)))) (define-class handler-source (prompter:source) ((prompter:name "Handlers") From 126d85688d7a084c849cdd543042eefcfb6be830 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 15 Jan 2024 09:45:10 +0200 Subject: [PATCH 3/4] command-commands(handler-source): Fix display of handlers. --- source/command-commands.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/command-commands.lisp b/source/command-commands.lisp index e0a78c4b54c..92ba4b9efc6 100644 --- a/source/command-commands.lisp +++ b/source/command-commands.lisp @@ -315,7 +315,7 @@ User input is evaluated Lisp." :documentation "The hook for which to retrieve handlers for.") (prompter:constructor (lambda (source) (hooks:handlers (hook source)))))) -(defmethod prompter:object-attributes ((handler hooks:handler) (source handler-source)) +(defmethod prompter:object-attributes ((handler symbol) (source handler-source)) (declare (ignore source)) `(("Name" ,(str:downcase (hooks:name handler))))) From 10303f5c81596457681accf8ef81d96d67573744 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Mon, 15 Jan 2024 09:45:37 +0200 Subject: [PATCH 4/4] command-commands: Refactor {enable,disable}-hook-handler commands. --- source/command-commands.lisp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/source/command-commands.lisp b/source/command-commands.lisp index 92ba4b9efc6..b6206bb9548 100644 --- a/source/command-commands.lisp +++ b/source/command-commands.lisp @@ -322,25 +322,23 @@ User input is evaluated Lisp." (define-class disabled-handler-source (handler-source) ((prompter:constructor (lambda (source) (hooks:disabled-handlers (hook source)))))) +(defun manage-hook-handler (action) + (let ((hook (prompt1 :prompt "Hook" + :sources 'hook-source))) + (funcall (case action + (:enable #'hooks:enable-hook) + (:disable #'hooks:disable-hook)) + hook + (prompt1 :prompt "Handler" + :sources (make-instance (case action + (:enable 'disabled-handler-source) + (:disable 'handler-source)) + :hook hook))))) (define-command-global disable-hook-handler () - "Remove handler(s) from a hook." - (let* ((hook-desc (prompt1 - :prompt "Hook where to disable handler" - :sources 'hook-source)) - (handler (prompt1 - :prompt (format nil "Disable handler from ~a" (name hook-desc)) - :sources (make-instance 'handler-source - :hook (value hook-desc))))) - (hooks:disable-hook (value hook-desc) handler))) + "Remove handler of a hook." + (manage-hook-handler :disable)) (define-command-global enable-hook-handler () - "Enable handler(s) from a hook." - (let* ((hook-desc (prompt1 - :prompt "Hook where to enable handler" - :sources 'hook-source)) - (handler (prompt1 - :prompt (format nil "Enable handler from ~a" (name hook-desc)) - :sources (make-instance 'disabled-handler-source - :hook (value hook-desc))))) - (hooks:enable-hook (value hook-desc) handler))) + "Add handler of a hook." + (manage-hook-handler :enable))