2009-09-16 4 views
17

dired 또는 dired와 유사한 버퍼 내에서 압축을 풀거나 압축을 풀고 싶습니다. 이게 뭐니? Nautilus 파일 관리자와 비슷한 것을 원합니다. 즉, 파일을 선택하고 키 입력을 눌러 이러한 파일을 새 아카이브 파일로 가져 오십시오.Emacs에서 압축을 풀거나 해제하는 방법

고맙습니다.

답변

26

가지고있어 옵션 ...

이 .zip 파일의 압축을 해제하려면, 당신은 단지 'dired-compress-file-suffixes

(eval-after-load "dired-aux" 
    '(add-to-list 'dired-compress-file-suffixes 
       '("\\.zip\\'" ".zip" "unzip"))) 

이제 dired의 Z 키가 .ZIP를 인식 변수에 추가해야 zip 아카이브를 압축 해제하십시오. 이미 지원되는 주소는 gunzip, bunzip2, uncompressdictunzip입니다.

당신은 파일을 표시하고 표시된 파일 세트 압축 수밖에 z 만들기 위해를 사용할 수 있습니다 보관이 .zip에 추가하려면 :

(eval-after-load "dired" 
    '(define-key dired-mode-map "z" 'dired-zip-files)) 
(defun dired-zip-files (zip-file) 
    "Create an archive containing the marked files." 
    (interactive "sEnter name of zip file: ") 

    ;; create the zip file 
    (let ((zip-file (if (string-match ".zip$" zip-file) zip-file (concat zip-file ".zip")))) 
    (shell-command 
    (concat "zip " 
      zip-file 
      " " 
      (concat-string-list 
       (mapcar 
       '(lambda (filename) 
        (file-name-nondirectory filename)) 
       (dired-get-marked-files)))))) 

    (revert-buffer) 

    ;; remove the mark on all the files "*" to " " 
    ;; (dired-change-marks 42 ?\040) 
    ;; mark zip file 
    ;; (dired-mark-files-regexp (filename-to-regexp zip-file)) 
) 

(defun concat-string-list (list) 
    "Return a string which is a concatenation of all elements of the list separated by spaces" 
    (mapconcat '(lambda (obj) (format "%s" obj)) list " ")) 
+0

'Z'그것을하지 않습니다를 - 상자? (또는 'm'으로 표시 한 다음 'Z'를 누르십시오). 나는 그것이 나를 위해 잠시 동안 일한 것을 기억한다. 나는 그것을 여기에서 보았다 : http://xahlee.org/emacs/file_management.html – hatmatrix

+1

'Z'는 파일들을 압축 할 것이고 그것들 각각은 개별적으로 압축 할 것이다. 그것들을 아카이브/zip에 추가하지는 않습니다. CONCAT : 기호의 함수 정의가 무효 : –

+0

그것은 CONCAT 문자열 목록이 존재하지 않는 것 같다 CONCAT 문자열 목록 확인 –

16

파일을 압축하려면 dired에서 해당 디렉토리를 엽니 다. 우편 번호를 m으로 지정하십시오. 그런 다음 당신이 쉘에서와 마찬가지로, 당신이 파일을 표시하고 & unzip를 실행할 수 있습니다 dired에서 전체 아카이브를 추출하려면

! zip foo.zip * <RET> 

을 입력합니다.

zip-archive 모드를 사용하면 zip 파일을 dired와 같은 방식으로 찾아 볼 수 있습니다. 최신 버전의 GNU 이맥스와 함께 제공되며 확장자가 .zip 인 파일을 방문 할 때 기본적으로 사용됩니다. 이 모드에서 개별 파일을 버퍼로 추출 할 수 있으며 거기에서 C-x C-s으로 저장합니다.

관련 문제