[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple useful functions
From: |
Tak Ota |
Subject: |
Re: simple useful functions |
Date: |
Fri, 3 Dec 2010 18:58:02 -0800 |
Fri, 3 Dec 2010 18:36:31 -0800: Stefan Monnier <address@hidden> wrote:
> > (defun source (script &optional shell keep-current-directory)
> > "Source the specified shell script.
> > Source the shell SCRIPT and import the environment into this
> > emacs. The optional SHELL specifies the shell other than the
> > default `shell-file-name'. When KEEP-CURRENT-DIRECTORY is nil,
> > which is the default, the current directory is temporarily
> > changed to the directory where the script resides while sourcing
> > the script."
> > (interactive "fscript file: ")
> > (if (null shell)
> > (setq shell shell-file-name))
> > (with-temp-buffer
> > (unless keep-current-directory
> > (setq default-directory (file-name-directory script)))
> > (call-process shell nil t nil "-c" (concat "source " script ";
> > printenv"))
> > (while (re-search-backward "^\\([^=]+\\)=\\(.*\\)$" nil t)
> > (setenv (match-string 1) (match-string 2)))))
>
> Some problems I see with it, by order of decreasing importance:
> - I fail to see in which circumstance(s) this is useful.
OK, I see this may not be useful for everybody. The reason I wrote
this command was to support embedded software development. In
embedded development work we are usually required to use some cross
compilation tools. Such tools often come with a setup script which
includes setting up necessary environment variables for command paths
and library paths. In order to compile software in this environment
from emacs I need to start emacs from the shell that has run the
script. But to me emacs is not a text editor but a working
environment. I don't want to kill the current emacs or start another
emacs for this purpose. My emacs has been running before running the
script. I take care of shell needs from inferior shell. But running
the setup script from an inferior shell doesn't help. Therefore this
command became handy.
After writing this up I now realize it is useful for minority groups.
Thanks for the comments anyway.
-Tak
> - What if the user uses scsh/emacs for his shell.
> - Most scripts don't setup much of environment.
> - AFAIC things like ~/.cshrc are not a scripts but a config files.
> - The call-process needs to quote `script' (and should probably be
> replaced by process-file).
> - The prompt should start with a capital.
>
>
> Stefan
>
- Re: simple useful functions, Tak Ota, 2010/12/03
- Re: simple useful functions, Stefan Monnier, 2010/12/03
- Re: simple useful functions,
Tak Ota <=
- Re: simple useful functions, Stefan Monnier, 2010/12/03
- Re: simple useful functions, David Kastrup, 2010/12/04
- Re: simple useful functions, Tak Ota, 2010/12/06
- Re: simple useful functions, Stefan Monnier, 2010/12/06
- Re: simple useful functions, Tak Ota, 2010/12/06
- Re: simple useful functions, Stefan Monnier, 2010/12/06
- Re: simple useful functions, René Kyllingstad, 2010/12/06
- Re: simple useful functions, Stefan Monnier, 2010/12/06