6

Python 開発用に emacs をセットアップしようとしています。

私が読んだところによると、Emacs 22.3 のデフォルトの python.el ではなく、python-mode.el を使用することをお勧めします。だから私は新しい冒険に乗り出す。

私の理解では、python-mode にはいくつかの依存関係があるため、rope、ropemode、ropemacs をインストールする必要があります。その上で、pymacs をインストールする必要があります。

Q:それは正しいですか?

これは私の新しい .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 は実行しませんでした。これらのパッケージを untar/unzip し、これらのファイルを ~/.emacs.d/site-lisp の下に置きます。デフォルトでは、python がコマンド プロンプトで呼び出された場合、それは python 2.4 実行可能ファイルです。

Q: 'pymacs' を正常にロードするにはどうすればよいですか?

4

3 に答える 3

1

私はこれまでpymacsを使用したことがありませんが、あなたを見ると私の目を引くものの1つ.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")

(またはあなたが持っているところならどこでもpymacs.el)emacsがlispファイルを見つけることができるように。pymacsのドキュメントにも記載されています

2.4Pymacsを適切にインストールします...Emacs部分に...

これは通常、現在手作業で行われています。まず、書き込みアクセス権を持つEmacsロードパスに保持されているリストに沿ってディレクトリを選択し、そのディレクトリにファイルpymacs.elをコピーします。

于 2009-07-03T07:28:47.470 に答える
1

パスが欠落している場合、これはスタートアップログで、またはemacsの開始時にバックトレースを取得することで簡単に見つけることができます。疑わしい場合は、Mxload-libraryが最適です。

私も、最新のDebianテストアップデート後にemacs23とemacs24の両方をロードすることを拒否するcompany-ropemacsを取得しています。これは、rope保存フックのためにファイルを保存できないことを意味します。それが機能している人からの連絡をお待ちしています。company-ropemacsと一般的にemacsを使用するpythonは、しばらくの間とげになっています。後でもう少しデバッグしてみて、このスレッドを更新するつもりです。

于 2010-08-07T11:20:37.957 に答える
1

次の 2 つを見逃していたことが判明しました。

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

明らかに、pymac スクリプトをロードする必要があります。

そして、仕事上の理由で、デフォルトのpythonインタープリターとしてpython 2.4を使用しているため、env var PYMACS_PYTHONをpython 2.6に設定しました。

于 2009-07-06T03:38:31.703 に答える