lewang / ws-butler

Unobtrusively trim extraneous white-space *ONLY* in lines edited.
242 stars 26 forks source link

ws-butler does not work with Emacs daemon #12

Closed tuhdo closed 9 years ago

tuhdo commented 9 years ago

When ws-butler is activated, it hangs the emacs daemon, prevent it from proceeding further. I used the following config:

(require 'ws-butler)
(add-hook 'prog-mode-hook 'ws-butler-mode)
lewang commented 9 years ago

This is related to #4. What is the fix? I don't use daemon mode.

It would help me see the problem if you can show a repro starting from emacs -Q.

Can you try?

(defun activate-ws-butler ()
  (require 'ws-butler)
  (add-hook 'prog-mode-hook 'ws-butler-mode))
(add-hook 'after-make-frame-functions 'activate-ws-butler)
tuhdo commented 9 years ago

I can start the Emacs daemon but ws-butler won't activate anymore. When I tried to run emacsclient with the above code, I got this error:

Waiting for Emacs... ERROR: Wrong number of arguments: (lambda nil (require (quote ws-butler)) (add-hook (quote prog-mode-hook) (quote ws-butler-mode))), 1

Normal Emacs starts file. My init.el only contains the above code you suggested.

lewang commented 9 years ago

How to repro the problem from emacs -Q?

tuhdo commented 9 years ago

Well, I did start Emacs in clean state using emacs -Q. But then, I have to save your code in init.el to test with emacs-- daemon. Your code is the only thing in init.el.

The way I use Emacs daemon is like this:

Waiting for Emacs... ERROR: Wrong number of arguments: (lambda nil (require (quote ws-butler)) (add-hook (quote prog-mode-hook) (quote ws-butler-mode))), 1

anirothan commented 9 years ago

A hook of 'after-make-frame-functions requires an argument (the frame just rendered). This why the activate-ws-butler function above causes an error when starting emacsclient.

However, even if this syntax error is corrected, the suggested solution will not work in all cases because any prog-mode buffers created before the frame is created, .e.g. you are using desktop-save-mode and it reloads them at startup, will not get ws-butler. Only those prog-mode buffers created after the frame is created will do so. Refer to https://github.com/lewang/ws-butler/issues/14 for more details and a suggested workaround.

lewang commented 9 years ago

Refer to #14 for details. https://github.com/lewang/ws-butler/tree/remove-highlight-changes-mode/ is the fix branch being tested.