English 中文(简体)
• 如何在应急中心安装和压缩标记档案
原标题:How to [tar and] compress marked files in Emacs
  • 时间:2012-04-19 11:14:04
  •  标签:
  • emacs
  • dired

在《Debian Squeeze变量一》的Emacs 23.2.1中,dired+选择了4个文档,编号为*,然后用Z加以压缩。 我迅速回答了<条码>y,并在小楼看到一些最新状况。 我在哪里找到压缩的档案? 我在one文档(C-uZ上进行了测试,Emacs在一份档案中进行了gzip的测试,将其编为.gz文档。 我如何在信标中标出有标记的档案?

(为了预先防范关于tar、 g、其他格式和一般档案的任何哲学或方法讨论,我所希望的是作为压缩数据储存的四种档案。) 如果可以通过tar、zi或直接压缩到档案中来做到这一点,则确实如此。

最佳回答

如果dired+ 是任何东西,例如dired,你可在m上标出,然后打到!(在有标记的文档上打着双壳指挥),并具体指明指挥为tar -czfoo.tar.gz */code>(>, is a special signer, 改为有标记的文档名称。

问题回答

You can also archive files just by marking and copying them to an archive file.

例如,在可怕的文件中标出几个文档,并选定<代码>m-x dired-do-copy。

When prompted for destination, type test.zip. The files will be added to the zip archive automatically.

你们也可以通过挑选可怕的档案和操作指挥系统(<>dired-do-extract)来解冻档案。

To set this up, look at the following variables: dired-to-archive-copy-alist dired-extract-alist

Here s my setup, which has served me for many years...

;; dired-a provides support functions, including archiving, for dired
(load "dired-a")

;; Alist with information how to add files to an archive (from dired-a)
;; Each element has the form (REGEXP ADD-CMD NEW-CMD). If REGEXP matches
;; the file name of a target, that target is an archive and ADD-CMD is a command
;; that adds to an existing archive and NEW-CMD is a command that makes a new
;; archive (overwriting an old one if it exists). ADD-CMD and NEW-CMD are:
;; 1. Nil (meaning we cannot do this for this type of archive) (one of
;;    ADD-CMD and NEW-CMD must be non-nil).
;; 2. A symbol that must be a function e.g. dired-do-archive-op.
;; 3. A format string with two arguments, the source files concatenated into
;;    a space separated string and the target archive.
;; 4. A list of strings, the command and its flags, to which the target and
;;    the source-files are concatenated."
(setq dired-to-archive-copy-alist
       (("\.sh\(ar\|[0-9]\)*$" nil "shar %s > %s")
    ("\.jar$" ("jar" "uvf") ("jar" "cvf"))
    ("\.tar$" ("tar" "-uf") ("tar" "-cf"))
    ("\.tgz$\|\.tar\.g?[zZ]$" ("tar" "-uf %s" "|" "gzip > %s") ("tar" "-czvf"))
    ("\.ear$" ("zip" "-qr") ("zip" "-qr"))
;   ("\.rar$" ("rar" "a")   ("rar" "a"))
    ("\.war$" ("zip" "-qr") ("zip" "-qr"))
    ("\.zip$" ("zip" "-qr") ("zip" "-qr"))
    ("\.wmz$" ("zip" "-qr") ("zip" "-qr")) ;; for media player skins
    ("\.arc$" ("arc" "a") nil)
    ("\.zoo$" ("zoo" "aP") nil)
    ))

;; use pkzip with manipulating zip files (t) from within dired (use zip
;; and unzip otherwise)
(setq archive-zip-use-pkzip nil)

;; add these file types to archive mode to allow viewing and changing
;; their contents
(add-to-list  auto-mode-alist  ("\.[ejrw]ar$\ " . archive-mode))

;; modify the dired-extract switches to use the directory
;; ~/download/tryout as the default extract directory for zip files
(defconst MY_TRYOUT_DIR "~/downloads/tryout"
  "Directory for extracting files")

(setq dired-extract-alist
      `(
    ("\.u\(ue\|aa\)$" . dired-uud)
    ("\.jar$" . "jar -xvf %s")
    ("\.tar$" . ,(concat "tar -xf %s -C " MY_TRYOUT_DIR))
    ("\.tgz$\|\.tar\.g?[zZ]$" . ,(concat "tar -xzf %s -C " MY_TRYOUT_DIR))
    ("\.arc$" . "arc x %s ")
    ("\.bz2$" . ,(concat "bunzip2 -q %s"))
    ("\.rar$" . ,(concat "unrar x %s " MY_TRYOUT_DIR "\"))
    ("\.zip$" . ,(concat "unzip -qq -Ux %s -d " MY_TRYOUT_DIR))
    ("\.ear$" . ,(concat "unzip -qq -Ux %s -d " MY_TRYOUT_DIR))
    ("\.war$" . ,(concat "unzip -qq -Ux %s -d " MY_TRYOUT_DIR))
    ("\.zoo$" . "zoo x. %s ")
    ("\.lzh$" . "lha x %s ")
    ("\.7z$"  . "7z e %s ")
    ("\.g?[zZ]$" . "gzip -d %s")   ; There is only one file
    ))

平台:乌班图

<>查询>

System:
sudo apt-get install atool

Emacs:
M-x package-list-packages
C-s dired-atool RET
i
x

<>Solution

1) Mark the files in dired buffer.
2) M-x dired-atool-do-pack NOTE: Make sure that shell-file-name is set to "/bin/bash".

在回答后一个问题时,另一个可用于生成雷患的压缩弹壳的工具是。 标识所希望的文档和执行<代码> 包装-dired-do- Pack,具体说明whatever.tar.gz为产出文档名称。





相关问题
suppress additional braces in emacs electric mode

I started using ruby-electric-mode. I like it except that I am used to closing open brackets myself (the other pairing are still useful to me). How can I make emacs suppress additional brackets when ...

Setting up an emacs environment in windows?

I am currently constrained to a windows dev box and I want to migrate my projects from eclipse to emacs. What are some good references on setting up an emacs dev environment for windows? Anything ...

Emacs Setting which-function-mode

I would like to have which-function-mode on by default when I open up Emacs. I ve added the following lines to my .emacs file. (setq which-func-mode t) (setq which-function-mode t) When I open ...

Enabling go mode for emacs

I don t seem to be able to enable a go mode for emacs. C mode doesn t work without semicolons. The best I have found is the JavaScript mode by Karl Landstrom, since JavaScript also doesn t require ...

Custom Emacs key bindings are not working

The key bindings I ve defined in my .emacs file aren t working. Here s the file: ;init modes (menu-bar-mode 0) (tool-bar-mode 0) (cua-mode) (column-number-mode) (fset perl-mode cperl-mode) (cperl-...

eval during emacs lisp macro expansion

How can I fix the simple macro foo in (elisp)Eval During Expansion? None of the followings work: (defmacro foo1 (a) `(setq (eval ,a) t)) (defmacro foo2 (a) `(setq ,(eval a) t)) (defmacro foo3 (...

Get local cvs comment history when committing file/s in emacs

I often commit files with similar cvs comment but not in a single operation. I would like to able to bring up previous comments I ve used in a previous commit when I am in the process of writing a ...