From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jadamson@partners.org (Joel J. Adamson) Newsgroups: gmane.emacs.help Subject: Re: is it possible to pass shell variables to emacs? Date: Fri, 07 Dec 2007 12:59:39 -0500 Organization: I need to put my ORGANIZATION here. Message-ID: <87bq92s7w4.fsf@W0053328.mgh.harvard.edu> References: <44a8858b-32d1-4b14-803f-4cded782b968@a39g2000pre.googlegroups.com> <85lk87o3i9.fsf@lola.goethe.zz> <05d07222-2a31-4399-90eb-63a0230a386a@s12g2000prg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1197053063 27495 80.91.229.12 (7 Dec 2007 18:44:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Dec 2007 18:44:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 07 19:44:32 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 1J0iBQ-0002Tk-W0 for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Dec 2007 19:44:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0iB9-0004wD-UE for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Dec 2007 13:44:03 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.glorb.com!newspeer1.asbnva01.us.to.verio.net!news.harvard.edu!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-NNTP-Posting-Host: w0053328.mgh.harvard.edu Original-X-Trace: plato.harvard.edu 1197050379 11190 132.183.29.121 (7 Dec 2007 17:59:39 GMT) Original-X-Complaints-To: news@plato.harvard.edu Original-NNTP-Posting-Date: Fri, 7 Dec 2007 17:59:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:p1V+jgBZT2nS3iTzXQDE8whcQTI= Original-Xref: shelby.stanford.edu gnu.emacs.help:154495 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:49926 Archived-At: "stuart.tett@gmail.com" writes: > On Dec 6, 2:35 pm, David Kastrup wrote: >> "stuart.t...@gmail.com" writes: >> > is there any possible way to do this? I would like to avoid making >> > them environment variables. I have a command-line script that when >> > called, sets all of these variables. I would like to use these >> > variables for example when finding a file. >> >> > Maybe there's some custom code I could put in my .emacs file. or I >> > could write a wrapper around emacs. >> >> emacs -eval '(setq a (pop argv) b (pop argv))' "$a" "$b" >> >> If your Emacs version is not a more recent developer version, you need >> to write command-line-args-left instead of argv. This is to be >> preferred to >> >> emacs -eval "(setq a \"$a\" b \"$b\")" >> >> since this will break if $a or $b contain characters or character >> sequences that are interpreted specially in literal Lisp strings. >> >> -- >> David Kastrup, Kriemhildstr. 15, 44793 Bochum > > > Great thanks. Question: some of these variables that I am passing in > refer to directories and I want to use them in the C-x C-f interface. > How do I access them? I don't think they work with $myvar You access them as part of the return value from command-line-args or command-line-args-left, as you would access the members of any other list, e.g. car cdr nth nthcdr... Each element is a string. Joel -- Joel J. Adamson Biostatistician Pediatric Psychopharmacology Research Unit Massachusetts General Hospital Boston, MA 02114 (617) 643-1432 (303) 880-3109