[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [works on the comman line] (was: [a directory is also created])
From: |
Emanuel Berg |
Subject: |
Re: [works on the comman line] (was: [a directory is also created]) |
Date: |
Mon, 21 Feb 2022 05:18:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Uwe Brauer and then Jean Louis wrote:
> On the command line
> zip -9 -j test.zip test.tex
>
> Works but emacs or dired adds a directory, who is here
> the culprit?
Actually, both are correct :)
It is because of the relative path where you are when you run
the command in the shell, OTOH in the Elisp code you give zip
the path.
See the man file for zip(1):
By default, zip will store the full path (relative to the
current directory).
The option you are looking for is '--junk-path'.
> You can do it in single function here:
>
> (defun rcd-zip-file ()
> "ZIP single file within Dired."
> (interactive)
> (let* ((file (car (dired-get-marked-files t)))
> (zip-file (concat file ".zip")))
> (when file
> (start-process "ZIP" "ZIP" "zip" "-9" zip-file file)
> (revert-buffer))))
Yeah, but why have a specific function for a single file, if
it is based on files first being marked anyway? If that's the
method it is better to have a generic function and if one
wants to zip a zingle file, just mark that and nothing else,
if you want more, then instead you do that?
Try this:
(defun dired-zip-files ()
(interactive)
(dolist (f (dired-get-marked-files))
(start-process "zip" nil "zip" "-9" "--junk-path" (concat f ".zip") f)
(revert-buffer) ))
--
underground experts united
https://dataswamp.org/~incal
- Re: how to generate a zip file (not a directory) within dired, (continued)
- Re: how to generate a zip file (not a directory) within dired, Jean Louis, 2022/02/20
- Re: how to generate a zip file (not a directory) within dired, Uwe Brauer, 2022/02/20
- [a directory is also created] (was: how to generate a zip file (not a directory) within dired), Uwe Brauer, 2022/02/20
- [works on the comman line] (was: [a directory is also created]), Uwe Brauer, 2022/02/20
- Re: [works on the comman line] (was: [a directory is also created]), Jean Louis, 2022/02/20
- Re: [works on the comman line], Uwe Brauer, 2022/02/20
- Re: [works on the comman line], Uwe Brauer, 2022/02/20
- Re: [works on the comman line], Emanuel Berg, 2022/02/20
- Re: [works on the comman line], Uwe Brauer, 2022/02/21
- Re: [works on the comman line], Emanuel Berg, 2022/02/25
- Re: [works on the comman line] (was: [a directory is also created]),
Emanuel Berg <=