From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthew Flaschen Newsgroups: gmane.emacs.help Subject: Re: "source" shell commands Date: Sun, 25 Mar 2007 00:03:10 -0400 Message-ID: <4605F47E.1080708@gatech.edu> References: <87bqii936r.fsf@baldur.tsdh.de> <85wt16btg5.fsf@lola.goethe.zz> <87hcsaqbui.fsf@lion.rapttech.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1174795414 2969 80.91.229.12 (25 Mar 2007 04:03:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 25 Mar 2007 04:03:34 +0000 (UTC) To: emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 25 06:03:28 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HVJx0-0003T6-D3 for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Mar 2007 06:03:26 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVJz5-0002ml-Gi for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Mar 2007 23:05:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVJyu-0002mg-Cq for help-gnu-emacs@gnu.org; Sun, 25 Mar 2007 00:05:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVJyr-0002mT-VQ for help-gnu-emacs@gnu.org; Sun, 25 Mar 2007 00:05:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVJyr-0002mQ-Pg for help-gnu-emacs@gnu.org; Sat, 24 Mar 2007 23:05:21 -0500 Original-Received: from deliverator8.gatech.edu ([130.207.165.183]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1HVJwl-00040x-Md for help-gnu-emacs@gnu.org; Sun, 25 Mar 2007 00:03:11 -0400 Original-Received: from deliverator8.gatech.edu (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id C0A36DC for ; Sun, 25 Mar 2007 00:03:10 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) Original-Received: from mailprx3.gatech.edu (mailprx3.prism.gatech.edu [130.207.171.17]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "smtp.mail.gatech.edu", Issuer "RSA Data Security, Inc." (verified OK)) by deliverator8.gatech.edu (Postfix) with ESMTP id A9360D0 for ; Sun, 25 Mar 2007 00:03:10 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) Original-Received: from [128.61.73.81] (r73h81.res.gatech.edu [128.61.73.81]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (sasl: method=PLAIN, username=mflaschen3@mailprx3.gatech.edu, sender=n/a) by mailprx3.gatech.edu (Postfix) with ESMTP id 5BB0A21CA for ; Sun, 25 Mar 2007 00:03:10 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) User-Agent: Thunderbird 1.5.0.10 (X11/20070306) In-Reply-To: <87hcsaqbui.fsf@lion.rapttech.com.au> X-Enigmail-Version: 0.94.3.0 X-detected-kernel: Solaris 9 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42173 Archived-At: Tim X wrote: > Matthew Flaschen writes: > >> Barry Margolin wrote: >>> In article <85wt16btg5.fsf@lola.goethe.zz>, David Kastrup >>> wrote: >>> >>>> Tassilo Horn writes: >>>> >>>>> Matthew Flaschen writes: >>>>> >>>>>> Is there an elisp function to "source" a shell file; i.e. an >>>>>> alternative to: >>>>>> >>>>>> (shell-command (concat "source \"" (expand-file-name "~/.rc") "\"")) >>>>> Sure. >>>>> >>>>> --8<---------------cut here---------------start------------->8--- >>>>> (defun mf-source (file) >>>>> (interactive "f") >>>>> (shell-command (concat "source \"" file "\""))) >>>>> --8<---------------cut here---------------end--------------->8--- >>>> Quoting is always good for trouble. I'd rather use >>>> >>>> (defun mf-source (file) >>>> (interactive "f") >>>> (call-process shell-file-name nil nil nil "source" file)) >>>> >>>> assuming that you don't care about the output. >>> First of all, shells don't take a command line to execute as arguments. >>> Take a look at what happens if you try it from the command line: >>> >>> $ bash source .bashrc >>> source: source: No such file or directory >>> >>> You can do it with the -c option, but then they expect the command to be >>> in a single argument: >>> >>> (call-process shell-file-name nil nil nil >>> "-c" (format "source '%s'" file)) >>> >>> Second, the point of "sourcing" is to execute the commands in the >>> current process's context. Since call-process and shell-command both >>> execute a child process, nothing that occurs in the sourced script will >>> have any effect on the emacs process. So even if you get the syntax >>> right, it won't do anything different from executing the script normally. >> Thanks. I realized this after I asked the question. Is there any way I >> could import the variables after? I found >> shell-copy-environment-variable but I reall want to copy *all* of them >> (for when I start emacs from outside the shell). >> > > I doubt shell-copy-environment-variable will work either. As soon as the sub > process that executes the "source file" has exited, I think that envrionment is > gone. > > I'm curious, how are you starting emacs "from outside the shell"? Maybe I'm missing something big. I'm using KDE. Sometimes I start emacs from an xterm (Konsole actually), but sometimes I just click a shortcut. > The first and easiest is to change the shell that executes your > .Xsession (or equivalent) to a login shell. Any idea how I would do that in Ubuntu (gNewSense really)? Matthew Flaschen