From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bostjan Vilfan Newsgroups: gmane.emacs.help Subject: problem with call-process function Date: Mon, 30 Nov 2015 12:28:44 -0500 Message-ID: <1123318547.39321.1448904524817.JavaMail.help@alum.mit.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_39320_1278450917.1448904524816" X-Trace: ger.gmane.org 1448906661 14163 80.91.229.3 (30 Nov 2015 18:04:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Nov 2015 18:04:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 30 19:04:09 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a3So2-0000st-P6 for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Nov 2015 19:04:07 +0100 Original-Received: from localhost ([::1]:42556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3So1-00035T-NZ for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Nov 2015 13:04:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Sno-00035N-DG for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 13:03:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3Snk-0007qV-B5 for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 13:03:52 -0500 Original-Received: from dmz-mailsec-scanner-3.mit.edu ([18.9.25.14]:58792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3Snk-0007qO-6c for help-gnu-emacs@gnu.org; Mon, 30 Nov 2015 13:03:48 -0500 X-AuditID: 1209190e-f79046d0000036c0-e8-565c874eb55d Original-Received: from mailhub-2.mit.edu ( [18.7.62.30]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 0F.41.14016.E478C565; Mon, 30 Nov 2015 12:28:46 -0500 (EST) Original-Received: from outgoing.mit.edu (outgoing-1.mit.edu [18.9.28.12]) by mailhub-2.mit.edu (8.13.8/8.9.2) with ESMTP id tAUHSjhZ004133 for ; Mon, 30 Nov 2015 12:28:46 -0500 Original-Received: from outgoing-alum.mit.edu (outgoing-alum.mit.edu [18.7.68.33]) ) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id tAUHSjLv007648 for ; Mon, 30 Nov 2015 12:28:45 -0500 Original-Received: from brunch.MIT.EDU (brunch.mit.edu [18.9.62.90]) by outgoing-alum.mit.edu (8.13.8) with ESMTP id tAUHSjBG001578; Mon, 30 Nov 2015 12:28:45 -0500 Original-Received: from brunch.MIT.EDU (localhost [127.0.0.1]) by brunch.MIT.EDU (8.14.4/8.14.4) with ESMTP id tAUHSiRN029578 for ; Mon, 30 Nov 2015 12:28:44 -0500 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRmVeSWpSXmKPExsUixG4np+vXHhNmcKNJw2LnzTdsDowebdPM AhijuGxSUnMyy1KL9O0SuDI2/jYpOKRfse2oeANjg3IXIyeHhICJxL4v15kgbDGJC/fWs3Ux cnEICcxjkuhu/M4K4RxhlLi6ZScjhHOBUeL7go9MEM5cRonuazPZIZxtjBIzfn5mAxnGIqAq ce3hZBYQm01AR+LeqivsILaIgJTE+TUnGEFsXgF3iXtNy8BsYQFtif5nP1kh4oISJ2c+Aetl FgiTmLj5CusERr5ZSFKzkKRmMXIA2eoS6+cJQYS1JZYtfM28gJFlFaNsSm6Vbm5iZk5xarJu cXJiXl5qka6xXm5miV5qSukmRlDocUry7WD8elDpEKMAB6MSD6+EWXSYEGtiWXFl7iFGSQ4m JVFepdqYMCG+pPyUyozE4oz4otKc1OJDjBIczEoivLtzgXK8KYmVValF+TApaQ4WJXHeuV98 w4QE0hNLUrNTUwtSi2CyMhwcShK8Km1AjYJFqempFWmZOSUIaSYOTpDhPEDDFUFqeIsLEnOL M9Mh8qcYFaXEeY1BEgIgiYzSPLheSGpwUXzFKA70ijBvFEgVDzCtwHW/AhrMBDT4w59okMEl iQgpqQbG5gZFexutCzucFJ483RUpxrHiyRlWn3np225/Oeb06hnXCgnuOXNmrPwuz6ycWbzy 6MUPm7kO2e2Z9abJky/mJvsPw+2Mnw8JTOnusy8oVBbeJl74rP8961EptoPu871XPn+mrNdm y3feR8DnaZfaEfuzxxc2t0q8Or9yEXu0bXmHYvS8due/SizFGYmGWsxFxYkA9hnT X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 18.9.25.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108261 Archived-At: ------=_Part_39320_1278450917.1448904524816 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello, I'm using emacs version 24.5.1 on Windows 10, and I encountered the followi= ng problem. It's probably due to some misunderstanding so I hope someone ca= n straighten me out: I tried to use the function call-process (Section 36.3 of Emacs Lisp manua= l), the manual entry for which I am copying for convenience: START OF COPY -- Function: call-process program &optional infile destination display &rest args This function calls PROGRAM and waits for it to finish. The current working directory of the subprocess is =E2=80=98default-directory=E2=80=99. The standard input for the new process comes from file=20 INFILE if INFILE is not =E2=80=98nil=E2=80=99, and from the null devic= e=20 otherwise. The argument DESTINATION says where to=20 put the process output. Here are the possibilities: a buffer Insert the output in that buffer, before point. This=20 includes both the standard output stream and the=20 standard error stream of the process. a string Insert the output in a buffer with that name, before point. =E2=80=98t=E2=80=99 Insert the output in the current buffer, before point. =E2=80=98nil=E2=80=99 Discard the output. 0 Discard the output, and return =E2=80=98nil=E2=80=99 immediately = without waiting for the subprocess to finish. In this case, the process is not truly synchronous, since=20 it can run in parallel with Emacs; but you can think of it=20 as synchronous in that Emacs is essentially finished with the subprocess as soon as this function returns. MS-DOS doesn=E2=80=99t support asynchronous subprocesses,=20 so this option doesn=E2=80=99t work there. =E2=80=98(:file FILE-NAME)=E2=80=99 Send the output to the file name specified, overwriting it=20 if it already exists. =E2=80=98(REAL-DESTINATION ERROR-DESTINATION)=E2=80=99 Keep the standard output stream separate from the=20 standard error stream; deal with the ordinary output as=20 specified by REAL-DESTINATION, and dispose of the=20 error output according to ERROR-DESTINATION. If ERROR-DESTINATION is=20 =E2=80=98nil=E2=80=99, that means to discard the error output, = =E2=80=98t=E2=80=99 means mix it with the ordinary output, and a string specifies a file=20 name to redirect error output into. You can=E2=80=99t directly specify a buffer to put the error outp= ut in; that is too difficult to implement. But you can achieve this result by sending the error output to a temporary file and then inserting the file into a buffer. If DISPLAY is non-=E2=80=98nil=E2=80=99, then =E2=80=98call-process=E2= =80=99 redisplays the=20 buffer as output is inserted. (However, if the coding system chosen for decoding output is =E2=80=98undecided=E2=80=99, meaning ded= uce the encoding from the actual data, then redisplay=20 sometimes cannot continue once non-ASCII characters are=20 encountered. There are fundamental reasons why it is hard to fix this; see *note Output from Processes::.) Otherwise the function =E2=80=98call-process=E2=80=99 does no redispla= y, and the results become visible on the screen only when Emacs redisplays that buffer in the normal course of events. The remaining arguments, ARGS, are strings that specify=20 command line arguments for the program. The value returned by =E2=80=98call-process=E2=80=99 (unless you told = it not to wait) indicates the reason for process termination. A=20 number gives the exit status of the subprocess; 0 means=20 success, and any other value means failure. If the process=20 terminated with a signal, =E2=80=98call-process=E2=80=99 returns a str= ing=20 describing the signal. In the examples below, the buffer =E2=80=98foo=E2=80=99 is current. (call-process "pwd" nil t) =E2=87=92 0 ---------- Buffer: foo ---------- /home/lewis/manual ---------- Buffer: foo ---------- (call-process "grep" nil "bar" nil "lewis" "/etc/passwd") =E2=87=92 0 ---------- Buffer: bar ---------- lewis:x:1001:1001:Bil Lewis,,,,:/home/lewis:/bin/bash ---------- Buffer: bar ---------- Here is an example of the use of =E2=80=98call-process=E2=80=99, as us= ed to=20 be found in the definition of the =E2=80=98insert-directory=E2=80=99 f= unction: (call-process insert-directory-program nil t nil switches (if full-directory-p (concat (file-name-as-directory file) ".") file)) END OF COPY The simple cases are straightforward enough. For example, (call-process "myprog.exe" nil t nil ) will place the output plus error output of myprog.exe into the=20 current buffer. However, when I tried to separate the output =20 from the error output, I ran into problems. According to my=20 reading of the manual (see above) one should replace=20 "destination" (1st line of manual text) with =E2=80=98(REAL-DESTINATION ERR= OR-DESTINATION)=E2=80=99 where REAL-DESTINATION and ERROR-DESTINATION are one of the given alternatives; for example: (call-process "myprog.exe" nil (t nil) nil ) However, the previous line, as well as many other attempts did not work. Obviously, I am doing something wrong; but what? Thanks in advance for answers. Regards, Bostjan Vilfan ------=_Part_39320_1278450917.1448904524816--