2012-04-15 181 views
37

我已經安裝了Pymacs,rope,ropemode,ropemacs,並且當我意外執行pymacs-terminate-services時,我無法保存修改後的緩衝區。它首先問我 - The Pymacs helper died. Restart it? (yes or no)。如果我回答「是」,它會投擲 - Debugger entered--Lisp error: (error "There is no Pymacs helper!")。如果我回答「不」,把它扔到:管理幫手死亡

Debugger entered--Lisp error: (error "Python: Traceback (most recent call last): 
    File \"/usr/local/lib/python2.7/dist-packages/Pymacs.py\", line 258, in loop 
    value = eval(text) 
    File \"<string>\", line 1, in <module> 
IndexError: list index out of range 
") 

我設法通過執行pymacs-load,裝載os模塊,並回答是肯定的Pymacs幫手重啓的問題來解決。緩衝區被撲出,但隨後我開始另一個錯誤,每次我保存的文件:

Debugger entered--Lisp error: (error "Python: Traceback (most recent call last): 
    File \"/usr/local/lib/python2.7/dist-packages/Pymacs.py\", line 258, in loop 
    value = eval(text) 
    File \"<string>\", line 1, in <module> 
TypeError: major() takes exactly 1 argument (0 given) 
") 

這是我的init文件:

(load "~/.emacs.d/pymacs.el") 
(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) 
(autoload 'pymacs-autoload "pymacs") 
(require 'pymacs) 
(pymacs-load "ropemacs" "rope-") 

Pymacs manual介紹Pymacs幫手死亡。它告訴我不應該關閉*Pymacs*緩衝區,因爲這會殺死幫助程序,並且如果幫助程序被終止,還應該重新啓動Emacs。這是不可接受的,因爲我有習慣隨時關閉所有緩衝區,並且很少重新啓動Emacs。我現在有幾個相關的問題:

  • 什麼是最好的方式來處理Pymacs最小化這種問題?僅當我使用Python並且然後再次安全地終止它時,是否可以運行Pymacs?
  • 什麼是pymacs-terminate-services,我應該運行它嗎?
  • 如果我意外運行pymacs-terminate-services,該怎麼辦?我特別感興趣的是如何編輯before-save-hook以使緩衝區保存成爲可能而沒有錯誤消息。
+1

沒有嘗試過,但是[Pymacs/contrib/Giorgi/dir中的這一點](https:// github。com/pinard/Pymacs/blob/b4e462f52566ad51c18f5d65e1db32af1e24bc13/contrib/Giorgi/dotEmacs.py)似乎是相關的,也許..? – dbr 2012-10-24 04:26:20

+1

一個非常詳細的,語法正確的問題,還沒有收到確鑿的答案...絕對值得一個賞金。 – 2012-11-25 20:05:02

回答

2

我能想到的最簡單的解決方法是使用kill-buffer-query-functions鉤來防止*Pymacs*被殺害。就像這樣:

(defun my-pymacs-saver() 
    (if (equal (buffer-name) "*Pymacs*") 
     (yes-or-no-p "Really kill *Pymacs* buffer? ") 
    t)) 

(add-hook 'kill-buffer-query-functions 'my-pymacs-saver) 

它會問你,如果你真的想殺死*Pymacs*緩衝與否。你甚至可以把它不可能從keybinds這個殺:

(defun my-pymacs-saver() 
    (if (equal (buffer-name) "*Pymacs*") 
     (progn 
     (message "NEVER kill *Pymacs*!") 
     nil) 
    t)) 

我用pymacs-terminate-services強行加載所有模塊。我有一個類似於http://www.emacswiki.org/emacs/AntonNazarov中的pymacs-reload-rope的函數。

也許您可以將pymacs-terminate-services添加到kill-buffer-hook(本地位於*Pymacs*緩衝區中)以獲得更優雅的終止。但我不確定。對於您的其餘問題,我想最好是在Pymacs issue tracker中詢問/請求。

0

如果不小心殺死了* Pymacs *緩衝區或執行pymacs-terminate-services,則可以通過執行以下命令並在提示符下回答「是」來恢復進程。

(pymacs-load "ropemacs" "rope-") 

您可以修改您的init文件功能,允許重啓與M-x python-restart交互調用。以這種方式重新啓動Pymacs將避免TypeError: major()...錯誤。

(defun pymacs-restart() 
    (interactive) 
    (pymacs-load "ropemacs" "rope-")) 

(load "~/.emacs.d/pymacs.el") 
(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) 
(autoload 'pymacs-autoload "pymacs") 
(require 'pymacs) 
(pymacs-restart)