GNU bug report logs - #20682
25.0.50; Enable users to combine --script and --quick

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Thu, 28 May 2015 13:58:02 UTC

Severity: wishlist

Merged with 25671

Found in version 25.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20682 in the body.
You can then email your comments to 20682 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Thu, 28 May 2015 13:58:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 28 May 2015 13:58:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; Enable users to combine --script and --quick
Date: Thu, 28 May 2015 15:57:15 +0200
Hello!

This is a feature request to enable users to write emacs scripts (à la
--script) that can be executed in a way that --quick does (i.e. avoid
loading site stuff).

AFAIK this is not directly possible currently, because if you try with a
file starting like this:

#!/usr/bin/emacs -Q --script

the "#!" implementation on most Unices will not be able to pass more
than one argument to the interpreter.

The only thing that can be done to force --quick is to define a separate
interpreter like this:

--8<---------------cut here---------------start------------->8---
#!/bin/bash

emacs --quick --script $@
--8<---------------cut here---------------end--------------->8---

(suggested by saint <at> eng.it in g.e.help).

I have been told in the same thread that if --script would be available
as -s, one could start scripts with "#!/usr/bin/emacs -Qs" and that
would already solve the problem.


These are the main reason why using --quick can be desirable:

 - There are no messages like:

     Loading 00debian-vars...
     Loading /etc/emacs/site-start.d/50a2ps.el (source)...
     Loading /etc/emacs/site-start.d/50autoconf.el (source)...
     Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
     Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
     Loading debian-ispell...
     Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
     Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
     Loading /etc/emacs/site-start.d/51debian-el.el (source)...

   when running a script.  That would be a nice thing if you wanted to
   write something like wc or so.

 - It would speed up startup by a factor of five (for me, 0.01 secs
   vs. 0.002 secs when using the wrapper from above)

 - It might not be necessary to load site stuff.  On the contrary, if
   you want to write portable scripts, it might be more desirable to be
   able to write environment independent scripts


Many thanks,

Michael.




In GNU Emacs 25.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5)
 of 2015-05-27 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11701000
System Description:	Debian GNU/Linux testing (stretch)

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY
LIBXML2 FREETYPE XFT ZLIB





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Thu, 28 May 2015 18:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 20682 <at> debbugs.gnu.org
Subject: Re: bug#20682: 25.0.50; Enable users to combine --script and --quick
Date: Thu, 28 May 2015 14:48:04 -0400
> This is a feature request to enable users to write emacs scripts (à la
> --script) that can be executed in a way that --quick does (i.e. avoid
> loading site stuff).

I'm not very much in favor of adding yet another ad-hoc arg for that.
OTOH I'd be happy to see a new argument that lets you provide various
args as one.  E.g. "emacs --args=-Q,--script" which would be more
generally useful to deal with the limit of only one arg in shebang.
Given the size limit of shebang lines, we'd also want this extra arg to
be shortish.

An alternative would be to combine --args and --script, so you could
say "emacs --script=-Q" to get what you're asking for.

>  - There are no messages like:

>      Loading 00debian-vars...
>      Loading /etc/emacs/site-start.d/50a2ps.el (source)...
>      Loading /etc/emacs/site-start.d/50autoconf.el (source)...
>      Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
>      Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
>      Loading debian-ispell...
>      Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
>      Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
>      Loading /etc/emacs/site-start.d/51debian-el.el (source)...

>    when running a script.  That would be a nice thing if you wanted to
>    write something like wc or so.

I consider those messages as bugs.

BTW, Ideally, Debian packaging of Emacs packages should move towards
installing those packages as ELPA packages (i.e. install them into one
of package-directory-list and let Emacs load their <pkg>-autoloads.el
file).

>  - It would speed up startup by a factor of five (for me, 0.01 secs
>    vs. 0.002 secs when using the wrapper from above)

We should look into speeding this up, BTW.  Part of it might be
a problem on Debian's side (where those files do too much), but
I suspect that the problem goes deeper and we should figure out how to
improve it.  E.g. package.el's handling of package initialization could
use some optimization for the usual case where the set of packages is
the same as last time.

E.g. Ideally we could cache somewhere the last set of packages seen
along with the resulting set of <pkg>-autoloads.el files that we loaded
and actually keep the concatenation of those files into a single file
which we'd load instead.  Of course, this won't work currently because
those files are "position dependent" (e.g. they use load-file-name or
#$), but we should try and solve those problems.

>  - It might not be necessary to load site stuff.  On the contrary, if
>    you want to write portable scripts, it might be more desirable to be
>    able to write environment independent scripts

I tend to consider that any <pkg>-autoloads.el file should be 100%
harmless, or at least that the kind of changes they cause should be no
worse than the kinds of changes you experience when going from
Emacs-A.B to Emacs-A.C or Emacs-A+1.C


        Stefan


PS: Just to clarify, this should not be taken as an argument against
providing a way to get both -Q and --script as a single arg.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Thu, 28 May 2015 20:31:04 GMT) Full text and rfc822 format available.

Message #11 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 20682 <at> debbugs.gnu.org
Subject: Re: bug#20682: 25.0.50; Enable users to combine --script and --quick
Date: Thu, 28 May 2015 16:30:19 -0400
Stefan Monnier wrote:

> OTOH I'd be happy to see a new argument that lets you provide various
> args as one.  E.g. "emacs --args=-Q,--script" which would be more
> generally useful to deal with the limit of only one arg in shebang.
> Given the size limit of shebang lines, we'd also want this extra arg to
> be shortish.
>
> An alternative would be to combine --args and --script, so you could
> say "emacs --script=-Q" to get what you're asking for.

Apparently it's somewhat conventional (perl, ruby) to use "-x" for this
purpose. A nice write-up at

https://github.com/smikes/node/blob/minus-x-switch/doc/Minus-X-Switch-Proposal.md

Amazingly, "-x" is available as an Emacs command-line switch...


Personally, I'd probably just use a trivial shell wrapper script.




Merged 20682 25671. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 09 Feb 2017 21:30:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Mon, 18 Apr 2022 11:02:01 GMT) Full text and rfc822 format available.

Message #16 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 25671 <at> debbugs.gnu.org, Michael Heerdegen <michael_heerdegen <at> web.de>,
 Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 20682 <at> debbugs.gnu.org
Subject: Re: bug#25671: Feature request: emacs -Q --script as a single binary
Date: Mon, 18 Apr 2022 13:01:10 +0200
Glenn Morris <rgm <at> gnu.org> writes:

>> OTOH I'd be happy to see a new argument that lets you provide various
>> args as one.  E.g. "emacs --args=-Q,--script" which would be more
>> generally useful to deal with the limit of only one arg in shebang.
>> Given the size limit of shebang lines, we'd also want this extra arg to
>> be shortish.
>>
>> An alternative would be to combine --args and --script, so you could
>> say "emacs --script=-Q" to get what you're asking for.
>
> Apparently it's somewhat conventional (perl, ruby) to use "-x" for this
> purpose. A nice write-up at
>
> https://github.com/smikes/node/blob/minus-x-switch/doc/Minus-X-Switch-Proposal.md
>
> Amazingly, "-x" is available as an Emacs command-line switch...

I think that sounds really attractive, so I've added this to Emacs 29.
The new -x switch is like --script, but will kill Emacs when it reaches
the end of the script, and return the value of the final form as the
return value, so you can say use 0 at the end to signal success to the
caller.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 25671 <at> debbugs.gnu.org and Clément Pit--Claudel <clement.pitclaudel <at> live.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 18 Apr 2022 11:02:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Thu, 05 May 2022 22:16:02 GMT) Full text and rfc822 format available.

Message #21 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 25671 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>,
 Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 20682 <at> debbugs.gnu.org
Subject: Re: bug#25671: Feature request: emacs -Q --script as a single binary
Date: Fri, 06 May 2022 00:14:53 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> > Amazingly, "-x" is available as an Emacs command-line switch...
>
> I think that sounds really attractive, so I've added this to Emacs 29.
> The new -x switch is like --script, but will kill Emacs when it reaches
> the end of the script, and return the value of the final form as the
> return value, so you can say use 0 at the end to signal success to the
> caller.

Thanks - but it doesn't work correctly for me.  Contrarily to --script,
my init file is being loaded with -x.  Does that work correctly for you,
Lars?

TIA,

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Fri, 06 May 2022 12:06:01 GMT) Full text and rfc822 format available.

Message #24 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 25671 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>,
 Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 20682 <at> debbugs.gnu.org
Subject: Re: bug#25671: Feature request: emacs -Q --script as a single binary
Date: Fri, 06 May 2022 14:05:13 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Thanks - but it doesn't work correctly for me.  Contrarily to --script,
> my init file is being loaded with -x.  Does that work correctly for you,
> Lars?

Nope.  Should be fixed now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#20682; Package emacs. (Sat, 07 May 2022 02:10:02 GMT) Full text and rfc822 format available.

Message #27 received at 20682 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 25671 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>,
 Stefan Monnier <monnier <at> IRO.UMontreal.CA>, 20682 <at> debbugs.gnu.org
Subject: Re: bug#25671: Feature request: emacs -Q --script as a single binary
Date: Sat, 07 May 2022 04:08:55 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Nope.  Should be fixed now.

Better - thanks.

Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Jun 2022 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.