Skip to main content
edited tags
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Is there a way to check whether cursor is in the prompt of read-multiple-choice, waiting for user's response?

I have tried (minibuffer-p) and (input-pending-p), but got no luck.

Code for testing (copy the code below to a new scratch-buffer and M-x eval-buffer RET):

(defun test-prompt ()
  ;; check if running `read-multiple-choice' exists
  (unless (or (minibufferp) (input-pending-p))
    (error "Test failed. \n\
You are supposed to be in the middle of `read-multiple-choice'.")))

(run-with-idle-timer 1 nil #'test-prompt)

(read-multiple-choice
 "Prompt: Which prebuilt binary to download? "
 '((?1 "amd64-GNU/Linux"
       "GNU/Linux on Intel/AMD x86_64 CPU")
   (?2 "amd64-macOS"
       "macOS on Intel/AMD x86_64 CPU")
   (?q "quit")))
(defun test-prompt ()
  ;; check if running `read-multiple-choice' exists
  (unless (or (minibufferp) (input-pending-p))
    (error "Test failed. \n\
You are supposed to be in the middle of `read-multiple-choice'.")))

(run-with-idle-timer 1 nil #'test-prompt)

(read-multiple-choice
 "Prompt: Which prebuilt binary to download? "
 '((?1 "amd64-GNU/Linux"
       "GNU/Linux on Intel/AMD x86_64 CPU")
   (?2 "amd64-macOS"
       "macOS on Intel/AMD x86_64 CPU")
   (?q "quit")))

If test-prompt were able to detect a running read-multiple-choice, it shouldn't have errored out.

Thanks for any help.

Is there a way to check whether cursor is in the prompt of read-multiple-choice, waiting for user's response?

I have tried (minibuffer-p) and (input-pending-p), but got no luck.

Code for testing (copy the code below to a new scratch-buffer and M-x eval-buffer RET):

(defun test-prompt ()
  ;; check if running `read-multiple-choice' exists
  (unless (or (minibufferp) (input-pending-p))
    (error "Test failed. \n\
You are supposed to be in the middle of `read-multiple-choice'.")))

(run-with-idle-timer 1 nil #'test-prompt)

(read-multiple-choice
 "Prompt: Which prebuilt binary to download? "
 '((?1 "amd64-GNU/Linux"
       "GNU/Linux on Intel/AMD x86_64 CPU")
   (?2 "amd64-macOS"
       "macOS on Intel/AMD x86_64 CPU")
   (?q "quit")))

If test-prompt were able to detect a running read-multiple-choice, it shouldn't have errored out.

Thanks for any help.

Is there a way to check whether cursor is in the prompt of read-multiple-choice, waiting for user's response?

I have tried (minibuffer-p) and (input-pending-p), but got no luck.

Code for testing (copy the code below to a new scratch-buffer and M-x eval-buffer RET):

(defun test-prompt ()
  ;; check if running `read-multiple-choice' exists
  (unless (or (minibufferp) (input-pending-p))
    (error "Test failed. \n\
You are supposed to be in the middle of `read-multiple-choice'.")))

(run-with-idle-timer 1 nil #'test-prompt)

(read-multiple-choice
 "Prompt: Which prebuilt binary to download? "
 '((?1 "amd64-GNU/Linux"
       "GNU/Linux on Intel/AMD x86_64 CPU")
   (?2 "amd64-macOS"
       "macOS on Intel/AMD x86_64 CPU")
   (?q "quit")))

If test-prompt were able to detect a running read-multiple-choice, it shouldn't have errored out.

Add new tags for this question
Link
Source Link

How to check whether cursor in the middle of `read-multiple-choice` process

Is there a way to check whether cursor is in the prompt of read-multiple-choice, waiting for user's response?

I have tried (minibuffer-p) and (input-pending-p), but got no luck.

Code for testing (copy the code below to a new scratch-buffer and M-x eval-buffer RET):

(defun test-prompt ()
  ;; check if running `read-multiple-choice' exists
  (unless (or (minibufferp) (input-pending-p))
    (error "Test failed. \n\
You are supposed to be in the middle of `read-multiple-choice'.")))

(run-with-idle-timer 1 nil #'test-prompt)

(read-multiple-choice
 "Prompt: Which prebuilt binary to download? "
 '((?1 "amd64-GNU/Linux"
       "GNU/Linux on Intel/AMD x86_64 CPU")
   (?2 "amd64-macOS"
       "macOS on Intel/AMD x86_64 CPU")
   (?q "quit")))

If test-prompt were able to detect a running read-multiple-choice, it shouldn't have errored out.

Thanks for any help.