2011-09-04 15 views
5

के लिए प्रतीक्षा न करें Emacs को प्रोग्राम चलाने के लिए कैसे करें और आउटपुट/प्रतिक्रिया के लिए प्रतीक्षा न करें? मैं एक बाहरी कार्यक्रम में एक पीडीएफ खोलने की कोशिश की:Emacs से एक प्रोग्राम चलाएं और आउटपुट

(shell-command (concat "start sumatrapdf " (shell-quote-argument path) " -page " search)))) 

लेकिन जब तक मौजूदा SumatraPDF प्रक्रिया बंद कर दिया है यह एक और फ़ाइलों को खोलने के नहीं होंगे। मैं async-shell-command थक गया, लेकिन यह Async आउटपुट के साथ एक नया बफर खुलता है जिसकी मुझे आवश्यकता नहीं है।

बाहरी कार्यक्रमों में फ़ाइलों का सही तरीका क्या है?

उत्तर

9

start-process समारोह है कि संभाल कर सकते हैं:

(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) 

Start a program in a subprocess. Return the process object for it. 
NAME is name for process. It is modified if necessary to make it unique. 
BUFFER is the buffer (or buffer name) to associate with the process. 

Process output (both standard output and standard error streams) goes 
at end of BUFFER, unless you specify an output stream or filter 
function to handle the output. BUFFER may also be nil, meaning that 
this process is not associated with any buffer. 

PROGRAM is the program file name. It is searched for in `exec-path' 
(which see). If nil, just associate a pty with the buffer. Remaining 
arguments are strings to give program as arguments. 

If you want to separate standard output from standard error, invoke 
the command through a shell and redirect one of them using the shell 
syntax. 

आप खुले प्रक्रिया के साथ bufer संबद्ध करने के लिए नहीं करना चाहते हैं - nil बफर तर्क के रूप में पारित

+0

धन्यवाद, विक्टर। आपके संकेत के साथ मुझे थोड़ा अलग फ़ंक्शन ('स्टार्ट-प्रोसेस-शेल-कमांड') मिला है क्योंकि 'स्टार्ट-प्रोसेस' ने तर्कों को सही तरीके से नहीं लिया है। –

+0

तो, बफर के अंत को कैसे प्राप्त करें और इसे प्रदर्शित करें? – zobi8225

2

C-h k M-!

देखें ... यदि COMMAND एम्पर्सेंड में समाप्त होता है, तो इसे अतुल्यकालिक रूप से निष्पादित करें। आउटपुट बफर 'असिंक शैल कमांड' में दिखाई देता है। वह बफर मोड में है। ...

IOW, M-! my_command --opt=foo arg1 arg2 &my_command शुरू करने और इसे में चल my_command के साथ एक *Async Shell Command* बफर बनाने लेकिन Emacs नियंत्रण वापस आप को देने के तुरंत होगा।

+0

मेरे मामले में Emacs किसी भी प्रतिक्रिया के लिए इंतजार नहीं करना चाहिए। बस एक फाइल खोलें और इसके बारे में भूल जाएं (असल में, यह ऑर्ग-मोड और कस्टम हाइपरलिंक प्रकार के लिए है जो कुछ पेज पर पीडीएफ खोल देगा)। वैसे भी, आपके ध्यान के लिए धन्यवाद, रॉस। –

संबंधित मुद्दे