bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5513: Archives disregard special mode-class


From: Juri Linkov
Subject: bug#5513: Archives disregard special mode-class
Date: Thu, 04 Feb 2010 02:07:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (x86_64-pc-linux-gnu)

>>     ;; 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/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]