]> git.eshelyaron.com Git - emacs.git/commitdiff
(archive-find-type): Add recognition of rar-exe format.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Dec 2007 02:05:48 +0000 (02:05 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 2 Dec 2007 02:05:48 +0000 (02:05 +0000)
(archive-rar-summarize): Allow the file name to be passed as argument.
Remove unused vars `header' and `footer'.
(archive-rar-exe-summarize, archive-rar-exe-extract): New functions.

lisp/ChangeLog
lisp/arc-mode.el

index f32f7c86531a5c9c3a0427d82140559ea17d70b6..db23a638f9875aaae63ce877d98bbb9879192617 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-02  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * arc-mode.el (archive-find-type): Add recognition of rar-exe format.
+       (archive-rar-summarize): Allow the file name to be passed as argument.
+       Remove unused vars `header' and `footer'.
+       (archive-rar-exe-summarize, archive-rar-exe-extract): New functions.
+
 2007-12-01  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * log-edit.el (log-edit-show-diff): New function.
@@ -38,8 +45,8 @@
        * textmodes/org-export-latex.el (org-export-latex-cleaned-string):
        Move args on defun line.
 
-       * textmodes/org.el (org-calendar-holiday): Use
-       calendar-check-holidays instead of the obsolete
+       * textmodes/org.el (org-calendar-holiday):
+       Use calendar-check-holidays instead of the obsolete
        check-calendar-holidays.
        (add-to-diary-list, table--at-cell-p, Info-find-node, bbdb)
        (bbdb-company, bbdb-current-record, bbdb-name)
@@ -69,8 +76,8 @@
 
        * longlines.el (longlines-show-hard-newlines): Remove handling of
        buffer-undo-list and buffer-modified status.
-       (longlines-show-region, longlines-unshow-hard-newlines): Handle
-       buffer-undo-list, buffer-modified status, inhibit-read-only, and
+       (longlines-show-region, longlines-unshow-hard-newlines):
+       Handle buffer-undo-list, buffer-modified status, inhibit-read-only, and
        inhibit-modification-hooks here to avoid that a buffer appears
        modified when toggling visibility of hard newlines.
 
        * net/newsticker.el (w3m-toggle-inline-image, htmlr-reset)
        (htmlr-step): Declare as functions.
 
-       * net/eudcb-bbdb.el (eudc-bbdb-extract-addresses): Use
-       bbdb-address-zip rather than bbdb-address-zip-string.
+       * net/eudcb-bbdb.el (eudc-bbdb-extract-addresses):
+       Use bbdb-address-zip rather than bbdb-address-zip-string.
 
 2007-11-28  Richard Stallman  <rms@gnu.org>
 
 
        * nxml/nxml-maint.el (nxml-create-unicode-char-name-sets):
        * nxml/nxml-mode.el (nxml-get-char-name, nxml-insert-named-char):
-       * nxml/xsd-regexp.el (xsdre-gen-categories): Use mapc rather than
-       mapcar.
+       * nxml/xsd-regexp.el (xsdre-gen-categories): Change mapcar -> mapc.
 
        * nxml/nxml-outln.el (nxml-token-start-tag-p)
        (nxml-token-end-tag-p): Move definitions before use.
index 404e4543e0b454e65e8ce823197b2807eb94164e..8fb9e239b1ca061dfd786656cfc1f054897a5c7b 100644 (file)
@@ -705,6 +705,9 @@ archive.
           ;; Note this regexp is also in archive-exe-p.
           ((looking-at "MZ\\(.\\|\n\\)\\{34\\}LH[aA]'s SFX ") 'lzh-exe)
           ((looking-at "Rar!") 'rar)
+          ((and (looking-at "MZ")
+                (re-search-forward "Rar!" (+ (point) 100000) t))
+           'rar-exe)
          (t (error "Buffer format not recognized")))))
 ;; -------------------------------------------------------------------------
 
@@ -1844,10 +1847,10 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
 ;; -------------------------------------------------------------------------
 ;;; Section: Rar Archives
 
-(defun archive-rar-summarize ()
-  (let* ((file buffer-file-name)
-         (copy (file-local-copy file))
-         header footer
+(defun archive-rar-summarize (&optional file)
+  ;; File is used internally for `archive-rar-exe-summarize'.
+  (unless file (setq file buffer-file-name))
+  (let* ((copy (file-local-copy file))
          (maxname 10)
          (maxsize 5)
          (files ()))
@@ -1856,9 +1859,6 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
       (if copy (delete-file copy))
       (goto-char (point-min))
       (re-search-forward "^-+\n")
-      (setq header
-            (buffer-substring (save-excursion (re-search-backward "^[^ ]"))
-                              (point)))
       (while (looking-at (concat " \\(.*\\)\n" ;Name.
                                  ;; Size ; Packed.
                                  " +\\([0-9]+\\) +[0-9]+"
@@ -1878,8 +1878,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
                         size (match-string 3)
                         ;; Date, Time.
                         (match-string 4) (match-string 5))
-                files)))
-      (setq footer (buffer-substring (point) (point-max))))
+                files))))
     (setq files (nreverse files))
     (goto-char (point-min))
     (let* ((format (format " %%s %%s  %%%ds %%5s  %%s" maxsize))
@@ -1921,9 +1920,44 @@ This doesn't recover lost files, it just undoes changes in the buffer itself."
           (delete-directory (expand-file-name name dest)))
         (delete-directory dest)))))
 
+;;; Section: Rar self-extracting .exe archives.
+
+(defun archive-rar-exe-summarize ()
+  (let ((tmpfile (make-temp-file "rarexe")))
+    (unwind-protect
+        (progn
+          (goto-char (point-min))
+          (re-search-forward "Rar!")
+          (write-region (match-beginning 0) (point-max) tmpfile)
+          (archive-rar-summarize tmpfile))
+      (delete-file tmpfile))))
+
+(defun archive-rar-exe-extract (archive name)
+  (let* ((tmpfile (make-temp-file "rarexe"))
+         (buf (find-buffer-visiting archive))
+         (tmpbuf (unless buf (generate-new-buffer " *rar-exe*"))))
+    (unwind-protect
+        (progn
+          (with-current-buffer (or buf tmpbuf)
+            (save-excursion
+              (save-restriction
+                (if buf
+                    ;; point-max unwidened is assumed to be the end of the
+                    ;; summary text and the beginning of the actual file data.
+                    (progn (goto-char (point-max)) (widen))
+                  (insert-file-contents-literally archive)
+                  (goto-char (point-min)))
+                (re-search-forward "Rar!")
+                (write-region (match-beginning 0) (point-max) tmpfile))))
+          (archive-rar-extract tmpfile name))
+      (if tmpbuf (kill-buffer tmpbuf))
+      (delete-file tmpfile))))
+  
+
 ;; -------------------------------------------------------------------------
 ;; This line was a mistake; it is kept now for compatibility.
 ;; rms  15 Oct 98
+
 (provide 'archive-mode)
 
 (provide 'arc-mode)