Skip to content

Commit

Permalink
mode/prompt-buffer: Add return-action-source.
Browse files Browse the repository at this point in the history
Rename from action-source to return-action-source to distinguish it from
selection-action-source.
  • Loading branch information
aadcg committed Sep 8, 2022
1 parent 6821395 commit 1c64590
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/mode/prompt-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ current unmarked selection."
(t (documentation action 'function)))))
"")))))

(define-class action-source (prompter:source)
;; TODO: Should return-actions be commands? For now, they can be either
;; commands or symbols.
(defun make-selection-action-suggestion (action &optional source input)
Expand All @@ -339,23 +338,24 @@ current unmarked selection."
;; :attributes
))

(define-class return-action-source (prompter:source)
((prompter:name "List of return-actions")
(prompter:constructor (prompt-buffer-return-actions))
(prompter:suggestion-maker 'make-action-suggestion)))

"Prompt for an action to run over PROMPT-BUFFER selection."
(define-class selection-action-source (prompter:source)
((prompter:name "List of selection-actions")
(prompter:constructor (prompt-buffer-selection-actions))
(prompter:suggestion-maker 'make-selection-action-suggestion)))

(define-command-prompt return-marks-action (prompt-buffer)
"Prompt for an action to run over PROMPT-BUFFER `prompter:marks'."
(if (equal (mapcar #'type-of (prompter:sources (current-prompt-buffer)))
'(action-source))
'(return-action-source))
(echo "Already displaying return-actions of previous prompt buffer.")
(let ((action (prompt1 :prompt "Action to run on selection"
:sources 'action-source)))
(when action
(prompter:return-selection prompt-buffer action)))))
(alex:when-let ((action (prompt1 :prompt "Action to run on selection"
:sources 'return-action-source)))
(prompter:return-selection prompt-buffer action))))

(define-command-prompt set-selection-action (prompt-buffer)
"Run one of `prompter:selection-actions' without closing PROMPT-BUFFER."
Expand Down

0 comments on commit 1c64590

Please sign in to comment.