unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20682: 25.0.50; Enable users to combine --script and --quick
@ 2015-05-28 13:57 Michael Heerdegen
  2015-05-28 18:48 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2015-05-28 13:57 UTC (permalink / raw)
  To: 20682


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@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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20682: 25.0.50; Enable users to combine --script and --quick
  2015-05-28 13:57 bug#20682: 25.0.50; Enable users to combine --script and --quick Michael Heerdegen
@ 2015-05-28 18:48 ` Stefan Monnier
  2015-05-28 20:30   ` Glenn Morris
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2015-05-28 18:48 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 20682

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20682: 25.0.50; Enable users to combine --script and --quick
  2015-05-28 18:48 ` Stefan Monnier
@ 2015-05-28 20:30   ` Glenn Morris
  2022-04-18 11:01     ` bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2015-05-28 20:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Michael Heerdegen, 20682

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary
  2015-05-28 20:30   ` Glenn Morris
@ 2022-04-18 11:01     ` Lars Ingebrigtsen
  2022-05-05 22:14       ` Michael Heerdegen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-04-18 11:01 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 25671, Michael Heerdegen, Stefan Monnier, 20682

Glenn Morris <rgm@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#25671: Feature request: emacs -Q --script as a single binary
  2022-04-18 11:01     ` bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary Lars Ingebrigtsen
@ 2022-05-05 22:14       ` Michael Heerdegen
  2022-05-06 12:05         ` bug#20682: " Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2022-05-05 22:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25671, Glenn Morris, Stefan Monnier, 20682

Lars Ingebrigtsen <larsi@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary
  2022-05-05 22:14       ` Michael Heerdegen
@ 2022-05-06 12:05         ` Lars Ingebrigtsen
  2022-05-07  2:08           ` Michael Heerdegen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-06 12:05 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 25671, Glenn Morris, Stefan Monnier, 20682

Michael Heerdegen <michael_heerdegen@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary
  2022-05-06 12:05         ` bug#20682: " Lars Ingebrigtsen
@ 2022-05-07  2:08           ` Michael Heerdegen
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Heerdegen @ 2022-05-07  2:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 25671, Glenn Morris, Stefan Monnier, 20682

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Nope.  Should be fixed now.

Better - thanks.

Michael.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-07  2:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-28 13:57 bug#20682: 25.0.50; Enable users to combine --script and --quick Michael Heerdegen
2015-05-28 18:48 ` Stefan Monnier
2015-05-28 20:30   ` Glenn Morris
2022-04-18 11:01     ` bug#20682: bug#25671: Feature request: emacs -Q --script as a single binary Lars Ingebrigtsen
2022-05-05 22:14       ` Michael Heerdegen
2022-05-06 12:05         ` bug#20682: " Lars Ingebrigtsen
2022-05-07  2:08           ` Michael Heerdegen

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