help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defining functions in emacs


From: Kevin Rodgers
Subject: Re: defining functions in emacs
Date: Wed, 25 Jan 2006 09:02:33 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]