From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: starting an external command from emacs Date: Thu, 13 Nov 2008 07:50:33 -0800 (PST) Organization: http://groups.google.com Message-ID: <3d16ac18-967c-4511-8c9c-9a80c40c3d8e@x16g2000prn.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1226598062 20367 80.91.229.12 (13 Nov 2008 17:41:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 13 Nov 2008 17:41:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 13 18:42:03 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L0gCL-0007Xh-MO for geh-help-gnu-emacs@m.gmane.org; Thu, 13 Nov 2008 18:41:41 +0100 Original-Received: from localhost ([127.0.0.1]:47928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0gBD-00057r-Ob for geh-help-gnu-emacs@m.gmane.org; Thu, 13 Nov 2008 12:40:31 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!x16g2000prn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 84 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1226591433 17337 127.0.0.1 (13 Nov 2008 15:50:33 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 13 Nov 2008 15:50:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x16g2000prn.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164409 comp.emacs:97353 X-Mailman-Approved-At: Thu, 13 Nov 2008 12:29:30 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59748 Archived-At: On Nov 12, 11:59 am, Matt Price wrote: > hi, > > i'm a not-especially-technical person who uses emacs as a > straightforward text editor; in fact i'm experimenting with living > inside emacs most of the time on my main laptop, largely to eliminate > distractions while i'm writing. however, some significant fraction of > the stuff i write is intended to be emailed away. I'd like to do two > things: > > (1) write a function that takes the contents of the current buffer and > inserts it into a message; > (2) use an external script to query an already-existing contacts > database (for me it's evolution or gmail), and pass that address on to > the to-header of the resultant message. > > (2) seemed difficult to me. so what i'm trying right now is to write a > function that invokes mutt with an address string, then, within mutt, > use emacsclient as my editor, post-mode as my mode, and insert the text > into the message body. This is what i have so far: > > (defun start-mutt-with-this-buffer-contents (address) > (mark-whole-buffer) > (kill-ring-save) ;; ok this needs a beginning and end but i don't= know how to do that > (interactive "M") ;; i think that's right > (set-buffer (apply 'make-term "Mutt" "mutt" nil (list address))) > (switch-to-buffer "*Mutt*") > ;; need some kind of "wait for mutt to start composing" thing here > (post-goto-body) > (yank) > ) > > the problem with this right now is that the (yank) occurs too early, and > the yanked text appears in the *Mutt* window, instead of the *Composing* > window where i want it to appear. is there a way to tell emacs to wait > on mutt till the interactive command is finished, then switch tothe > composing buffer and paste the text in there? or failing that -- how > might i query an external database from within emacs? if i could do > that, then i guess i could use one of the many already-existing emacs > mail modes to actually send the message, and provide it with the the > query result as a to-address. i have, for instance, a couple of python > scripts that return a sequence of lines, one email address per line -- > these are designed for use with mutt -- i guess one could put them into > some kind of minibuffer that would then feed the appropriate choice back > to an emacs function. i just don't know how to do that kind of stuff > myself. > > Thanks in advance for your help!! Can you make your question into one specific question? if you can make just one specific question, as much as possible to your problem, it's likely to get much useful replies. from scanning several replies, here's what i think might be helpful. i used vm and rmail from about 1999 to 2000. vm was much feature rich than rmail, and i suppose it still is. I have tried gnus during the time but find it hard to learn. (i've also used mutt, unix command line mail, mh, pine, in the past 10 years, typically each i have used for a few months. I've stopped using any text based email client since about 2003.) if you want to write elisp to call some other script and process the result, it's fairly easy. If you can be specific about what command you want to call and how you want to parse the result, we can help better. The following tutorial will probably help: =E2=80=A2 Elisp Wrapper For Perl Scripts http://xahlee.org/emacs/elisp_perl_wrapper.html (you can use your existing knowledge of a scripting lang and turn them into elisp command) =E2=80=A2 Elisp Lesson: Writing image-linkify Function http://xahlee.org/emacs/elisp_image_tag.html (contains example of calling external script and process its result) Xah =E2=88=91 http://xahlee.org/ =E2=98=84