繁体   English   中英

如何为Emacs安装python-mode.el?

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

我正在使用Ubuntu 10.10(Maverick Meerkat)。 我从Launchpad下载了python-mode.el并将其放在emacs.d/plugins/

现在我如何安装python-mode.el

尝试这个

(add-to-list 'load-path "~/.emacs.d/plugins")
(require 'python-mode)

我发现根据编辑的文件类型自动加载适当的编辑模式会更方便。 有很多方法可以做到这一点,但我通常会在autoload-alist中添加一个条目:

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

对于我喜欢使用的各种模式,我有很长的列表。 如果未安装python-mode(或任何其他模式),它将无提示失败。 如果我在没有安装模式的ISP服务器上运行,我将〜/ lib / elisp添加到加载路径并将丢失的.el文件放在那里。

library-loadable-p来自朋友,只是测试文件是否在加载路径中的某个位置:

(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))))))

我建议克隆最新的快照:

cd ~/.emacs.d/site-lisp/python-mode
bzr branch lp:python-mode

然后添加到.emacs

(add-to-list 'load-path "~/.emacs.d/site-lisp/python-mode")
(setq py-install-directory "~/.emacs.d/site-lisp/python-mode")
(require 'python-mode)

您可以稍后使用以下命令更新到最新版本:

bzr update

但是别忘了重新编译:

(byte-recompile-directory (expand-file-name "~/.emacs.d/site-lisp/python-mode") 0)

在emacs 25中,您可以使用melpa安装python模式,因此只需将其添加到.emacs文件中:

(require 'package)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/"))

重新加载文件,然后键入,

Alt+x list-packages

移动到你想要的包裹,

python-mode

然后点击“enter”,在打开的新缓冲区中移动到Install并按Enter键。

这会导致python-mode安装在~/.emacs.d/elpa

现在在一个打开python-mode的新缓冲区中,编写代码并输入Cu Cc Cc来评估和显示输出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM