unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* extracting a zip archive via elisp (with no external executables)
@ 2017-07-09 12:26 Saulius Menkevičius
  2017-07-09 18:51 ` Alan Third
  0 siblings, 1 reply; 11+ messages in thread
From: Saulius Menkevičius @ 2017-07-09 12:26 UTC (permalink / raw)
  To: emacs-devel

Hello,

I am looking for a package (or integrated functionality in Emacs) 
which I could use to extract a .zip file to a specified folder. So far
I have not found any functionality that can be used to do this
programatically.

There is arc-mode.el but it references existing binaries that should 
be available on the system (unzip, 7zip, etc.)

Those executables are (usually) present on UNIX systems on $PATH, 
but on Windows I am out of luck, apparently.

What I am trying to achieve is:
 - download a .zip file (via url-copy-file)
 - extract it to ~/.emacs.d/.cache/<package>/ subdir

Any hints?

Thanks,
-Saulius Menkevicius



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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 12:26 extracting a zip archive via elisp (with no external executables) Saulius Menkevičius
@ 2017-07-09 18:51 ` Alan Third
  2017-07-09 18:58   ` Saulius Menkevičius
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Third @ 2017-07-09 18:51 UTC (permalink / raw)
  To: Saulius Menkevičius; +Cc: emacs-devel

On Sun, Jul 09, 2017 at 03:26:10PM +0300, Saulius Menkevičius wrote:
> There is arc-mode.el but it references existing binaries that should 
> be available on the system (unzip, 7zip, etc.)
> 
> Those executables are (usually) present on UNIX systems on $PATH, 
> but on Windows I am out of luck, apparently.

I’m not aware of any way to do this without using an external binary,
but that’s not very hard. You can grab a Windows version of unzip from

    http://gnuwin32.sourceforge.net/packages/unzip.htm

and either add it’s directory to the windows PATH or put the files
into an existing location on the PATH, like maybe into the Emacs
install’s bin directory.

-- 
Alan Third



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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 18:51 ` Alan Third
@ 2017-07-09 18:58   ` Saulius Menkevičius
  2017-07-09 19:15     ` Kaushal Modi
  0 siblings, 1 reply; 11+ messages in thread
From: Saulius Menkevičius @ 2017-07-09 18:58 UTC (permalink / raw)
  To: Alan Third; +Cc: emacs-devel

The problem is those files come within a .zip file too.

 Kind of a chicken and egg scenario here for automatic code..

-Saulius

> Am 09.07.2017 um 21:51 schrieb Alan Third <alan@idiocy.org>:
> 
> On Sun, Jul 09, 2017 at 03:26:10PM +0300, Saulius Menkevičius wrote:
>> There is arc-mode.el but it references existing binaries that should 
>> be available on the system (unzip, 7zip, etc.)
>> 
>> Those executables are (usually) present on UNIX systems on $PATH, 
>> but on Windows I am out of luck, apparently.
> 
> I’m not aware of any way to do this without using an external binary,
> but that’s not very hard. You can grab a Windows version of unzip from
> 
>    http://gnuwin32.sourceforge.net/packages/unzip.htm
> 
> and either add it’s directory to the windows PATH or put the files
> into an existing location on the PATH, like maybe into the Emacs
> install’s bin directory.
> 
> -- 
> Alan Third




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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 18:58   ` Saulius Menkevičius
@ 2017-07-09 19:15     ` Kaushal Modi
  2017-07-09 19:26       ` Saulius Menkevičius
  0 siblings, 1 reply; 11+ messages in thread
From: Kaushal Modi @ 2017-07-09 19:15 UTC (permalink / raw)
  To: Saulius Menkevičius, Alan Third; +Cc: Emacs developers

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

On Sun, Jul 9, 2017, 2:59 PM Saulius Menkevičius <
saulius.menkevicius@gmail.com> wrote:

> The problem is those files come within a .zip file too.
>
>  Kind of a chicken and egg scenario here for automatic code..
>

You need to extract those outside Emacs. One way is to install 7-zip
(search for 7-zip Windows executables online).

> --

Kaushal Modi

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

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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 19:15     ` Kaushal Modi
@ 2017-07-09 19:26       ` Saulius Menkevičius
  2017-07-09 19:45         ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Saulius Menkevičius @ 2017-07-09 19:26 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Alan Third, Emacs developers

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

> 
> Am 09.07.2017 um 22:15 schrieb Kaushal Modi <kaushal.modi@gmail.com>:
> 
> On Sun, Jul 9, 2017, 2:59 PM Saulius Menkevičius <saulius.menkevicius@gmail.com <mailto:saulius.menkevicius@gmail.com>> wrote:
> The problem is those files come within a .zip file too.
> 
>  Kind of a chicken and egg scenario here for automatic code..
> 
> You need to extract those outside Emacs. One way is to install 7-zip (search for 7-zip Windows executables online). 
> -- 
> Kaushal Modi
> 

Not sure I expressed myself properly..

I am one of the maintainers of the C# package for emacs https://github.com/OmniSharp/omnisharp-emacs <https://github.com/OmniSharp/omnisharp-emacs>
For the package to work properly it needs to run language server, which
should be downloaded from https://github.com/OmniSharp/omnisharp-roslyn/releases <https://github.com/OmniSharp/omnisharp-roslyn/releases>

I have added a new interactive command omnisharp-install-server which
downloads and installs the server to ~/.emacs.d/.cache/omnisharp/server/<version> directory.
Thus aleviating the need for the user to navigate to web page, download, extract
and the configure package to point to the location where the server has been extracted.

For UNIX systems things are easy, I just download tarball and extract it with (call-process „tar“ .. „xz“..)

But on Windows things get tough, apparently.

Instructing the user to install 7-zip or something else manually kind of
invalidates the purpose of automatic installation. I want to keep this functionality
low-noise and avoid any involvement of the user. Which I can do on macOS & Linux
but I cannot find a way to do non-intrusively on Windows...

BR,
-Saulius

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

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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 19:26       ` Saulius Menkevičius
@ 2017-07-09 19:45         ` Eli Zaretskii
  2017-07-09 19:49           ` Saulius Menkevičius
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2017-07-09 19:45 UTC (permalink / raw)
  To: Saulius Menkevičius; +Cc: alan, emacs-devel, kaushal.modi

> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
> Date: Sun, 9 Jul 2017 22:26:45 +0300
> Cc: Alan Third <alan@idiocy.org>, Emacs developers <emacs-devel@gnu.org>
> 
> I am one of the maintainers of the C# package for emacs https://github.com/OmniSharp/omnisharp-emacs
> For the package to work properly it needs to run language server, which
> should be downloaded from https://github.com/OmniSharp/omnisharp-roslyn/releases
> 
> I have added a new interactive command omnisharp-install-server which
> downloads and installs the server to ~/.emacs.d/.cache/omnisharp/server/<version> directory.
> Thus aleviating the need for the user to navigate to web page, download, extract
> and the configure package to point to the location where the server has been extracted.
> 
> For UNIX systems things are easy, I just download tarball and extract it with (call-process „tar“ .. „xz“..)
> 
> But on Windows things get tough, apparently.

Not really.  This should get them going:

     (w32-shell-execute "open" "FILENAME.zip")
or
     (w32-shell-execute "explore" "FILENAME.zip")

(replace FILENAME.zip with the actual file name).  This will open the
Windows Explorer showing the contents of the zip archive, and you
should tell your users to click "File->Extract all" to extract the
files into the directory of their choosing.

> Instructing the user to install 7-zip or something else manually kind of
> invalidates the purpose of automatic installation.

Please never suggest to install 7z, it's not Free Software on Windows
(and on Unix it's less capable to make it Free Software).  If someone
needs 7z capabilities, the best Free Software alternative is bsdtar
from the libarchive project.



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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 19:45         ` Eli Zaretskii
@ 2017-07-09 19:49           ` Saulius Menkevičius
  2017-07-09 20:09             ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Saulius Menkevičius @ 2017-07-09 19:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: alan, emacs-devel, kaushal.modi

Am 09.07.2017 um 22:45 schrieb Eli Zaretskii <eliz@gnu.org>:
> 
>> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
>> Date: Sun, 9 Jul 2017 22:26:45 +0300
>> Cc: Alan Third <alan@idiocy.org>, Emacs developers <emacs-devel@gnu.org>
>> 
>> I am one of the maintainers of the C# package for emacs https://github.com/OmniSharp/omnisharp-emacs
>> For the package to work properly it needs to run language server, which
>> should be downloaded from https://github.com/OmniSharp/omnisharp-roslyn/releases
>> 
>> I have added a new interactive command omnisharp-install-server which
>> downloads and installs the server to ~/.emacs.d/.cache/omnisharp/server/<version> directory.
>> Thus aleviating the need for the user to navigate to web page, download, extract
>> and the configure package to point to the location where the server has been extracted.
>> 
>> For UNIX systems things are easy, I just download tarball and extract it with (call-process „tar“ .. „xz“..)
>> 
>> But on Windows things get tough, apparently.
> 
> Not really.  This should get them going:
> 
>     (w32-shell-execute "open" "FILENAME.zip")
> or
>     (w32-shell-execute "explore" "FILENAME.zip")
> 
> (replace FILENAME.zip with the actual file name).  This will open the
> Windows Explorer showing the contents of the zip archive, and you
> should tell your users to click "File->Extract all" to extract the
> files into the directory of their choosing.
> 
>> Instructing the user to install 7-zip or something else manually kind of
>> invalidates the purpose of automatic installation.
> 
> Please never suggest to install 7z, it's not Free Software on Windows
> (and on Unix it's less capable to make it Free Software).  If someone
> needs 7z capabilities, the best Free Software alternative is bsdtar
> from the libarchive project.

My questions is still, is it possible to avoid involving user in this procedure?

Or do I need to roll out my own zip parser + extractor in elisp to do so :(
Which is probably slightly complicated thing to do.. Compared to what I
am trying to achieve.

-Saulius


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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 19:49           ` Saulius Menkevičius
@ 2017-07-09 20:09             ` Eli Zaretskii
  2017-07-09 20:16               ` Saulius Menkevičius
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2017-07-09 20:09 UTC (permalink / raw)
  To: Saulius Menkevičius; +Cc: alan, emacs-devel, kaushal.modi

> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
> Date: Sun, 9 Jul 2017 22:49:50 +0300
> Cc: kaushal.modi@gmail.com,
>  alan@idiocy.org,
>  emacs-devel@gnu.org
> 
> >     (w32-shell-execute "open" "FILENAME.zip")
> > or
> >     (w32-shell-execute "explore" "FILENAME.zip")
> > 
> > (replace FILENAME.zip with the actual file name).  This will open the
> > Windows Explorer showing the contents of the zip archive, and you
> > should tell your users to click "File->Extract all" to extract the
> > files into the directory of their choosing.
> > 
> >> Instructing the user to install 7-zip or something else manually kind of
> >> invalidates the purpose of automatic installation.
> > 
> > Please never suggest to install 7z, it's not Free Software on Windows
> > (and on Unix it's less capable to make it Free Software).  If someone
> > needs 7z capabilities, the best Free Software alternative is bsdtar
> > from the libarchive project.
> 
> My questions is still, is it possible to avoid involving user in this procedure?

But the user is already involved -- they started the installation to
begin with, didn't they?  So why do you want so hard to avoid them
clicking one more button?

> Or do I need to roll out my own zip parser + extractor in elisp to do so :(
> Which is probably slightly complicated thing to do.. Compared to what I
> am trying to achieve.

Maybe somebody knows how to tell the Explorer to extract the files
without user interaction.  I don't.



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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 20:09             ` Eli Zaretskii
@ 2017-07-09 20:16               ` Saulius Menkevičius
  2017-07-10  2:26                 ` Eli Zaretskii
  2017-07-10  7:25                 ` Fabrice Popineau
  0 siblings, 2 replies; 11+ messages in thread
From: Saulius Menkevičius @ 2017-07-09 20:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: alan, emacs-devel, kaushal.modi


> Am 09.07.2017 um 23:09 schrieb Eli Zaretskii <eliz@gnu.org>:
> 
>> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
>> Date: Sun, 9 Jul 2017 22:49:50 +0300
>> Cc: kaushal.modi@gmail.com,
>> alan@idiocy.org,
>> emacs-devel@gnu.org
>> 
>>>    (w32-shell-execute "open" "FILENAME.zip")
>>> or
>>>    (w32-shell-execute "explore" "FILENAME.zip")
>>> 
>>> (replace FILENAME.zip with the actual file name).  This will open the
>>> Windows Explorer showing the contents of the zip archive, and you
>>> should tell your users to click "File->Extract all" to extract the
>>> files into the directory of their choosing.
>>> 
>>>> Instructing the user to install 7-zip or something else manually kind of
>>>> invalidates the purpose of automatic installation.
>>> 
>>> Please never suggest to install 7z, it's not Free Software on Windows
>>> (and on Unix it's less capable to make it Free Software).  If someone
>>> needs 7z capabilities, the best Free Software alternative is bsdtar
>>> from the libarchive project.
>> 
>> My questions is still, is it possible to avoid involving user in this procedure?
> 
> But the user is already involved -- they started the installation to
> begin with, didn't they?  So why do you want so hard to avoid them
> clicking one more button?

But then they probably need to specify target directory or do other things with
the UI that pops out. And they leave emacs (even if for a moment). Ideally I
would want to make this procedure slick and low profile… Which it is on
LInux/macOS..

> 
>> Or do I need to roll out my own zip parser + extractor in elisp to do so :(
>> Which is probably slightly complicated thing to do.. Compared to what I
>> am trying to achieve.
> 
> Maybe somebody knows how to tell the Explorer to extract the files
> without user interaction.  I don't.


I was looking for this a bit too, and yeah, people propose the same thing,
i.e. invoke „rundll32 zipfldr.dll,RouteTheCall file.zip“ but I have not found yet
any exports that do extract the file automatically..

Thanks for your thoughts! I think I will come to some kind of solution
eventually. Hopefully this will avoid writing a homemade zip file parser.

-BR, 
Saulius


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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 20:16               ` Saulius Menkevičius
@ 2017-07-10  2:26                 ` Eli Zaretskii
  2017-07-10  7:25                 ` Fabrice Popineau
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2017-07-10  2:26 UTC (permalink / raw)
  To: Saulius Menkevičius; +Cc: alan, emacs-devel, kaushal.modi

> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
> Date: Sun, 9 Jul 2017 23:16:40 +0300
> Cc: kaushal.modi@gmail.com,
>  alan@idiocy.org,
>  emacs-devel@gnu.org
> 
> >> My questions is still, is it possible to avoid involving user in this procedure?
> > 
> > But the user is already involved -- they started the installation to
> > begin with, didn't they?  So why do you want so hard to avoid them
> > clicking one more button?
> 
> But then they probably need to specify target directory or do other things with
> the UI that pops out.

The target directory needs to be specified, with the default shown in
the dialog.  That's all they need to do.



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

* Re: extracting a zip archive via elisp (with no external executables)
  2017-07-09 20:16               ` Saulius Menkevičius
  2017-07-10  2:26                 ` Eli Zaretskii
@ 2017-07-10  7:25                 ` Fabrice Popineau
  1 sibling, 0 replies; 11+ messages in thread
From: Fabrice Popineau @ 2017-07-10  7:25 UTC (permalink / raw)
  To: Saulius Menkevičius
  Cc: Eli Zaretskii, kaushal.modi, alan, Emacs developers

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

Why not build a self-extracting .exe file ?

Fabrice

2017-07-09 22:16 GMT+02:00 Saulius Menkevičius <
saulius.menkevicius@gmail.com>:

>
> > Am 09.07.2017 um 23:09 schrieb Eli Zaretskii <eliz@gnu.org>:
> >
> >> From: Saulius Menkevičius <saulius.menkevicius@gmail.com>
> >> Date: Sun, 9 Jul 2017 22:49:50 +0300
> >> Cc: kaushal.modi@gmail.com,
> >> alan@idiocy.org,
> >> emacs-devel@gnu.org
> >>
> >>>    (w32-shell-execute "open" "FILENAME.zip")
> >>> or
> >>>    (w32-shell-execute "explore" "FILENAME.zip")
> >>>
> >>> (replace FILENAME.zip with the actual file name).  This will open the
> >>> Windows Explorer showing the contents of the zip archive, and you
> >>> should tell your users to click "File->Extract all" to extract the
> >>> files into the directory of their choosing.
> >>>
> >>>> Instructing the user to install 7-zip or something else manually kind
> of
> >>>> invalidates the purpose of automatic installation.
> >>>
> >>> Please never suggest to install 7z, it's not Free Software on Windows
> >>> (and on Unix it's less capable to make it Free Software).  If someone
> >>> needs 7z capabilities, the best Free Software alternative is bsdtar
> >>> from the libarchive project.
> >>
> >> My questions is still, is it possible to avoid involving user in this
> procedure?
> >
> > But the user is already involved -- they started the installation to
> > begin with, didn't they?  So why do you want so hard to avoid them
> > clicking one more button?
>
> But then they probably need to specify target directory or do other things
> with
> the UI that pops out. And they leave emacs (even if for a moment). Ideally
> I
> would want to make this procedure slick and low profile… Which it is on
> LInux/macOS..
>
> >
> >> Or do I need to roll out my own zip parser + extractor in elisp to do
> so :(
> >> Which is probably slightly complicated thing to do.. Compared to what I
> >> am trying to achieve.
> >
> > Maybe somebody knows how to tell the Explorer to extract the files
> > without user interaction.  I don't.
>
>
> I was looking for this a bit too, and yeah, people propose the same thing,
> i.e. invoke „rundll32 zipfldr.dll,RouteTheCall file.zip“ but I have not
> found yet
> any exports that do extract the file automatically..
>
> Thanks for your thoughts! I think I will come to some kind of solution
> eventually. Hopefully this will avoid writing a homemade zip file parser.
>
> -BR,
> Saulius
>



-- 
Fabrice Popineau
-----------------------------
CentraleSupelec
Département Informatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
------------------------------

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

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

end of thread, other threads:[~2017-07-10  7:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-09 12:26 extracting a zip archive via elisp (with no external executables) Saulius Menkevičius
2017-07-09 18:51 ` Alan Third
2017-07-09 18:58   ` Saulius Menkevičius
2017-07-09 19:15     ` Kaushal Modi
2017-07-09 19:26       ` Saulius Menkevičius
2017-07-09 19:45         ` Eli Zaretskii
2017-07-09 19:49           ` Saulius Menkevičius
2017-07-09 20:09             ` Eli Zaretskii
2017-07-09 20:16               ` Saulius Menkevičius
2017-07-10  2:26                 ` Eli Zaretskii
2017-07-10  7:25                 ` Fabrice Popineau

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