To get user input for a shell script, I prepared an emacs-lisp source block.

#+name: get_text_from_user
#+begin_src emacs-lisp
    (let ((text (read-from-minibuffer "Enter some text> ")))
#+begin_src shell :noweb yes
    echo <<get_text_from_user()>>

This works, but the user is prompted for input a total of 3 times, instead of just once. How can this behavior be fixed?

-- Update --

The issue seems to be related to this configuration:

(defun my-org-confirm-babel-evaluate (lang body)
   (not (member lang '("shell" "emacs-lisp"))))
(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
  • 1
    I see no reason why the user is prompted 3 times and indeed when I try it out for myself, I cannot reproduce the behavior: I'm prompted once every time I C-c C-c the code block and whatever I type appears as the result each time. Do you get a result printed out? Do you get a "Code block evaluation complete" message? If you type a different string each time, what result is printed out?
    – NickD
    Aug 17, 2023 at 19:28
  • Can you provide a recipe for reproducing the behavior starting from emacs -q? AFAICT, the code you point to is not used above, so I'm not sure how exactly you pinned the problem to it. In particular, show the complete file and describe what you do as exactly as possible to get the behavior you describe.
    – NickD
    Aug 17, 2023 at 20:26
  • 1
    That code was not the problem. I deleted my comment with the wrong reference and updated the question. Aug 18, 2023 at 8:51
  • 1
    Now I can reproduce it - thanks!
    – NickD
    Aug 18, 2023 at 12:18


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.