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

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

Re: Start Emacs with a minimal bash and Emacs lisp mixed script for test


From: Hongyi Zhao
Subject: Re: Start Emacs with a minimal bash and Emacs lisp mixed script for testing.
Date: Wed, 4 Aug 2021 08:26:56 +0800

On Wed, Aug 4, 2021 at 12:09 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> > Try:
> >
> >   #! /bin/bash
> >
> >   :; set -e
> >   :; emacs -Q --load "$(realpath -e $0)" -- "$@"; exit
> >
> >   (setq test-var 3)
> >
> > Then type test-var and do `eval-last-sexp'.
>
> Or even more minimal:
>
>   #! /bin/zsh
>
>   ; emacs -Q --load "$(realpath -e $0)"; exit

Wonderful. The key point is the `exit' command used here, which will
fix the error I encountered. After I posted this email, I found
another similar usage [1], which is exactly the trick you suggested
above.

Another question: how to do the same job with the `--script' option of
Emacs? I've tried with the following command, but failed to start
Emacs:

:; emacs -Q --script $(realpath -e $0); exit


[1] 
https://github.com/alphapapa/matrix-client.el/blob/d2ac55293c96d4c95971ed8e2a3f6f354565c5ed/matrix-client-standalone.el.sh#L64-L81

>   (setq test-var 1)
>
> (I changed the shell to zsh because that's what I use.)
>
> And you don't have to do 'bash SCRIPT', instead just
> 'chmod +x SCRIPT', put in $PATH, and 'SCRIPT'.

Thank you for your suggestion.

Best regards
-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province



reply via email to

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