From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: defining functions in emacs Date: Wed, 25 Jan 2006 09:02:33 -0700 Message-ID: References: <43D69ED3.6070005@ucsc.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1138210840 23258 80.91.229.2 (25 Jan 2006 17:40:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 25 Jan 2006 17:40:40 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 25 18:40:37 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F1od6-0005G7-Jr for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Jan 2006 18:40:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F1ofp-0006fO-62 for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Jan 2006 12:43:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F1nLQ-0006hH-0T for help-gnu-emacs@gnu.org; Wed, 25 Jan 2006 11:18:05 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F1nLM-0006gF-Ny for help-gnu-emacs@gnu.org; Wed, 25 Jan 2006 11:18:02 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F1nLI-0006fM-Es for help-gnu-emacs@gnu.org; Wed, 25 Jan 2006 11:17:57 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1F1nIh-00006T-Ut for help-gnu-emacs@gnu.org; Wed, 25 Jan 2006 11:15:16 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1F1nCJ-00010A-FC for help-gnu-emacs@gnu.org; Wed, 25 Jan 2006 17:08:39 +0100 Original-Received: from 207.167.42.60 ([207.167.42.60]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Jan 2006 17:08:39 +0100 Original-Received: from ihs_4664 by 207.167.42.60 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 25 Jan 2006 17:08:39 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 37 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.60 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en In-Reply-To: <43D69ED3.6070005@ucsc.edu> 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:32846 Archived-At: Matt Brown wrote: > I wrote my first emacs function! Here's my function: > > > (defun read-environment () > (setq outbuf (generate-new-buffer "read-environment-outbuf")) > (call-process "read-environment.sh" nil outbuf nil) > (eval-buffer outbuf) > (kill-buffer outbuf)) > > It uses read-environment.sh to generate a whole bunch of setenv lines, > and then evaluates them. Basically, it sources .bashrc and sets the new > variables in emacs. In Emacs there is always more than 1 way to skin a cat: (let ((shell-file-name "/bin/bash")) (setq process-environment (split-string (shell-command-to-string ". $HOME/.bashrc; env") "\n"))) > It works fine, but I want to be able to run it by > M-x read-environment > > This doesn't work. I have to put > (read-environment) > into *scratch*, move to the ')' and do C-x C-e to evaluate it. Pretty > lame. > > From the digging around I've done, it seems like it should just work. > Any ideas? BTW, the defun is in my .emacs Read the "Defining Commands" node of the Emacs Lisp manual, and its subnodes. -- Kevin Rodgers