5

setenv-internal and setenv change the list stored in process-environment (as local or special variable) by side-effects. It does not help if you assign the list (pointer) to a local variable process-environment. You still have only a single list for the process-environment which is just bound to two variables -- the global variable process-environment and ...


5

You're looking for (call-process-shell-command "echo ${GOPATH}" nil t nil). In this case, ${PATH} is syntax defined by a shell, not a native call, so you'll need to invoke a shell to interpret it. However, you may be interested in (insert (getenv "GOPATH")) which is considerably more direct, as it simply reads the environment instead of spawning a shell to ...


4

I just found this: Proxy shell designed for use with Emacs on Windows 95 and NT. [...] The main function is simply to process the "-c string" option in the way /bin/sh does, since the standard Windows command shells use the convention that everything after "/c" (the Windows equivalent of "-c") is the input string. Personally, I don't see cases where ...


3

You've quoted the list: :command '("sh" "-c" body) So you have passed it a symbol body not the string value of the variable. Try: :command (list "sh" "-c" body) or: :command `("sh" "-c" ,body) Either of which cause body to be evaluated to its string value.


3

You can use call-process the same way as you did, but just replace the third argument by 0. If the third argument is 0, Emacs don't wait for the process and quit without killing it. SHELL-PROMPT> emacs -Q --batch --eval '(call-process "okular" nil 0 nil)'


2

I would like to run convert - -draw 'rectangle 0,0,100,100' - Note that you're quoting for the shell there, so that it will not break that argument into two, on account of the space. For example I tried (call-process-region (point-min) (point-max) "convert" t t nil "-" "-draw" "'rectangle 0,0,50,50'" "-") ...


2

There are several ways of copying text between programs on Linux. I'm just guessing that you're using Linux, but I don't think that this problem could occur on Windows or OSX. I also surmise that you're running Emacs as an X Windows application, not inside a terminal, else you wouldn't have this problem. The first is by selecting text in program A and ...


2

Use the system shell, e.g., M-! ls | wc, there are many other APIs such as shell-command-to-string, call-process-shell-command and start-process-shell-command. An idea is emulating pipe like the following, it is slow since the second process won't run until the first is done. Though it's possible to use asynchronous process + process filter to avoiding ...


2

The c-function call-process is the basis for creating synchronous processes in Emacs. So you don't get more with any other functions. The info page (elisp) Synchronous Processes contains the following section: You can’t directly specify a buffer to put the error output in; that is too difficult to implement. But you can achieve ...


2

The "let binding" way is the following (notice that contrary to Tobias's answer, this does not involve any copying or "set"ting): (let ((process-environment (cons "HOME" (cons (concat "OLDHOME=" (getenv "HOME")) process-environment)))) (start-process "proc" (current-buffer) ...))


2

I recommend using call-process instead of shell-command: (defun open-a-file () (interactive) (call-process "xdg-open" nil 0 nil (read-file-name "Open: "))) One large difference between the two is that call-process does not invoke a shell, and thus does not accept shell syntax. It also takes all of the arguments separately; they do ...


1

Here's a somewhat silly implementation of a function that does a call-process and returns its pid (sort-of): (defun call-process-pid () (let (l1 l2) (setq l1 (list-system-processes)) (call-process "sleep" nil 0 nil "60") (setq l2 (list-system-processes)) (cl-set-difference l2 l1))) It's a somewhat cleaner way of doing a ...


1

You can use something like the following with M-|: cat > tmp.txt && python -m doctest -v tmp.txt


Only top voted, non community-wiki answers of a minimum length are eligible