skeeto / skewer-mode

Live web development in Emacs
The Unlicense
1.1k stars 57 forks source link

How to run `skewer-css-eval-buffer` after save file #10

Closed L42y closed 11 years ago

L42y commented 11 years ago

Seems my solution doesn't work:

(add-hook 'skewer-css-mode
          (lambda ()
            (add-hook 'after-save-hook 'skewer-css-eval-buffer nil t)))
skeeto commented 11 years ago

Make sure you use the mode's hook, not the mode toggle command. This one works for me, just adding "-hook":

(add-hook 'skewer-css-mode-hook
          (lambda ()
            (add-hook 'after-save-hook 'skewer-css-eval-buffer nil t)))

I didn't realize it until you had me investigate: define-minor-mode will not actually declare the hook as a variable. It only interns the symbol. add-hook creates the variable binding automatically if not already bound. So you won't see skewer-css-mode-hook as a variable until you've added a hook function. Maybe that's why you didn't see it.

Thanks for opening this issue! I'll wait to close this until you confirm that this works for you.

L42y commented 11 years ago

Thank you so much, it works.