Reputation: 529
I've been learning emacs and lisp right, so I'm sure I'm missing something, but I'm trying to get highlight-indentation to work when I start emacs.
I've got the highlight-indentation.el file in my emacs path and after startup, I can do
M-x highlight-indentation
and all works well, but how do I get this to work on startup. I thought putting
(highlight-indentation)
in my .emacs file would work, but it didn't. Is this because highlight-indentation is an interactive function?
Upvotes: 1
Views: 1428
Reputation: 61
highlight-indentation.el actually creates a minor mode that will automatically highlight the indentation at all times, appropriately called highlight-indentation-mode. You can see the relevant functions under the sections that say
;;;###autoload
namely,
define-minor-mode highlight-indentation-mode
and
define-minor-mode highlight-indentation-current-column-mode
To use them, add a hook like Lindydancer suggested, but instead of creating a new hook that calls the highlight-indentation function, simply write:
(add-hook 'emacs-lisp-mode-hook 'highlight-indentation-mode)
I kind of prefer the (rather wordy) highlight-indentation-current-column-mode, which just highlights the column the cursor is on. It's a bit cleaner, but still shows you the relationship between different levels of the code.
Edit: I'm two years late to updating this, but for future Internet wanderers who want to get highlight-indentation-mode working for all programming langagues, you can do this:
(add-hook 'prog-mode-hook 'highlight-indentation-mode)
Upvotes: 3
Reputation: 26094
The function is only applied to the current buffer. I would recommend using a hook like the following. Functions added to major mode hooks are executed when the major mode is enabled for a particular buffer.
(defun my-emacs-lisp-mode-hook ()
(highlight-indentation))
(add-hook 'emacs-lisp-mode-hook 'my-emacs-lisp-mode-hook)
Upvotes: 5
Reputation: 241748
It really depends on what the highlight-indentation
does. Check whether its effects are not visible in the *scratch*
buffer.
Upvotes: 0