help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs script that works on all platforms


From: Tassilo Horn
Subject: Re: Emacs script that works on all platforms
Date: Fri, 21 May 2010 15:24:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Johan Andersson <johan.rejeep@gmail.com> writes:

Hi Johan,

> #!/usr/bin/emacs --script
>
> However, on Mac OSX, Emacs is installed by default, but with an old
> version.
>
> I have also installed Emacs via Homebrew (compiled from source) and can run
> that with:
> /Usr/local/Cellar/emacs/23.2/Emacs.app/Contents/MacOS/Emacs
>
> [...]
>
> I was thinking I could use env somehow, like this:
> #!/usr/bin/env emacs --script
>
> And then make emacs an alias or function that points to the correct
> binary depending on system. But it's still the default Emacs that is
> used.

"env cmd" uses the cmd it finds first when checking the directories in
your $PATH.  For example I have:

--8<---------------cut here---------------start------------->8---
% echo $PATH
/home/horn/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.3:/usr/games/bin
--8<---------------cut here---------------end--------------->8---

Now I make a symlink to `less' that I call `emacs' inside
/home/horn/bin:

--8<---------------cut here---------------start------------->8---
% cd ~/bin
% ln -s /usr/bin/less emacs
% zsh   # start a new shell
% emacs
Missing filename ("less --help" for help)
--8<---------------cut here---------------end--------------->8---

So as you can see, when calling `emacs' it finds the emacs-symlink to
less first, cause that resides in a directory that comes before
/usr/bin in PATH.

HTH,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]