changeset 104838:27450b6f6cf7

(diary-fancy-display): Only switch modes if necessary. (diary-fancy-overriding-map): New variable. (diary-fancy-display-mode): Set minor-mode-overriding-map-alist. Use view-mode.
author Glenn Morris <rgm@gnu.org>
date Fri, 04 Sep 2009 02:59:13 +0000
parents 6c2939592100
children 6e7b745a5ee5
files lisp/ChangeLog lisp/calendar/diary-lib.el
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Sep 04 02:49:07 2009 +0000
+++ b/lisp/ChangeLog	Fri Sep 04 02:59:13 2009 +0000
@@ -1,5 +1,11 @@
 2009-09-04  Glenn Morris  <rgm@gnu.org>
 
+	* calendar/diary-lib.el (diary-fancy-display): Only switch modes if
+	necessary.
+	(diary-fancy-overriding-map): New variable.
+	(diary-fancy-display-mode): Set minor-mode-overriding-map-alist.
+	Use view-mode.
+
 	* vc-rcs.el (vc-rcs-annotate-command): Use forward-line rather than
 	goto-line.
 
--- a/lisp/calendar/diary-lib.el	Fri Sep 04 02:49:07 2009 +0000
+++ b/lisp/calendar/diary-lib.el	Fri Sep 04 02:59:13 2009 +0000
@@ -1019,7 +1019,8 @@
                      (overlay-put
                       (make-overlay (match-beginning 0) (match-end 0))
                       'face temp-face)))))))
-      (diary-fancy-display-mode)
+      (or (eq major-mode 'diary-fancy-display-mode)
+          (diary-fancy-display-mode))
       (calendar-set-mode-line date-string)
       (message "Preparing diary...done"))))
 
@@ -2348,6 +2349,11 @@
       (setq end (line-beginning-position 2)))
   (font-lock-default-fontify-region beg end verbose))
 
+(defvar diary-fancy-overriding-map (let ((map (make-sparse-keymap)))
+                                     (define-key map "q" 'quit-window)
+                                     map)
+  "Keymap overriding minor-mode maps in `diary-fancy-display-mode'.")
+
 (define-derived-mode diary-fancy-display-mode fundamental-mode
   "Diary"
   "Major mode used while displaying diary entries using Fancy Display."
@@ -2356,7 +2362,9 @@
          t nil nil nil
          (font-lock-fontify-region-function
           . diary-fancy-font-lock-fontify-region-function)))
-  (local-set-key "q" 'quit-window))
+  (set (make-local-variable 'minor-mode-overriding-map-alist)
+       (list (cons t diary-fancy-overriding-map)))
+  (view-mode 1))
 
 (define-obsolete-function-alias 'fancy-diary-display-mode
   'diary-fancy-display-mode "23.1")