Fork me on GitHub
#emacs
<
2021-03-26
>
teodorlu14:03:10

Hello! Another newbie Emacs Lisp question. I'm trying to launch an external program from Emacs. I found async-shell-command, which seems to be doing what I want. But I just want my app launched, I don't want to see any more buffers. From the docstring, I think that should be possible. I've managed to evaluate display-buffer-alist, and got a lot of values. Do I need to imperatively change this in-place in order to do what I want? Or is there an equivalent to Clojure's binding? Or can I just pass in an argument and I've misread the docs? Any advice is appreciated! > You can configure `async-shell-command-buffer' to specify what to do > when the `*Async Shell Command*' buffer is already taken by another > running shell command. To run COMMAND without displaying the output > in a window you can configure `display-buffer-alist' to use the action > display-buffer-no-window' for the buffer *Async Shell Command*'.

teodorlu15:03:02

I've got this now:

(defun teod/shell ()
  (interactive)
  (async-shell-command "th-terminal"))
, but when I run it, I'm getting an empty *Async Shell Command* buffer that I'd like to avoid.

hindol15:03:36

Do you want Emacs to control the lifecycle of the external process or do you just want a fire and forget process?

teodorlu15:03:46

fire and forget please.

hindol15:03:58

I mean, should the process shutdown when emacs is stopped?

hindol15:03:41

If you want your process to live beyond Emacs, it may be simpler to start it outside Emacs.

Phil Shapiro15:03:52

I think start-process is what you want.

(start-process "test" "ls" nil)

πŸ‘ 3
πŸ’― 3
Phil Shapiro15:03:15

If you don’t want it to close when emacs exits, nohup might work.

hindol15:03:37

call-process if you want to completely detach. https://www.emacswiki.org/emacs/ExecuteExternalCommand

πŸ’― 3
teodorlu15:03:33

Just want to say that I really appreciate the pointers, digging through docs and trying things out now :thumbsup:

teodorlu15:03:23

(start-process "RUN" "RUN" "nohup" "th-terminal")
Seems promising. Trying to understand how to use call-process now.

hindol15:03:59

I am no Elisp programmer myself, but I like to dig around when I see an interesting question. Thanks to you, I am also learning new things, πŸ™‚

πŸ˜„ 3
πŸ™Œ 6
hindol15:03:47

With display-buffer-alist, you can hide (or control other aspects of) any buffers matching a specific RegEx. You can append to the alist your own RegEx and configs. alist is kind of like a hash map. This is one key-value pair for example,

("^\\*Command Line"
  (+popup-buffer)
  (actions)
  (side . bottom)
  (size . 8)
  (window-width . 40)
  (window-height . 0.16)
  (slot)
  (vslot)
  (window-parameters
   (ttl . 5)
   (quit . t)
   (select . ignore)
   (modeline)
   (autosave)))
And the configs will apply to any buffer names matching the "^\\*Command Line" RegEx.

πŸ’― 3
πŸŽ‰ 3
teodorlu16:03:11

Also seems to do what I want without going through nohup:

(call-process "th-terminal" nil 0)

πŸ‘ 3