From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#5513: Archives disregard special mode-class Date: Thu, 04 Feb 2010 02:07:18 +0200 Organization: JURTA Message-ID: <873a1h26c9.fsf@mail.jurta.org> References: <873a1j2p71.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1265245102 21164 80.91.229.12 (4 Feb 2010 00:58:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Feb 2010 00:58:22 +0000 (UTC) Cc: 5513@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 04 01:58:19 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ncq31-0005pa-7W for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Feb 2010 01:58:19 +0100 Original-Received: from localhost ([127.0.0.1]:48606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ncq30-0002dD-Me for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Feb 2010 19:58:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ncq2N-0002OZ-SA for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2010 19:57:39 -0500 Original-Received: from [199.232.76.173] (port=47572 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ncq2M-0002OF-Ri for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2010 19:57:38 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ncq2L-0003Gh-5Z for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2010 19:57:38 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57852) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ncq2K-0003Gb-Pp for bug-gnu-emacs@gnu.org; Wed, 03 Feb 2010 19:57:37 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NcpgU-0004QN-RQ; Wed, 03 Feb 2010 19:35:02 -0500 X-Loop: bug-gnu-emacs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2010 00:35:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: followup 5513 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 5513-submit@debbugs.gnu.org id=B5513.126524365016962 (code B ref 5513); Thu, 04 Feb 2010 00:35:02 +0000 Original-Received: (at 5513) by debbugs.gnu.org; 4 Feb 2010 00:34:10 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ncpfe-0004PX-Hk for submit@debbugs.gnu.org; Wed, 03 Feb 2010 19:34:10 -0500 Original-Received: from smtp-out4.starman.ee ([85.253.0.6] helo=mx2.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ncpfc-0004PF-Mt for 5513@debbugs.gnu.org; Wed, 03 Feb 2010 19:34:09 -0500 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.30.224.cable.starman.ee [82.131.30.224]) by mx2.starman.ee (Postfix) with ESMTP id B104E3F4072; Thu, 4 Feb 2010 02:33:59 +0200 (EET) In-Reply-To: (Stefan Monnier's message of "Tue, 02 Feb 2010 21:21:42 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 03 Feb 2010 19:35:02 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:34890 Archived-At: >> ;; FIXME: code duplicated from `view-file', perhaps the test for >> ;; special mode-class should be moved from `view-file' to `view-buffer'. > > Then at least move it to a new view-buffer-1 function. > But please don't introduce such code duplication. I think all `view-buffer' calls should respect the property `mode-class', so I moved this code from `view-file' to `view-buffer'. `view-buffer-1' is a new function with the old content of `view-buffer' for the case when some package would prefer to ignore `mode-class' for some reasons. I hesitate to install this patch now because it changes the behavior of `view-file' for a non-critical bug. === modified file 'lisp/view.el' --- lisp/view.el 2010-01-13 08:35:10 +0000 +++ lisp/view.el 2010-02-04 00:05:22 +0000 @@ -263,13 +263,7 @@ (defun view-file (file) (unless (file-exists-p file) (error "%s does not exist" file)) (let ((had-a-buf (get-file-buffer file)) (buffer (find-file-noselect file))) - (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 (not had-a-buf) 'kill-buffer-if-not-modified))))) + (view-buffer buffer (and (not had-a-buf) 'kill-buffer-if-not-modified)))) ;;;###autoload (defun view-file-other-window (file) @@ -335,6 +329,15 @@ (defun view-buffer (buffer &optional exi Exiting View mode will then discard the user's edits. Setting EXIT-ACTION to `kill-buffer-if-not-modified' avoids this." (interactive "bView 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-1 buffer exit-action))) + +(defun view-buffer-1 (buffer &optional exit-action) (let ((undo-window (list (window-buffer) (window-start) (window-point)))) (switch-to-buffer buffer) (view-mode-enter (cons (selected-window) (cons nil undo-window)) -- Juri Linkov http://www.jurta.org/emacs/