Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install python-mode.el for Emacs?

Tags:

python

emacs

I am using Ubuntu 10.10 (Maverick Meerkat). I have downloaded python-mode.el from Launchpad and placed it in emacs.d/plugins/.

Now how do I install python-mode.el?

like image 711
murtaza52 Avatar asked Jul 06 '12 13:07

murtaza52


2 Answers

Try this

(add-to-list 'load-path "~/.emacs.d/plugins")
(require 'python-mode)
like image 128
mamboking Avatar answered Oct 05 '22 12:10

mamboking


I find it more convenient to have the appropriate editing mode auto-load based on the type of file edited. There are lots of ways to do this, but I usually add an entry to autoload-alist:

(and (library-loadable-p "python-mode")
     (setq auto-mode-alist (append '(
                     ("\\.py\\'"       . python-mode)
                     )
                   auto-mode-alist)))

I have a long list of these for the various modes I like to use. It fails silently if python-mode (or any other mode) is not installed. If I'm running on an ISP sever that doesn't have a mode installed, I add ~/lib/elisp to the load-path and put the missing .el files in there.

library-loadable-p came from a friend and simply tests whether the file is somewhere in the load path:

(defun library-loadable-p (lib &optional nosuffix)
  "Return t if library LIB is found in load-path.
Optional NOSUFFIX means don't try appending standard .elc and .el suffixes."
  (let ((path load-path)
    elt)
    (catch 'lib-found
      (while (car path)
    (setq elt (car path))
    (and
     (if nosuffix
         (file-exists-p (concat elt "/" lib))
       (or (file-exists-p (concat elt "/" lib ".elc"))
           (file-exists-p (concat elt "/" lib ".el"))
           (file-exists-p (concat elt "/" lib))))
     (throw 'lib-found t))
    (setq path (cdr path))))))
like image 27
ericx Avatar answered Oct 05 '22 12:10

ericx