Add 7z operations to delete and save changed members.
authorJuri Linkov <juri@jurta.org>
Mon, 4 Jul 2011 22:11:40 +0000 (01:11 +0300)
committerJuri Linkov <juri@jurta.org>
Mon, 4 Jul 2011 22:11:40 +0000 (01:11 +0300)
* lisp/arc-mode.el (archive-7z-expunge, archive-7z-update):
New defcustoms.
(archive-7z-write-file-member): New function.
(archive-7z-summarize): Fix the number of dashes in the
listing output.

Fixes: debbugs:8968

etc/NEWS
lisp/ChangeLog
lisp/arc-mode.el

index 01b767b..d123073 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -485,7 +485,7 @@ Just set shell-dir-cookie-re to an appropriate regexp.
 
 ** FIXME: xdg-open for browse-url and reportbug, 2010/08.
 
-** Archive Mode has basic support to browse 7z archives.
+** Archive Mode has basic support to browse and update 7z archives.
 
 ** browse-url has gotten a new variable that is used for mailto: URLs,
 `browse-url-mailto-function', which defaults to `browse-url-mail'.
index 278ead6..d7def50 100644 (file)
@@ -1,3 +1,12 @@
+2011-07-04  Juri Linkov  <juri@jurta.org>
+
+       Add 7z operations to delete and save changed members (bug#8968).
+       * arc-mode.el (archive-7z-expunge, archive-7z-update):
+       New defcustoms.
+       (archive-7z-write-file-member): New function.
+       (archive-7z-summarize): Fix the number of dashes in the
+       listing output.
+
 2011-07-04  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * pcmpl-linux.el (pcomplete-pare-list): Re-add, from pcomplete.el
index 0d12985..e0a587c 100644 (file)
@@ -55,9 +55,9 @@
 ;;                     --------------------------------------------
 ;; View listing                Intern  Intern  Intern  Intern  Y       Y
 ;; Extract member      Y       Y       Y       Y       Y       Y
-;; Save changed member Y       Y       Y       Y       N       N
+;; Save changed member Y       Y       Y       Y       N       Y
 ;; Add new member      N       N       N       N       N       N
-;; Delete member       Y       Y       Y       Y       N       N
+;; Delete member       Y       Y       Y       Y       N       Y
 ;; Rename member       Y       Y       N       N       N       N
 ;; Chmod               -       Y       Y       -       N       N
 ;; Chown               -       Y       -       -       N       N
@@ -323,9 +323,30 @@ Archive and member name will be added."
 Extraction should happen to standard output.  Archive and member name will
 be added."
   :type '(list (string :tag "Program")
-               (repeat :tag "Options"
-                       :inline t
-                       (string :format "%v")))
+              (repeat :tag "Options"
+                      :inline t
+                      (string :format "%v")))
+  :group 'archive-7z)
+
+(defcustom archive-7z-expunge
+  '("7z" "d")
+  "Program and its options to run in order to delete 7z file members.
+Archive and member names will be added."
+  :type '(list (string :tag "Program")
+              (repeat :tag "Options"
+                      :inline t
+                      (string :format "%v")))
+  :group 'archive-7z)
+
+(defcustom archive-7z-update
+  '("7z" "u")
+  "Program and its options to run in order to update a 7z file member.
+Options should ensure that specified directory will be put into the 7z
+file.  Archive and member name will be added."
+  :type '(list (string :tag "Program")
+              (repeat :tag "Options"
+                      :inline t
+                      (string :format "%v")))
   :group 'archive-7z)
 
 ;; -------------------------------------------------------------------------
@@ -2037,7 +2058,9 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
     (with-temp-buffer
       (call-process "7z" nil t nil "l" "-slt" file)
       (goto-char (point-min))
-      (re-search-forward "^-+\n")
+      ;; Four dashes start the meta info section that should be skipped.
+      ;; Archive members start with more than four dashes.
+      (re-search-forward "^-----+\n")
       (while (re-search-forward "^Path = \\(.*\\)\n" nil t)
         (goto-char (match-end 0))
         (let ((name (match-string 1))
@@ -2084,6 +2107,12 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
          (message "%s" (buffer-string)))
        (delete-file tmpfile)))))
 
+(defun archive-7z-write-file-member (archive descr)
+  (archive-*-write-file-member
+   archive
+   descr
+   archive-7z-update))
+
 ;; -------------------------------------------------------------------------
 ;;; Section `ar' archives.