From 1c84ec04f024f9de44b0bb57d60d009b9738c899 Mon Sep 17 00:00:00 2001 From: Matthew Leach Date: Thu, 13 Nov 2014 18:30:24 +0000 Subject: [PATCH] Don't show summary for single-file archives. * arc-mode.el (singular-file-archive-action): New. (archive-mode): Visit file if archive contains a single file. --- lisp/arc-mode.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index ef155ee..279b9a1 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -147,6 +147,13 @@ A local copy of the archive will be used when updating." "Hook run when an archive member has been extracted." :type 'hook :group 'archive) + +(defcustom singular-file-archive-action 'visit-file + "When opening an archive that contains a single file choose +whether to open the file or display the archive summary." + :type '(choice (const :tag "Show archive summary" show-summary) + (const :tag "Visit the single file" visit-file)) + :group 'archive) ;; ------------------------------ ;; Arc archive configuration @@ -742,7 +749,12 @@ archive. (if (default-value 'enable-multibyte-characters) (set-buffer-multibyte 'to)) (archive-summarize nil) - (setq buffer-read-only t)))) + (setq buffer-read-only t) + (when (and (= (length archive-files) 1) + (eq singular-file-archive-action 'visit-file)) + (let ((archive-buffer (current-buffer))) + (archive-extract) + (kill-buffer archive-buffer)))))) ;; Archive mode is suitable only for specially formatted data. (put 'archive-mode 'mode-class 'special) -- 2.1.3