I have an Emacs command like following:
(defun query-lisp (word)
(interactive "sType a word to query:")
(message "%s" (query word)))
The query
operation is a time-consuming operation. When this command is running Emacs blocks the whole frame. Is there a way to make Emacs run this command in the background or block only a single window such as the minibuffer?
You can run any Emacs command by name using M-x , whether or not any keys are bound to it. If you use M-x to run a command which also has a key binding, it displays a message to tell you about the key binding, before running the command.
You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size.
Emacs displays the buffer in a full-screen window. If you want to display one of the buffers in place of the buffer list, you can press f. To put a buffer in another window (i.e., one not occupied by the buffer list), type o. Emacs displays the buffer in the other window and puts the cursor there.
When you want to leave Emacs for a short time, type a C-z and Emacs will be suspended. To get back into Emacs, type %emacs at the shell prompt. To quit Emacs permanently, type C-x C-c.
If you plan to use an external process (which you have indicated in a comment to another question), you can use the following:
(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
This will return a process object. You can either send the output to a buffer, or you could attach a filter function to the process. In the latter case, this is a function that is called every time your process emits any output.
In addition, you could attach a sentinel function to your process. This function is called everytime the status of your process changes, this is useful to find out when it has exited.
There are several examples of the above in the source code of Emacs, one such example is compile.el
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With