unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How can I put together a small bare bones "Emacs for scripting" package?
@ 2020-01-24 15:34 Mathias Dahl
  2020-01-24 15:49 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Mathias Dahl @ 2020-01-24 15:34 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]

Hi,

I am writing a lot of tools for my own use at work in Emacs. Sometimes I
like to share these tools with friends who are not using Emacs. I have
tried this a few times and I have ended up zipping my whole Emacs file
structure together with some scripts to start Emacs and do the stuff for
them.

This approach kind of works, but today I got thinking: how little could I
actually copy from my Emacs installation to have basic scripting working?
And with basic scripting I mean basic file handling (creating, checking
for, deleting), buffer handling and basic text manipulation stuff.

Obviously I would need emacs.exe. On my Windows installation it's around 9
MB. A bit on the big side for a scripting engine, still not bad by today's
standards.

But what would I need more, for Emacs to even start? If I knew the bare
minimum of what is needed to start, I think I would be able to add in any
additional features just by copying those Elisp files.

Any thoughts, comments or pointers to further reading?

Thanks!

/Mathias

[-- Attachment #2: Type: text/html, Size: 1254 bytes --]

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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-24 15:34 How can I put together a small bare bones "Emacs for scripting" package? Mathias Dahl
@ 2020-01-24 15:49 ` Eli Zaretskii
  2020-01-24 16:18   ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2020-01-24 15:49 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: emacs-devel

> From: Mathias Dahl <mathias.dahl@gmail.com>
> Date: Fri, 24 Jan 2020 16:34:08 +0100
> 
> Obviously I would need emacs.exe. On my Windows installation it's around 9 MB. A bit on the big side for a
> scripting engine, still not bad by today's standards.
> 
> But what would I need more, for Emacs to even start? If I knew the bare minimum of what is needed to start, I
> think I would be able to add in any additional features just by copying those Elisp files.

Start with emacs.exe alone, and then add *.elc files according to
error messages you get.  You will need lisp/term/w32-win.el at least,
but other than that, I don't know.




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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-24 15:49 ` Eli Zaretskii
@ 2020-01-24 16:18   ` Eli Zaretskii
  2020-01-24 21:37     ` Mathias Dahl
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2020-01-24 16:18 UTC (permalink / raw)
  To: mathias.dahl; +Cc: emacs-devel

> Date: Fri, 24 Jan 2020 17:49:11 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> Start with emacs.exe alone, and then add *.elc files according to
> error messages you get.  You will need lisp/term/w32-win.el at least,
> but other than that, I don't know.

I see you'd also need simple.elc (because we look for it at startup),
and with Emacs before 27 also mule-util.elc.  Emacs will probably
complain about a missing libexec directory, so create it.



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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-24 16:18   ` Eli Zaretskii
@ 2020-01-24 21:37     ` Mathias Dahl
  2020-01-25  7:41       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Mathias Dahl @ 2020-01-24 21:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]

>
> > Start with emacs.exe alone, and then add *.elc files according to
> > error messages you get.  You will need lisp/term/w32-win.el at least,
> > but other than that, I don't know.
>
> I see you'd also need simple.elc (because we look for it at startup),
> and with Emacs before 27 also mule-util.elc.  Emacs will probably
> complain about a missing libexec directory, so create it.
>

Thanks!

Got it to work.

Here seems to be the bare minimum structure needed for Emacs 26.3 on
Windows 10:

./bin
./bin/emacs.exe
./libexec
./libexec/emacs
./libexec/emacs/26.3
./libexec/emacs/26.3/x86_64-w64-mingw32
./share
./share/emacs
./share/emacs/26.3
./share/emacs/26.3/etc
./share/emacs/26.3/etc/charsets
./share/emacs/26.3/etc/charsets/8859-10.map
... a lot of map files goes here ..
./share/emacs/26.3/lisp
./share/emacs/26.3/lisp/simple.el
./share/emacs/26.3/lisp/term
./share/emacs/26.3/lisp/term/w32-win.el

I could then successfully do this (from cmd.exe, a similar command also
worked from Git Bash)

  C:\...> bin\emacs.exe --batch -Q --eval "(princ """This is cool!""")"
  This is cool!
  C:\...>

I might write up something more detailed on EmacsWiki later. It took a bit
of trial and error to get it to work and the error messages are only partly
helpful (they mention looking in c:\emacs, a folder that does not exist,
and which is not needed).

One thing that I noticed is the HUGE difference in size of the exe file
between Emacs 24 and later versions. I listed the sizes of the folder when
I keep my different Emacs versions:

8.8M    ./emacs-24.5-official/bin/emacs.exe
91M     ./emacs-25.1-2-x86_64-w64-mingw32_2016_11_16/bin/emacs.exe
119M    ./emacs-26.1-x86_64/bin/emacs.exe
120M    ./emacs-26.2-x86_64/bin/emacs.exe
130M    ./emacs-26.3-x86_64/bin/emacs.exe
16M     ./emacs-bin-w64-24.4/emacs/bin/emacs.exe
121M    ./emax64-bin-20180529/emax64/bin/emacs.exe
119M    ./old/emacs-26.1/bin/emacs.exe

Now, I can probably use an old version for the mentioned scenarios (using
Emacs as a kind of scripting engine), but I am curious about the jump in
sizes. I assume that later versions include something that was earlier
"outside", in separate files, is that right? If I wanted to, could I reduce
the size by building Emacs myself? Is this in some way related to "dumping
Emacs"?

/Mathias

[-- Attachment #2: Type: text/html, Size: 3034 bytes --]

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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-24 21:37     ` Mathias Dahl
@ 2020-01-25  7:41       ` Eli Zaretskii
  2020-01-25 20:12         ` Mathias Dahl
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2020-01-25  7:41 UTC (permalink / raw)
  To: Mathias Dahl; +Cc: emacs-devel

> From: Mathias Dahl <mathias.dahl@gmail.com>
> Date: Fri, 24 Jan 2020 22:37:14 +0100
> Cc: emacs-devel@gnu.org
> 
> One thing that I noticed is the HUGE difference in size of the exe file between Emacs 24 and later versions. I
> listed the sizes of the folder when I keep my different Emacs versions:
> 
> 8.8M    ./emacs-24.5-official/bin/emacs.exe
> 91M     ./emacs-25.1-2-x86_64-w64-mingw32_2016_11_16/bin/emacs.exe
> 119M    ./emacs-26.1-x86_64/bin/emacs.exe
> 120M    ./emacs-26.2-x86_64/bin/emacs.exe
> 130M    ./emacs-26.3-x86_64/bin/emacs.exe
> 16M     ./emacs-bin-w64-24.4/emacs/bin/emacs.exe
> 121M    ./emax64-bin-20180529/emax64/bin/emacs.exe
> 119M    ./old/emacs-26.1/bin/emacs.exe

The small ones are stripped, the large ones are with debug info.  If
you have the 'strip' command (from Binutils) installed, you can strip
the large ones as well.



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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-25  7:41       ` Eli Zaretskii
@ 2020-01-25 20:12         ` Mathias Dahl
  2020-01-27 14:36           ` Mathias Dahl
  0 siblings, 1 reply; 7+ messages in thread
From: Mathias Dahl @ 2020-01-25 20:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

>
> > One thing that I noticed is the HUGE difference in size of the exe file
> between Emacs 24 and later versions. I
> > listed the sizes of the folder when I keep my different Emacs versions:
> >
> > 8.8M    ./emacs-24.5-official/bin/emacs.exe
> > 91M     ./emacs-25.1-2-x86_64-w64-mingw32_2016_11_16/bin/emacs.exe
> > 119M    ./emacs-26.1-x86_64/bin/emacs.exe
> > 120M    ./emacs-26.2-x86_64/bin/emacs.exe
> > 130M    ./emacs-26.3-x86_64/bin/emacs.exe
> > 16M     ./emacs-bin-w64-24.4/emacs/bin/emacs.exe
> > 121M    ./emax64-bin-20180529/emax64/bin/emacs.exe
> > 119M    ./old/emacs-26.1/bin/emacs.exe
>
> The small ones are stripped, the large ones are with debug info.  If
> you have the 'strip' command (from Binutils) installed, you can strip
> the large ones as well.
>

Ah, makes sense.

I tried three different versions of MingW and binutils/strip until I found
one that did not fail :)

Now I have an emacs.exe (emacs-26.3-x86_64-no-deps, from the official Gnu
download location) that is 30 MB in size instead of 132 MB :) And, it still
seems
to work.

Thanks a lot!

/Mathias

[-- Attachment #2: Type: text/html, Size: 1526 bytes --]

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

* Re: How can I put together a small bare bones "Emacs for scripting" package?
  2020-01-25 20:12         ` Mathias Dahl
@ 2020-01-27 14:36           ` Mathias Dahl
  0 siblings, 0 replies; 7+ messages in thread
From: Mathias Dahl @ 2020-01-27 14:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

> Now I have an emacs.exe (emacs-26.3-x86_64-no-deps, from the official Gnu
> download location) that is 30 MB in size instead of 132 MB :) And, it still
> seems
> to work.
>

For the benefit of those who have no means to strip their own exe, I
uploaded my 26.3 version with a small explanation, here:

https://github.com/mathiasdahl/misc-emacs-stuff

/Mathias

[-- Attachment #2: Type: text/html, Size: 768 bytes --]

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

end of thread, other threads:[~2020-01-27 14:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 15:34 How can I put together a small bare bones "Emacs for scripting" package? Mathias Dahl
2020-01-24 15:49 ` Eli Zaretskii
2020-01-24 16:18   ` Eli Zaretskii
2020-01-24 21:37     ` Mathias Dahl
2020-01-25  7:41       ` Eli Zaretskii
2020-01-25 20:12         ` Mathias Dahl
2020-01-27 14:36           ` Mathias Dahl

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