pymacs:一般问题和安装问题

发布于 2024-07-26 16:16:53 字数 3292 浏览 7 评论 0原文

我正在尝试为 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 ,但我的电脑上安装了 python 2.6。 但显然,rope 不喜欢 2.4,所以我没有运行 setup.py。 我解压/解压缩这些包并将这些文件放在 ~/.emacs.d/site-lisp 下。 默认情况下,如果在命令提示符下调用 python,则它是 python 2.4 可执行文件。

问:如何成功加载“pymacs”?

I am trying to setup emacs for python development.

From what I read, it is recommended to use python-mode.el rather than the default python.el from Emacs 22.3. So I embark on the new adventure.

From what I understand, python-mode has the several dependencies, so I need to install rope, ropemode and ropemacs. Then on top of that I need to install pymacs.

Q: is it correct?

This is my new .emacs now:

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

Now, when i start emacs, I got this error message:

("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]

To make it slightly more complicated:

For work reason I have to use python 2.4, but I have python 2.6 installed on my PC. But obviously rope does not like 2.4 so I did not run setup.py. I untar/unzip these packages and put these files under ~/.emacs.d/site-lisp. By default if python is invoked in command prompt, it is the python 2.4 executable.

Q: How can I successfully load 'pymacs'?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

意犹 2024-08-02 16:16:53

到目前为止,我从未使用过 pymacs,但是当我查看您的 .emacs 时,引起我注意的一件事是您显然没有将 pymacs 目录添加到 emacs 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")

或任何您有 pymacs.el 的地方),以便emacs 可以找到 lisp 文件。 pymacs 文档中也提到了

2.4 正确安装 Pymacs ...用于 Emacs 部分...

现在这通常是手工完成的。
首先选择一些目录
保存在 Emacs 加载路径中的列表,用于
您有写入权限,然后复制
在该目录中创建 pymacs.el 文件。

I have never used pymacs so far, but one thing which catches my eye when I look at your .emacs is that you apparently didn't add the pymacs directory to the emacs load-path but only to the pymacs one:

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

You will probably need also something like:

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

(or whereever you have pymacs.el) so that emacs can find the lisp files. Also mentioned in the pymacs documentation

2.4 Install the Pymacs proper ... for the Emacs part ...

This is usually done by hand now.
First select some directory along the
list kept in your Emacs load-path, for
which you have write access, and copy
file pymacs.el in that directory.

牵你手 2024-08-02 16:16:53

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

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

显然我需要加载 pymac 脚本。

我已将环境变量 PYMACS_PYTHON 设置为 python 2.6,因为出于工作原因,我使用 python 2.4 作为默认 python 解释器。

It turns out I missed these two:

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

Obviously I need to load the pymac script.

And I have set the env var PYMACS_PYTHON to python 2.6 because I am using python 2.4 as default python interpreter, for work reason.

说谎友 2024-08-02 16:16:53

如果路径丢失,那么很容易在启动日志中或通过在 emacs 启动时获取回溯来发现这一点。 如果有疑问,Mx load-library 是最佳选择。

在最新的 Debian 测试更新之后,我也遇到了 company-ropemacs 拒绝加载 emacs 23 和 emacs 24 的情况,这意味着由于绳索保存钩子,您无法保存文件。 我很想听听任何使用它的人的意见。 Company-ropemacs 和 python 与 emacs 之间的矛盾已经有一段时间了。 我打算稍后再尝试调试它,然后更新此线程。

If paths are missing then this will easily be spotted in the startup log or by getting a backtrace at emacs start. If in doubt M-x load-library is the way to go.

I too am getting company-ropemacs refusing to load with both emacs 23 and emacs 24 after latest Debian Testing updates which then means you can not save files because of rope save hooks. I would be interested to hear from anyone with it working. company-ropemacs and python in general with emacs has been a thorn for some time now. I intend to try and debug it some more later and will update this thread then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文