1

Is there a popup input dialogue box for Emacs, which returns the string that a user enters? Maybe something that can be launched through the mini-buffer? Or through an elisp command/function?

4

yes-or-no-p provides this for yes/no answers (and it's often used cousin y-or-no-p).

Several arguments to the interactive macro can allow prompting for arguments when a function is called interactively (using M-x to call the function, binding a key to the function, or using call-interactively).

As mentioned in the documentation for interactive above, read-string will prompt the minibuffer for a string and return it to the caller.

Finally, completing-read can be used to prompt the user with options for completion. For instance, switch-to-buffer and find-file use wrapper functions around completing-read that provide a list of current buffers or the files in the current directory as candidate completions. completing-read then uses that list of candidates to prompt the user on what file or buffer to open.

  • 2
    Just to add to @dgtized answer, there are a bunch of read-* that will help do things like completion in the minibuffer. read-file-name for example will autocomplete a path like you'd see with C-x C-f (find-file). – elarson Oct 7 '14 at 20:02
  • A minor detail: y-or-n-p does not use the minibuffer. It reads an event (keypress). – Drew Oct 7 '14 at 21:21
1

interactive has several code characters which can be what you are looking for. If you write a function, you can specify that the user needs to provide a plain string, a buffer name, etc. All from the minibuffer.

If you want to provide completion look at ido-completing-read, from ido, to request user input anywhere in your function (and it's easy to use IMHO).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.