unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5513: Archives disregard special mode-class
@ 2010-02-02 23:27 Juri Linkov
  2010-02-03  2:21 ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2010-02-02 23:27 UTC (permalink / raw)
  To: 5513

Visiting a file from an archive activates view-mode even when its major
mode has the property `mode-class' equal to `special'.  For instance,
visiting a .jar archive from .xpi archives or from .tar archives.
(See also bug#4896 for more information.)

This patch takes into account the special mode-class property
and doesn't activate view-mode in this case:

=== modified file 'lisp/arc-mode.el'
--- lisp/arc-mode.el	2010-02-01 23:02:47 +0000
+++ lisp/arc-mode.el	2010-02-02 23:10:14 +0000
@@ -1057,8 +1057,16 @@ (defun archive-extract (&optional other-
 	(archive-maybe-update t))
       (or (not (buffer-name buffer))
           (cond
-           (view-p (view-buffer
-		    buffer (and just-created 'kill-buffer-if-not-modified)))
+           (view-p
+	    ;; FIXME: code duplicated from `view-file', perhaps the test for special
+	    ;; mode-class should be moved from `view-file' to `view-buffer'.
+	    (if (eq (with-current-buffer buffer
+		      (get major-mode 'mode-class))
+		    'special)
+		(progn
+		  (switch-to-buffer buffer)
+		  (message "Not using View mode because the major mode is special"))
+	      (view-buffer buffer (and just-created 'kill-buffer-if-not-modified))))
            ((eq other-window-p 'display) (display-buffer buffer))
            (other-window-p (switch-to-buffer-other-window buffer))
            (t (switch-to-buffer buffer))))))

=== modified file 'lisp/tar-mode.el'
--- lisp/tar-mode.el	2010-01-13 08:35:10 +0000
+++ lisp/tar-mode.el	2010-01-31 20:06:55 +0000
@@ -852,14 +852,23 @@ (defun tar-extract (&optional other-wind
           (set (make-local-variable 'tar-superior-descriptor) descriptor)
           (setq buffer-read-only read-only-p)
           (tar-subfile-mode 1)))
-      (if view-p
-	  (view-buffer
-	   buffer (and just-created 'kill-buffer-if-not-modified))
-	(if (eq other-window-p 'display)
-	    (display-buffer buffer)
-	  (if other-window-p
-	      (switch-to-buffer-other-window buffer)
-	    (switch-to-buffer buffer)))))))
+      (cond
+       (view-p
+	;; FIXME: code duplicated from `view-file', perhaps the test for special
+	;; mode-class should be moved from `view-file' to `view-buffer'.
+	(if (eq (with-current-buffer buffer
+		  (get major-mode 'mode-class))
+		'special)
+	    (progn
+	      (switch-to-buffer buffer)
+	      (message "Not using View mode because the major mode is special"))
+	  (view-buffer buffer (and just-created 'kill-buffer-if-not-modified))))
+       ((eq other-window-p 'display)
+	(display-buffer buffer))
+       (other-window-p
+	(switch-to-buffer-other-window buffer))
+       (t
+	(switch-to-buffer buffer))))))
 
 
 (defun tar-extract-other-window ()

-- 
Juri Linkov
http://www.jurta.org/emacs/







^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-04-18 23:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 23:27 bug#5513: Archives disregard special mode-class Juri Linkov
2010-02-03  2:21 ` Stefan Monnier
2010-02-04  0:07   ` Juri Linkov
2010-02-04 15:22     ` Stefan Monnier
2010-02-04 19:52       ` Juri Linkov
2010-02-04 22:16         ` Stefan Monnier
2010-04-18 23:52           ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).