From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Amy Templeton Newsgroups: gmane.emacs.help Subject: Re: An easy defun Date: Sun, 07 Oct 2007 20:53:53 -0400 Message-ID: <87ve9i8lzy.fsf@gmail.com> References: <20071007215101.GA12042@relwi.unibe.ch> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0687706845==" X-Trace: sea.gmane.org 1191805153 30381 80.91.229.12 (8 Oct 2007 00:59:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 8 Oct 2007 00:59:13 +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 Oct 08 02:59:09 2007 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 1Iegxh-00007Z-2y for geh-help-gnu-emacs@m.gmane.org; Mon, 08 Oct 2007 02:59:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iegxb-0002BV-DS for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2007 20:59:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IegxL-0002BD-Ex for help-gnu-emacs@gnu.org; Sun, 07 Oct 2007 20:58:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IegxG-0002AT-OW for help-gnu-emacs@gnu.org; Sun, 07 Oct 2007 20:58:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IegxG-0002AQ-Iw for help-gnu-emacs@gnu.org; Sun, 07 Oct 2007 20:58:42 -0400 Original-Received: from wx-out-0506.google.com ([66.249.82.237]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IegxG-00053M-8E for help-gnu-emacs@gnu.org; Sun, 07 Oct 2007 20:58:42 -0400 Original-Received: by wx-out-0506.google.com with SMTP id s7so1024267wxc for ; Sun, 07 Oct 2007 17:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:to:subject:references:from:x-now-playing:x-windows:face:date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=VmMkZ5RgHuZQpodx11hkdolDZQn0V6LI2ki2qqwFFbA=; b=ZrfW+rveipOJC9oCYl18HH/TMb5blLRjlI63utHoRH5cFgu/ZeOEFwP4jiWjSt58CCJi9rjwn7FLaVjRzfrQjCTraAFUu+CzO+3kSh+VErOQdNEcLXPdVR+/LSqox5peau4lmm+cZlQo5q1VdppWbhaVO6fNmWFMcZeF9EycOiY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:to:subject:references:from:x-now-playing:x-windows:face:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=DL4eU2x14/AkVIVvZQsqBi2P5tAFjKcZkCJwaZClYFlHCXKk3rDZnNWOOsB0dlPy2hpuibMt+EE1JbxL+w6sf6s5MlnLPRK4jbsiS3AqYPcArPcPDUUitkb7gsTLGlYHA50t5AKSXsqvcuFXIykqUd5UOw6Aj/vBHPliD8TpxD4= Original-Received: by 10.70.72.11 with SMTP id u11mr24024413wxa.1191804717990; Sun, 07 Oct 2007 17:51:57 -0700 (PDT) Original-Received: from localhost ( [132.162.252.123]) by mx.google.com with ESMTPS id b11sm7333424ana.2007.10.07.17.51.56 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 07 Oct 2007 17:51:57 -0700 (PDT) X-Now-Playing: Nothing playing right now X-Windows: warn your friends about it. Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUAAAAAAANaaXzP4O+c rcAAAQQOExuRlO0xAAACKElEQVQ4jW1UQXKkMAw0U8We4cCeN8b2A5ArD7CVOYNr5PPEwfz/CStj hkoyowNFqa1Wqy0Q4hFNT0N/X8TvoBLp7QmgmOO2SZqF6L/nW0qIaN1Gyw+g5tEiGq7puuYkCugt SrNJpYmWlo78kEaLTspMcZPc6a17FCg+rmllWTpcc5SHtiYgui3TTcecgiQKugJRgWdqWvXtI5iY ua5Kih4cLcOS8tdH0At9XecHYIuWRW5erxRX0AdwA5sXBlICI2mFiaqqYQSrozQklQ3XAHAwicHj RCvrQj+teizlhyg+Q8opZb2dEoDLlaoNFjUpqTwicKDNtJe0K4CODBQbATyANfMJBIfFRg97kb1X tZblO2VUASxDeFTcECSy38zly3G33+M+H6B0Ksmju6699won0aXgkQUDZJq3Khf4NpTbkrcewftM f80xh3V8fbLI4i785qqqiDChlAn9Pog16V6XgRjg+Qyrgh3RVJeruJuQp+D94af1U553oP1iiRsz TWhZMozse390Z3svx3AKjJIVEDSC039c8cqZaHgtjr1iG/1VFbXlLhLRfG46snl7TBQeF8vR8wLY avgUVT6BXgxxZJcUA++81F1/AoWM+bkGr2zt8P37MIqtLFtB4ke0FCWPbn/n2ZdFjO6y6uWkPxvR xf6Lz4AQ3Ty+N0MnnqJvL1M7P+dLjPfXQLvp5lWemi19Nt1zl6WNRr7m4m+KfwIvu8xRyvr6H1c0 rEpGcjoCAAAAAElFTkSuQmCC In-Reply-To: <20071007215101.GA12042@relwi.unibe.ch> (Sven Bretfeld's message of "Sun\, 7 Oct 2007 23\:51\:01 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-Detected-Kernel: Linux 2.6 (newer, 2) 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:48199 Archived-At: --===============0687706845== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Transfer-Encoding: quoted-printable Sven Bretfeld wrote: > I want to define a funtion called start-mutt, which does: > - open an ansi term > - rename it to *Mutt* > - start Mutt within the ansi-term > - if the ansi-term already exists and has Mutt running, switch to that > buffer > Can anybody help me? Perhaps something like this? Substitute the correct path to your mutt in the second-to-last line. (defun start-mutt (&optional bg) "Start an ansi-term running the mutt mailreader, in a buffer called \"*Mu= tt*\" Given an argument (assuming the buffer called \"*Mutt*\" doesn't already ex= ist), will start in the background" (interactive "P") (if (get-buffer "*Mutt*") (switch-to-buffer "*Mutt*") (let ((buf (current-buffer))) (ansi-term "/usr/bin/mutt" "Mutt") (if bg (switch-to-buffer buf))))) Some useful information to know in the future: =2D Press "C-h f ansi-term" to read the documentation for the function ansi-term (or substitute some other function you're curious about), a function I had never used previously but which I found out takes two arguments: the program to run and the name of the buffer, to which it will pre-pend and append asterices. =2D Most of the time you won't use (switch-to-buffer) in elisp programs (see its documentation, as above). =2D (interactive) can be called with a wide array of arguments; see its documentation for more information. =2D Consider checking out the Emacs Lisp Intro., which if you're running a recent emacs I'm pretty sure should be included. =2D Try to go through this code and understand it, one step at a time. Anyway, I hope that's helpful. Amy =2D-=20 "The History of every major Galactic Civilization tends to pass through three distinct and recognizable phases, those of Survival, Inquiry and Sophistication, otherwise known as the How, Why and Where phases. "For instance, the first phase is characterized by the question 'How can we eat?' the second by the question 'Why do we eat?' and the third by the question 'Where shall we have lunch?'" -- Hitchhiker's Guide to the Galaxy --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHCX+u2syA5KibvcsRAqx1AJ90angJt6/1BeFjbkfE2FInJA+B+gCfVENN LgEm1WVaj9EcXY/FMwqBebI= =wedq -----END PGP SIGNATURE----- --=-=-=-- --===============0687706845== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0687706845==--