all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: defining functions in emacs
Date: Wed, 25 Jan 2006 09:02:33 -0700	[thread overview]
Message-ID: <dr87et$q2e$1@sea.gmane.org> (raw)
In-Reply-To: <43D69ED3.6070005@ucsc.edu>

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

  parent reply	other threads:[~2006-01-25 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-24 21:40 defining functions in emacs Matt Brown
2006-01-24 23:13 ` Edward O'Connor
2006-01-25 16:02 ` Kevin Rodgers [this message]
     [not found] <mailman.11.1138142928.2878.help-gnu-emacs@gnu.org>
2006-01-25  8:09 ` Tim X
2006-01-26  6:17 ` Barry Margolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='dr87et$q2e$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.