help-gnu-emacs
[Top][All Lists]
Advanced

[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: Jean Louis
Subject: Re: [works on the comman line] (was: [a directory is also created])
Date: Sun, 20 Feb 2022 17:08:04 +0300
User-agent: Mutt/2.2.0 (2022-02-12)

* Uwe Brauer <oub@mat.ucm.es> [2022-02-20 16:44]:
> >>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:
> 
> >> * Uwe Brauer <oub@mat.ucm.es> [2022-02-20 15:01]:
> 
> >> Solution is Z.
> 
> >> 1) Adapt `dired-compress-file-alist' for ZIP files;
> >> example:
> 
> >> (setf (alist-get "\\.zip\\'" dired-compress-file-alist) "zip -9 %o %i")
> 
> > It is a more complicated that I thought, but this is because of the
> > behavior of zip. If I use this setting zip creates a zip archive that
> > contains the file, but the whole absolute path, and that is crazy.
> 
> 
> > (setf (alist-get "\\.zip\\'" dired-compress-file-alist) "zip -9 
> > --junk-paths %o %i")
> 
> Very odd: 
> 
> On the command line 
> zip -9 -j test.zip test.tex 
> 
> Works but emacs or dired adds a directory, who is here the culprit?

dired-compress-file-alist is a variable defined in ‘dired-aux.el’.

Where it says:

Within CMD, %i denotes the input file(s), and %o denotes the
output file.  %i path(s) are relative, while %o is absolute.

Maybe that is limitation.

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

Then just bind to a key.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]