pymacs:一般问题和安装问题

时间:2009-07-03 06:55:41

标签: python emacs rope pymacs

我正在尝试为python开发设置emacs。

根据我的阅读,建议使用python-mode.el而不是Emacs 22.3中的默认python.el。所以我开始了新的冒险。

据我所知,python-mode有几个依赖项,所以我需要安装rope,ropemode和ropemacs。然后,我需要安装pymacs。

问:这是正确的吗?

这是我新的.emacs现在:

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(inhibit-startup-screen t)
 '(tab-width 4))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

(setq emacs-config-path "~/.emacs.d/")
(setq base-lisp-path "~/.emacs.d/site-lisp/")
(setq site-lisp-path (concat emacs-config-path "/site-lisp"))
(defun add-path (p)
  (add-to-list 'load-path (concat base-lisp-path p)))

(add-path "") 
(add-to-list 'load-path "~/.emacs.d")

(require 'psvn)

;; python-mode
;;
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)


(setq pymacs-load-path '(   "~/.emacs.d/site-lisp/rope"
                            "~/.emacs.d/site-lisp/ropemode"
                            "~/.emacs.d/site-lisp/ropemacs"))


(setq interpreter-mode-alist
      (cons '("python" . python-mode)
        interpreter-mode-alist)
      python-mode-hook
      '(lambda () (progn
            (set-variable 'py-indent-offset 4)
            (set-variable 'py-smart-indentation nil)
            (set-variable 'indent-tabs-mode nil)
            ;;(highlight-beyond-fill-column)
                    (define-key python-mode-map "\C-m" 'newline-and-indent)
            (pabbrev-mode)
            (abbrev-mode)
     )
      )
)


;; pymacs
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)

;; Search local path for emacs rope
;;

;; enable pymacs
;; 
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")

现在,当我启动emacs时,我收到此错误消息:

("C:\\opt\\emacs-22.3\\bin\\emacs.exe")
Loading encoded-kb...done
Loading regexp-opt...done
Loading easy-mmode...done
Loading wid-edit...done
Loading edmacro...done
Loading derived...done
Loading advice...done
Loading cl-macs...done
Loading byte-opt...done


An error has occurred while loading `c:/opt/cygwin/home/akong/.emacs':

File error: Cannot open load file, pymacs

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

For information about GNU Emacs and the GNU system, type C-h C-a. [2 times]

使其稍微复杂一点:

出于工作原因,我必须使用python 2.4,但我的PC上安装了python 2.6。但显然绳子不喜欢2.4,所以我没有运行setup.py。我解压缩/解压缩这些包并将这些文件放在〜/ .emacs.d / site-lisp下。默认情况下,如果在命令提示符下调用python,则它是python 2.4可执行文件。

问:如何成功加载'pymacs'?

3 个答案:

答案 0 :(得分:1)

到目前为止我从未使用过pymacs,但是当我查看你的.emacs时,有一件事引起了我的注意,那就是你显然没有将pymacs目录添加到 emacs { {1}}但仅限load-path一个:

pymacs

您可能还需要以下内容:

(setq pymacs-load-path '( "~/.emacs.d/site-lisp/rope"
                          "~/.emacs.d/site-lisp/ropemode"
                          "~/.emacs.d/site-lisp/ropemacs"))

(或者你有(add-to-list 'load-path "~/.emacs.d/site-lisp/rope") (add-to-list 'load-path "~/.emacs.d/site-lisp/ropemode") (add-to-list 'load-path "~/.emacs.d/site-lisp/ropemacs") ),以便emacs可以找到lisp文件。也在pymacs documentation

中提到
  

2.4安装适当的Pymacs ......用于Emacs部件...

     

这通常是手工完成的。   首先选择一些目录   列表保存在您的Emacs 加载路径中,用于   你有写访问权限和副本   文件pymacs.el在该目录中。

答案 1 :(得分:1)

事实证明我错过了这两个:

(add-to-list 'load-path "~/.emacs.d/site-lisp/Pymacs-0.23")

显然我需要加载pymac脚本。

我已经将env var PYMACS_PYTHON设置为python 2.6,因为出于工作原因,我使用python 2.4作为默认的python解释器。

答案 2 :(得分:1)

如果路径丢失,那么很容易在启动日志中或在emacs启动时获得回溯。如果有疑问,可以使用M-x加载库。

在最新的Debian测试更新之后,我也得到了公司-classmacs拒绝加载emacs 23和emacs 24,这意味着你因为绳索保存挂钩而无法保存文件。我很想听听有人工作的消息。公司 - ropemacs和python一般与emacs一直是一段时间的刺。我打算稍后再尝试调试它,然后更新这个线程。