[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: defining functions in emacs
From: |
Barry Margolin |
Subject: |
Re: defining functions in emacs |
Date: |
Thu, 26 Jan 2006 01:17:08 -0500 |
User-agent: |
MT-NewsWatcher/3.4 (PPC Mac OS X) |
In article <mailman.11.1138142928.2878.help-gnu-emacs@gnu.org>,
Matt Brown <mbrown83@ucsc.edu> 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 ***