=== modified file 'python-mode.el' --- python-mode.el 2012-02-15 20:51:45 +0000 +++ python-mode.el 2012-02-15 22:54:19 +0000 @@ -9102,13 +9102,10 @@ (defun py-guess-py-install-directory () (interactive) - (let* ((bufn (buffer-file-name)) - (erg (when (or (string-match "python-mode.el" bufn)(string-match "python-components-mode.el" bufn)) (file-name-directory (buffer-file-name))))) + (let ((erg (file-name-directory (locate-library "python-mode")))) (when erg - (add-to-list 'load-path erg) - (setq py-install-directory erg) - (when (interactive-p) (message "%s" erg)) - erg))) + (when (interactive-p) (message "Setting py-install-directory to: %s" erg)) + (setq py-install-directory erg)))) (defun py-set-load-path () "Include needed subdirs of python-mode directory. " @@ -9120,7 +9117,9 @@ (add-to-list 'load-path (concat (expand-file-name py-install-directory) "/test")) (add-to-list 'load-path (concat (expand-file-name py-install-directory) "/tools"))) ((when py-guess-py-install-directory-p - (py-guess-py-install-directory))) + (let ((guessed-py-install-directory (py-guess-py-install-directory))) + (when guessed-py-install-directory + (add-to-list 'load-path guessed-py-install-directory))))) (t (error "Please set `py-install-directory', see INSTALL")) (when (interactive-p) (message "%s" load-path)))) @@ -9233,7 +9232,13 @@ (current-column)))) (^ '(- (1+ (current-indentation)))))) (when python-load-extended-executes-p - (add-hook 'python-mode-hook '(lambda ()(load (concat py-install-directory "/python-extended-executes.el") nil t)))) + (if (not py-install-directory) + (unless (and py-guess-py-install-directory-p + (py-guess-py-install-directory)) + (error "Need to set py-install-directory."))) + (add-hook 'python-mode-hook + '(lambda () + (load (concat py-install-directory "python-extended-executes.el") nil t)))) ;; Python defines TABs as being 8-char wide. (set (make-local-variable 'tab-width) py-indent-offset) ;; Now do the automagical guessing