Skip to content

Commit

Permalink
ensure image input is non-nil
Browse files Browse the repository at this point in the history
  • Loading branch information
tillydray committed Oct 30, 2024
1 parent 895aec2 commit 407ce22
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions org-ai-openai-image-query.el
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,22 @@ Calls CALLBACK with the response."

(defun org-ai--get-image-path-or-url ()
"Prompt the user for a non-empty image path or URL."
;; TODO ensure non-nil
(let ((default (or (thing-at-point 'url)
(thing-at-point 'filename))))
(read-string (if default
(format "Enter image URL or file path (default %s): " default)
"Enter image URL or file path: ")
nil 'minibuffer-history default)))
(thing-at-point 'filename)))
(input ""))
(while (string-empty-p input)
(setq input
(read-string (if default
(format "Enter image URL or file path (default %s): " default)
"Enter image URL or file path: ")
nil 'minibuffer-history default))
(if (string-empty-p input)
(if default
(setq input default)
(progn
(message "Input cannot be empty.")
(sit-for 1)))))
input))

(defun org-ai--get-question ()
"Prompt the user for a non-empty question."
Expand Down

0 comments on commit 407ce22

Please sign in to comment.