 ;; (standard in the latest Emacs 19 and XEmacs 19 distributions).
 (defvar py-menu nil
   "Menu for Python Mode.
-
-This menu will get created automatically if you have the easymenu
-package.  Note that the latest XEmacs 19 and Emacs 19 versions contain
-this package.")
-
-(if (condition-case nil
-	(require 'easymenu)
-      (error nil))
-    (easy-menu-define
-     py-menu py-mode-map "Python Mode menu"
-     '("Python"
-       ["Comment Out Region"   py-comment-region  (mark)]
-       ["Uncomment Region"     (py-comment-region (point) (mark) '(4)) (mark)]
-       "-"
-       ["Mark current block"   py-mark-block t]
-       ["Mark current def"     mark-python-def-or-class t]
-       ["Mark current class"   (mark-python-def-or-class t) t]
-       "-"
-       ["Shift region left"    py-shift-region-left (mark)]
-       ["Shift region right"   py-shift-region-right (mark)]
-       "-"
-       ["Execute buffer"       py-execute-buffer t]
-       ["Execute region"       py-execute-region (mark)]
-       ["Start interpreter..." py-shell t]
-       "-"
-       ["Go to start of block" py-goto-block-up t]
-       ["Go to start of class" (beginning-of-python-def-or-class t) t]
-       ["Move to end of class" (end-of-python-def-or-class t) t]
-       ["Move to start of def" beginning-of-python-def-or-class t]
-       ["Move to end of def"   end-of-python-def-or-class t]
-       "-"
-       ["Describe mode"        py-describe-mode t]
-       )))
+This menu will get created automatically if you have the `easymenu'
+package.  Note that the latest X/Emacs releases contain this package.")
+
+(and (py-safe (require 'easymenu) t)
+     (easy-menu-define
+      py-menu py-mode-map "Python Mode menu"
+      '("Python"
+	["Comment Out Region"   py-comment-region  (mark)]
+	["Uncomment Region"     (py-comment-region (point) (mark) '(4)) (mark)]
+	"-"
+	["Mark current block"   py-mark-block t]
+	["Mark current def"     mark-python-def-or-class t]
+	["Mark current class"   (mark-python-def-or-class t) t]
+	"-"
+	["Shift region left"    py-shift-region-left (mark)]
+	["Shift region right"   py-shift-region-right (mark)]
+	"-"
+	["Execute buffer"       py-execute-buffer t]
+	["Execute region"       py-execute-region (mark)]
+	["Start interpreter..." py-shell t]
+	"-"
+	["Go to start of block" py-goto-block-up t]
+	["Go to start of class" (beginning-of-python-def-or-class t) t]
+	["Move to end of class" (end-of-python-def-or-class t) t]
+	["Move to start of def" beginning-of-python-def-or-class t]
+	["Move to end of def"   end-of-python-def-or-class t]
+	"-"
+	["Describe mode"        py-describe-mode t]
+	)))
 
 
 

(defun py-kill-emacs-hook ()
  ;; delete our temp files
  (while py-file-queue
    (py-delete-file-silently (car py-file-queue))
    (setq py-file-queue (cdr py-file-queue)))
  (if (not (or py-this-is-lucid-emacs-p py-this-is-emacs-19-p))
      ;; run the hook we inherited, if any
      (and py-inherited-kill-emacs-hook
	   (funcall py-inherited-kill-emacs-hook))))

;; make PROCESS's buffer visible, append STRING to it, and force
;; display; also make shell-mode believe the user typed this string,

(and (fboundp 'make-obsolete-variable)
     (make-obsolete-variable 'py-mode-hook 'python-mode-hook))

(defvar py-mode-map ()
  "Keymap used in `python-mode' buffers.")
(if py-mode-map
    nil
  (setq py-mode-map (make-sparse-keymap))

  ;; shadow global bindings for newline-and-indent w/ the py- version.
