From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nathan Trapuzzano Newsgroups: gmane.emacs.devel Subject: Re: Compile Mode and "host" Emacs Date: Tue, 29 Oct 2013 09:10:34 -0400 Message-ID: <874n80w7cl.fsf@nbtrap.com> References: <874n80l0b3.fsf@nbtrap.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1383052325 20574 80.91.229.3 (29 Oct 2013 13:12:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 29 Oct 2013 13:12:05 +0000 (UTC) Cc: emacs-devel@gnu.org To: Sebastian Wiesner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 29 14:12:08 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vb95b-0003Ri-Bc for ged-emacs-devel@m.gmane.org; Tue, 29 Oct 2013 14:12:07 +0100 Original-Received: from localhost ([::1]:47091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vb95a-0002eW-SS for ged-emacs-devel@m.gmane.org; Tue, 29 Oct 2013 09:12:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vb94k-0001Lw-EH for emacs-devel@gnu.org; Tue, 29 Oct 2013 09:11:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vb94d-0007a3-8Z for emacs-devel@gnu.org; Tue, 29 Oct 2013 09:11:14 -0400 Original-Received: from outbound-ss-1235.hostmonster.com ([67.20.99.188]:51626) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Vb94b-0007YW-AH for emacs-devel@gnu.org; Tue, 29 Oct 2013 09:11:07 -0400 Original-Received: (qmail 334 invoked by uid 0); 29 Oct 2013 13:10:38 -0000 Original-Received: from unknown (HELO host393.hostmonster.com) (66.147.240.193) by oproxy1.mail.unifiedlayer.com with SMTP; 29 Oct 2013 13:10:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbtrap.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From; bh=70PWnVBRlALtNNNViN3xkraGDDbtfMJnQxvMWqVLA14=; b=G+OoEnQUdGRedZ3v9Nv7ZkmaIsLyLOJnDPK6915OnTkMK9oxvewE9PKwyhQap4CT1kZNbDB8BCF24//KREXALd3f2oXEFxcb1Nr3BioUcb4Ig8HfX37tWkTnEBcbnj23; Original-Received: from [50.90.253.209] (port=54590 helo=Nathan-GNU) by host393.hostmonster.com with esmtpsa (TLSv1:CAMELLIA128-SHA:128) (Exim 4.80) (envelope-from ) id 1Vb94A-0006BD-0H; Tue, 29 Oct 2013 07:10:38 -0600 In-Reply-To: (Sebastian Wiesner's message of "Tue, 29 Oct 2013 13:50:10 +0100") User-Agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) X-Identified-User: {1585:host393.hostmonster.com:nbtrapco:nbtrap.com} {sentby:smtp auth 50.90.253.209 authed with nbtrap@nbtrap.com} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 67.20.99.188 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164622 Archived-At: Sebastian Wiesner writes: > Uhm, you misunderstood me. I didn't ask how to get the path to the > Emacs executable within the running Emacs instance itself. > > Rather, I wanted to know how to get the path to the Emacs executable > **from within a running subprocess**, started by `M-x compile`. > > For instance, assume that I do "M-x compile RET foo.sh", then how can > I get the path to the Emacs executable **within foo.sh**. > > I have "$EMACS" and "$INSIDE_EMACS", but the values of these variables > are pretty much useless. I don't think there's any portable way. If you're running on Linux and you know the process's direct parent is emacs, you could do something like: executable=$(readlink -f /proc/$PPID/exe) where $PPID is the parent's process id, which can be obtained in various ways. Of course, this only works if emacs is the direct parent. A better way would probably be to set some environment variable to the full path in your init file, and then using that from the compile process: ;;;; .emacs (setenv "EMACS_EXE_PATH" (file-truename (concat (file-name-as-directory invocation-directory) invocation-name))) Nathan