Shutting Down the Emacs Minibus

I have a function that runs programs asynchronously:

(defun app (app-name) (interactive "sRun application: ") (async-shell-command app-name)) 

And I have a list of all executables from which to choose. I want the app function to work as switch-to-buffer , providing a TAB termination for the user. How to use minibuffer padding in Emacs?

+6
source share
2 answers

Use the completing-read command. The function will look like

 (defun app () (interactive) (let ((app-name (completing-read "Run application: " program-list))) (async-shell-command app-name))) 

It might be more idiomatic to use interactive instead of assigning a variable according to Emacs Lisp Idioms: user input request

 (defun app (app-name) (interactive (list (completing-read "Run application: " app-list))) (async-shell-command app-name)) 

You can also use (start-process app-name nil app-name) instead of (async-shell-command app-name) if you do not need an output process according to Run the program from Emacs and do not wait for the exit .


See Minibuffer Termination for more ideas on termination in Emacs and Asynchronous Processes for invoking processes from Emacs, as in the GNU manual.

+8
source

If you want to finish working with possible shell commands without having to maintain a list yourself, and you are using Emacs 23 or later, you can use read-shell-command :

 (defun app (app-name) (interactive (list (read-shell-command "Run application: "))) (async-shell-command app-name)) 
+4
source

Source: https://habr.com/ru/post/921395/


All Articles