Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing helper death

I had installed Pymacs, rope, ropemode, ropemacs, and when I executed pymacs-terminate-servicesby accident, I couldn't save modified buffers. It first asked me - The Pymacs helper died. Restart it? (yes or no). If I answered "yes", it threw - Debugger entered--Lisp error: (error "There is no Pymacs helper!"). If I answered "no", it threw:

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

I managed to work around by executing pymacs-load, loading os module, and answering yes to Pymacs helper restart question. The buffer was saved, but then I started to get another error everytime I saved the file:

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

This is my init-file:

(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 describes death of Pymacs helper. It tells that I shouldn't close *Pymacs* buffer, because this kills the helper, and should also restart Emacs if helper is killed. This is unacceptable as I have a habit of closing all buffers from time to time and also rarely restart Emacs. I have several related questions now:

  • What is the best way to handle Pymacs to minimize such problems? Is it possible to run Pymacs only when i work with Python and then safely terminate it again?
  • What is pymacs-terminate-services for and should I ever run it?
  • What should I do if I ever accidentally run pymacs-terminate-services? I'm especially interested in how to edit before-save-hook to make buffer saves possible without error messages.
like image 285
Mirzhan Irkegulov Avatar asked Apr 15 '12 11:04

Mirzhan Irkegulov


People also ask

How do you help someone deal with death?

If you can't think of something to say, just offer eye contact, a squeeze of the hand, or a reassuring hug. Offer your support. Ask what you can do for the grieving person. Offer to help with a specific task, such as helping with funeral arrangements, or just be there to hang out with or as a shoulder to cry on.

What are the seven stages of dealing with death?

“Death is not the greatest loss in life. The greatest loss is what dies inside us while we live.” However, there are actually seven stages that comprise the grieving process: shock and disbelief, denial, pain, anger, bargaining, depression, and acceptance/hope.


1 Answers

The easiest solution I can think of is to use kill-buffer-query-functions hook to prevent *Pymacs* to be killed. Like this:

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

It will ask you if you really want to kill *Pymacs* buffer or not. You can even make it impossible to kill from keybinds by this:

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

I use pymacs-terminate-services to forcefully reload all modules. I have a function similar to pymacs-reload-rope in http://www.emacswiki.org/emacs/AntonNazarov.

Probably you can add pymacs-terminate-services to kill-buffer-hook (locally in *Pymacs* buffer) for more graceful termination. But I am not sure. For the rest of your question, I guess it's better to ask/request in the Pymacs issue tracker.

like image 88
tkf Avatar answered Nov 08 '22 22:11

tkf