Small cal-menu fix for bug#9976
[bpt/emacs.git] / lisp / calendar / cal-menu.el
index 877be95..d8de171 100644 (file)
@@ -1,7 +1,6 @@
 ;;; cal-menu.el --- calendar functions for menu bar and popup menu support
 
-;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2011  Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
 ;;         Lara Rios <lrios@coewl.cen.uiuc.edu>
@@ -216,13 +215,15 @@ is non-nil."
 ;; but easymenu does not seem to allow this (?).
 ;; The ignore-errors is because `documentation' can end up calling
 ;; this in a non-calendar buffer where displayed-month is unbound.  (Bug#3862)
+;; This still has issues - bug#9976, so added derived-mode-p call.
 (defun cal-menu-set-date-title (menu)
   "Convert date of last event to title suitable for MENU."
-  (let ((date (ignore-errors (calendar-cursor-to-date nil last-input-event))))
-    (if date
-        (easy-menu-filter-return menu (calendar-date-string date t nil))
-      (message "Not on a date!")
-      nil)))
+  (when (derived-mode-p 'calendar-mode)
+    (let ((date (ignore-errors (calendar-cursor-to-date nil last-input-event))))
+      (if date
+          (easy-menu-filter-return menu (calendar-date-string date t nil))
+        (message "Not on a date!")
+        nil))))
 
 (easy-menu-define cal-menu-context-mouse-menu nil
   "Pop up mouse menu for selected date in the calendar window."
@@ -281,5 +282,4 @@ is non-nil."
 
 (provide 'cal-menu)
 
-;; arch-tag: aa81cf73-ce89-48a4-97ec-9ef861e87fe9
 ;;; cal-menu.el ends here