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: Johan Andersson
Subject: Re: Emacs script that works on all platforms
Date: Thu, 27 May 2010 14:51:27 +0200

Hey,

To bad you could not get away with an alias or function though... But it works, thanks for the tip! :)

On Fri, May 21, 2010 at 3:24 PM, Tassilo Horn <tassilo@member.fsf.org> wrote:
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]