unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: chad <yandros@MIT.EDU>
To: Sebastian Wiesner <lunaryorn@gmail.com>
Cc: "emacs-devel@gnu.org devel" <emacs-devel@gnu.org>
Subject: Re: Compile Mode and "host" Emacs
Date: Tue, 29 Oct 2013 10:22:22 -0700	[thread overview]
Message-ID: <91DCEFA2-F588-48BA-921A-A05B38212B9A@mit.edu> (raw)
In-Reply-To: <CALf2awQZFWGY=0ZbV_mb3c1uuEBf_o1uTJ_71CLqFeObR8gKew@mail.gmail.com>


On 29 Oct 2013, at 06:18, Sebastian Wiesner <lunaryorn@gmail.com> wrote:
>> 
>> I don't think there's any portable way.
> 
> That's unfortunate.

It was (is?) an early design principle of unix systems that there isn't necessarily any such thing as `the path' or even `a path' to anything. This has a number of positive benefits surrounding hard links, soft links, movable files, and [un/re]mountable filesystems. Instead, we got conventions (not rules) about where things should be, and how to find them. It also has a cost, but it's relatively low - most of the time, when someone said "I want my program to know its place in the filesystem.", they really didn't need to know that, and there were better ways to accomplish their goals. For example, often these requests are an effort to work around the user's configuration choices, and that desire gets things wrong at least as often as it gets things right - even if it seems better in the short-term, narrow-focus view.

That said, there are times when the program really does want to know that data, so emacs provides a way to find it (invocation-*, mentioned above). Under macosx, for example, if you build a relocatable bundle, it really wants to be able to find its lisp libraries.

> I cannot but wonder what (stupid?) rationale let to the design of
> "$EMACS" and "$INSIDE_EMACS", if I have no chance to find out *what*
> Emacs I am actually inside of…

In most cases, programs don't care at all. When they do care, in most cases they care if they're running inside any sort of emacs at all or not. Your case appears to care inside which specific filesystem invocation of emacs it was run, which is unusual. Most cases, when examined, really are better off using rather than bypassing the user's configuration (PATH in this case). If I were using some code that wanted to know where emacs was installed, and I changed PATH for that code, I wouldn't want it poking around and guessing that it should ignore PATH. Conversely, if the user hasn't set PATH, but wants to interact with emacs, they generally will get similar sorts of wrong behavior if they're shell uses the wrong programs from bin and libexec (ctags, etags, emacsclient, etc).

In most cases, then, the right thing to do is to get/help the user configure emacs on their system correctly, rather than second-guess their intentions - it's harder to do, but gives the right result in more cases.

>> 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)))
> 
> I am not in control of my users' configurations, nor can I reasonably
> demand them to change their "init.el" just to support a single script.
> Besides, if I tell them to change their "init.el", I might just as
> well tell them to select the target Emacs via the corresponding option
> of my script right away.

That's a good idea; you can also have your script run emacs (probably -batch) and have that emacs stash the info you need somewhere. I'll point out that if you expect your users to interact with emacs both from a gui launcher and from the command-line, it's almost never a bad idea to suggest and/or help them to configure their environment so that emacs works well in both situations.

Hopefully that helps explain why what seemed like a simple question wasn't quite as simple as you'd thought. If you can explain a bit more what it is you're actually trying to do, we can probably provide some helpful suggestions about how to accomplish your goals.

Thanks,
~Chad




  parent reply	other threads:[~2013-10-29 17:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29  9:55 Compile Mode and "host" Emacs Sebastian Wiesner
2013-10-29 12:38 ` Nathan Trapuzzano
2013-10-29 12:50   ` Sebastian Wiesner
2013-10-29 12:54     ` Andreas Schwab
2013-10-29 13:11       ` Sebastian Wiesner
2013-10-29 13:53         ` Andreas Schwab
2013-10-29 14:04           ` Sebastian Wiesner
2013-10-29 15:28             ` Andreas Schwab
2013-10-29 15:52               ` Sebastian Wiesner
2013-10-29 16:02                 ` Michael Albinus
2013-10-29 16:12                 ` Andreas Schwab
2013-10-29 17:07                 ` Eli Zaretskii
2013-10-29 19:09                   ` Sebastian Wiesner
2013-10-29 19:57                     ` Eli Zaretskii
2013-10-29 20:22                       ` Óscar Fuentes
2013-10-29 20:27                         ` Eli Zaretskii
2013-10-29 15:59             ` David Engster
2013-10-29 17:00             ` Eli Zaretskii
2013-10-29 18:42               ` Sebastian Wiesner
2013-10-29 13:10     ` Nathan Trapuzzano
2013-10-29 13:18       ` Sebastian Wiesner
2013-10-29 13:31         ` Nathan Trapuzzano
2013-10-29 13:36           ` Sebastian Wiesner
2013-10-29 13:42             ` Nathan Trapuzzano
2013-10-29 13:55               ` Sebastian Wiesner
2013-10-29 13:58                 ` Nathan Trapuzzano
2013-10-29 14:07                   ` Sebastian Wiesner
2013-10-29 14:16                     ` Nathan Trapuzzano
2013-10-29 14:25                       ` Sebastian Wiesner
2013-10-29 14:27                         ` Nathan Trapuzzano
2013-10-30  4:43                         ` Stephen J. Turnbull
2013-10-30  7:23                           ` Jorgen Schaefer
2013-10-30  8:09                             ` Stephen J. Turnbull
2013-10-29 17:22         ` chad [this message]
2013-10-29 16:52 ` Stefan Monnier
2013-10-29 18:42   ` Sebastian Wiesner
2013-10-29 21:40     ` Stefan Monnier
2013-10-29 22:55       ` Xue Fuqiao

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=91DCEFA2-F588-48BA-921A-A05B38212B9A@mit.edu \
    --to=yandros@mit.edu \
    --cc=emacs-devel@gnu.org \
    --cc=lunaryorn@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).