From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matt Price Newsgroups: gmane.emacs.help Subject: starting an external command from emacs Date: Wed, 12 Nov 2008 14:59:49 -0500 Organization: History Department, University of Toronto Message-ID: <1226519989.8767.681.camel@localhost> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226528904 10326 80.91.229.12 (12 Nov 2008 22:28:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Nov 2008 22:28:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 12 23:29:23 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 1L0OD3-0003gA-RB for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Nov 2008 23:29:14 +0100 Original-Received: from localhost ([127.0.0.1]:48754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0OBv-0003UI-61 for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Nov 2008 17:28:03 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0Lsj-0004Ok-1G for help-gnu-emacs@gnu.org; Wed, 12 Nov 2008 15:00:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0Lsf-0004LJ-1b for help-gnu-emacs@gnu.org; Wed, 12 Nov 2008 15:00:04 -0500 Original-Received: from [199.232.76.173] (port=55254 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0Lse-0004L6-Rv for help-gnu-emacs@gnu.org; Wed, 12 Nov 2008 15:00:00 -0500 Original-Received: from bureau60.ns.utoronto.ca ([128.100.132.147]:47318) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0Lse-000327-1b for help-gnu-emacs@gnu.org; Wed, 12 Nov 2008 15:00:00 -0500 Original-Received: from anarres.mercey.org (CPE001d7e1d5798-CM0014f8cd1c4c.cpe.net.cable.rogers.com [173.32.83.31]) (authenticated bits=0) by bureau60.ns.utoronto.ca (8.13.8/8.13.8) with ESMTP id mACJxqij028210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 12 Nov 2008 14:59:54 -0500 Original-Received: by anarres.mercey.org (Postfix, from userid 1000) id 0652712034F; Wed, 12 Nov 2008 14:59:50 -0500 (EST) X-Mailer: Evolution 2.24.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Wed, 12 Nov 2008 17:27:36 -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:59705 Archived-At: 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!! matt -- Matt Price matt.price@utoronto.ca