unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
Subject: Re: defining functions in emacs
Date: Thu, 26 Jan 2006 01:17:08 -0500	[thread overview]
Message-ID: <barmar-D2FE79.01170826012006@comcast.dca.giganews.com> (raw)
In-Reply-To: mailman.11.1138142928.2878.help-gnu-emacs@gnu.org

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 ***

  parent reply	other threads:[~2006-01-26  6:17 UTC|newest]

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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=barmar-D2FE79.01170826012006@comcast.dca.giganews.com \
    --to=barmar@alum.mit.edu \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).