From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: defining functions in emacs Date: Thu, 26 Jan 2006 01:17:08 -0500 Organization: Symantec Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1138256251 22124 80.91.229.2 (26 Jan 2006 06:17:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 26 Jan 2006 06:17:31 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 26 07:17:30 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 1F20Rj-0000PC-Dv for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Jan 2006 07:17:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F20UV-0005f8-KR for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Jan 2006 01:20:19 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Thu, 26 Jan 2006 00:17:08 -0600 Original-Newsgroups: gnu.emacs.help Mail-Copies-To: nobody User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X) X-Copies-To: never Original-Lines: 35 Original-NNTP-Posting-Host: 24.128.234.87 Original-X-Trace: sv3-vHnNWRtEz5KX+nodSrosqgChtALZb/8cC08Z78f8Bh4VRvE5SQC1jEzC4q01VMFbT8LdrSgzjbOaQzD!0no+qw9t0tAlmaa+01y2snFTt7px8YDXUKc8DW6DCGiH0wyXIZHJR1Ev3rMAFKUL++SZmxDz9xxf!Wa/6GgJAYaDE8SCN/P5itvqg+nKIjqlNKQ== Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Original-Xref: shelby.stanford.edu gnu.emacs.help:137232 Original-To: help-gnu-emacs@gnu.org 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:32853 Archived-At: In article , Matt Brown wrote: > Hi everyone > > 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. It works fine, but I want to be able to run it by > M-x read-environment As others have pointed out, if you want to define a COMMAND, you have to use the (interactive) declaration. You've just defined a function, and M-x executes commands. > 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. It's not quite that bad. M-: can be used to execute arbitrary Lisp functions. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***