Malabarba / aggressive-indent-mode

Emacs minor mode that keeps your code always indented. More reliable than electric-indent-mode.
853 stars 35 forks source link

The package does note work well with user added `before-save-hook` #90

Closed mrkkrp closed 8 years ago

mrkkrp commented 8 years ago

Say I have two hooks like so:

(add-hook 'before-save-hook #'whitespace-cleanup)
(add-hook 'before-save-hook #'mk-single-empty-line)

But when I edit a file where aggressive-indent-mode is enabled my customization has no effect. In fact, before-save-hook has this value:

aggressive-indent-mode ⇒

(aggressive-indent--proccess-changed-list-and-indent t)

Is there some why to allow my clean up functions run when agressive-indent-mode is enabled?

Malabarba commented 8 years ago

That's the buffer-local value of the variable. Your functions were added to the global value and should still be there. Just do C-h v to describe the hook and you'll see what I mean. When a hook is run, both the local and global values are run.

mrkkrp commented 8 years ago

It doesn't seem to be the case. The global value is ignored, so only local value is run.

Malabarba commented 8 years ago

How did you confirm that? Try running the following:

(add-hook 'before-save-hook (lambda (&rest _) (message "I was called!")))

Do you see a message when you save the file.

mrkkrp commented 8 years ago

OK, seems it originates from somewhere else. Closing, sorry for the noise.

Malabarba commented 8 years ago

No problem