diff --git a/source/command.lisp b/source/command.lisp index c5ead9dcb9a6..37ce8663699c 100644 --- a/source/command.lisp +++ b/source/command.lisp @@ -339,7 +339,7 @@ With MODE-SYMBOLS and GLOBAL-P, include global commands." (with-current-buffer (current-buffer) (let ((*interactive-p* t)) (handler-case (apply #'funcall command args) - (prompt-buffer-canceled () + (prompter:canceled () (log:debug "Prompt buffer interrupted") nil))))) diff --git a/source/concurrency.lisp b/source/concurrency.lisp index 7f980ded226a..3ad7508df88f 100644 --- a/source/concurrency.lisp +++ b/source/concurrency.lisp @@ -26,7 +26,7 @@ raised condition." (alex:with-gensyms (c sub-c) `(if (or *run-from-repl-p* *debug-on-error*) (handler-case (progn ,@body) - (prompt-buffer-canceled () + (prompter:canceled () (log:debug "Prompt buffer interrupted"))) (ignore-errors (handler-bind diff --git a/source/conditions.lisp b/source/conditions.lisp index c47dccc8e222..81363e7988be 100644 --- a/source/conditions.lisp +++ b/source/conditions.lisp @@ -20,8 +20,9 @@ It should abort the ongoing command, but not the whole process.")) ((context :initarg :context :reader context))) (export-always 'prompt-buffer-canceled) -(define-condition prompt-buffer-canceled (error) - ()) +(define-condition prompt-buffer-canceled (prompter:canceled) ; TODO: Remove with 4.0.0. + () + (:documentation "Obsolete. Use `prompter:canceled' instead.")) (export-always 'prompt-buffer-non-interactive) (define-condition prompt-buffer-non-interactive (error) ((name :initarg :name :accessor name)) diff --git a/source/configuration.lisp b/source/configuration.lisp index af8e291c7465..2a10873535d0 100644 --- a/source/configuration.lisp +++ b/source/configuration.lisp @@ -445,7 +445,7 @@ Examples: ,@(when explicit-no-p (list :no no))) :hide-suggestion-count-p t) - (prompt-buffer-canceled () nil)))) + (prompter:canceled () nil)))) (if answer ,yes-form ,no-form))) diff --git a/source/describe.lisp b/source/describe.lisp index 295d3e69e85a..11f894373e3a 100644 --- a/source/describe.lisp +++ b/source/describe.lisp @@ -347,7 +347,7 @@ Otherwise prompt for matches." (prompt1 :prompt (format nil "Set ~a to" variable) :sources 'prompter:raw-source)))) - (prompt-buffer-canceled nil)))) + (prompter:canceled nil)))) "Change value") (:p (:raw (value->html (symbol-value variable)))) (:nsection diff --git a/source/inspector.lisp b/source/inspector.lisp index 3189b1da214b..dd92dc95393c 100644 --- a/source/inspector.lisp +++ b/source/inspector.lisp @@ -280,7 +280,7 @@ values in help buffers, REPL and elsewhere.")) (prompt1 :prompt (format nil "Set ~a to" slot-name) :sources 'prompter:raw-source)))) - (prompt-buffer-canceled nil)))) + (prompter:canceled nil)))) "change ")) (:dd (:raw (value->html (slot-value value slot-name) t))))) (:raw (escaped-literal-print value)))))) diff --git a/source/mode/prompt-buffer.lisp b/source/mode/prompt-buffer.lisp index 408e1f39da39..eaa948e0b93d 100644 --- a/source/mode/prompt-buffer.lisp +++ b/source/mode/prompt-buffer.lisp @@ -342,7 +342,7 @@ current unmarked suggestion." (prompter:actions-on-return first-prompt-buffer)) (progn (echo-warning "No actions to choose from.") - (error 'prompt-buffer-canceled)))) + (error 'prompt-buffer-canceled)))) ; TODO: Obsolete, switch to `promter:canceled' with 4.0.0. (defun prompt-buffer-actions-on-current-suggestion (&optional (window (current-window))) (sera:and-let* ((first-prompt-buffer (first (nyxt::active-prompt-buffers window)))) diff --git a/source/mode/small-web.lisp b/source/mode/small-web.lisp index c7bc98b4a976..fe4700453ad6 100644 --- a/source/mode/small-web.lisp +++ b/source/mode/small-web.lisp @@ -296,7 +296,7 @@ Implies that `small-web-mode' is enabled." (prompt1 :prompt meta :sources 'prompter:raw-source :invisible-input-p (eq status :sensitive-input)) - (nyxt::prompt-buffer-canceled () ""))))) + (prompter:canceled () ""))))) (buffer-load (str:concat url "?" text) :buffer buffer))) (:success (if (str:starts-with-p "text/gemini" meta) diff --git a/source/prompt-buffer.lisp b/source/prompt-buffer.lisp index f66f8c85e2e9..e0e1fd59d411 100644 --- a/source/prompt-buffer.lisp +++ b/source/prompt-buffer.lisp @@ -613,13 +613,8 @@ See `update-prompt-input' to update the changes visually." "Block and return PROMPT-BUFFER results." (when (prompt-buffer-p prompt-buffer) (show-prompt-buffer prompt-buffer) - (calispel:fair-alt - ((calispel:? (prompter:result-channel prompt-buffer) results) - (hide-prompt-buffer prompt-buffer) - results) - ((calispel:? (prompter:interrupt-channel prompt-buffer)) - (hide-prompt-buffer prompt-buffer) - (error 'prompt-buffer-canceled))))) + (unwind-protect (lpara:force (prompter:result-channel prompt-buffer)) + (hide-prompt-buffer prompt-buffer)))) (sera:eval-always (defvar %prompt-args (delete-duplicates @@ -647,23 +642,20 @@ See the documentation of `prompt-buffer' to know more about the options." (restart-case (error 'prompt-buffer-non-interactive :name prompter:prompt) (prompt-anyway () nil) - (cancel () (error 'prompt-buffer-canceled)))) + (cancel () (error 'prompter:canceled)))) (alex:when-let ((prompt-text (getf args :prompt))) (when (str:ends-with-p ":" prompt-text) (log:warn "Prompt text ~s should not end with a ':'." prompt-text) (setf (getf args :prompt) (string-right-trim (uiop:strcat ":" serapeum:whitespace) prompt-text)))) - (let ((prompt-object-channel (make-channel 1))) + (let ((prompt-promise (lpara:promise))) (ffi-within-renderer-thread *browser* (lambda () (let ((prompt-buffer (apply #'make-instance 'prompt-buffer (append args - (list - :window (current-window) - :result-channel (make-channel) - :interrupt-channel (make-channel)))))) - (calispel:! prompt-object-channel prompt-buffer)))) - (let ((new-prompt (calispel:? prompt-object-channel))) + (list :window (current-window)))))) + (lpara:fulfill prompt-promise prompt-buffer)))) + (let ((new-prompt (lpara:force prompt-promise))) (wait-on-prompt-buffer new-prompt))))) (export-always 'prompt1) diff --git a/source/renderer/gtk.lisp b/source/renderer/gtk.lisp index 72f2eb5fcff9..5e0702a609ca 100644 --- a/source/renderer/gtk.lisp +++ b/source/renderer/gtk.lisp @@ -1272,7 +1272,7 @@ the `active-buffer'." :extra-modes 'nyxt/mode/file-manager:file-manager-mode :sources (make-instance 'nyxt/mode/file-manager:file-source :enable-marks-p multiple)) - (prompt-buffer-canceled () + (prompter:canceled () nil))))) (if files (webkit:webkit-file-chooser-request-select-files @@ -1416,7 +1416,7 @@ the `active-buffer'." :prompt (webkit:webkit-script-dialog-get-message dialog) :input (webkit:webkit-script-dialog-prompt-get-default-text dialog) :sources 'prompter:raw-source) - (prompt-buffer-canceled () nil))))) + (prompter:canceled () nil))))) (if text (webkit:webkit-script-dialog-prompt-set-text dialog text) (progn