Disable hl-line in Emacs when using Emacs Starter Kit?
This problem is killing my productivity.
The Emacs Starter Kit automatically enables hl-line, which highlights the current line. It makes me unable to see the highlighting on the current line.
I've tried setting (global-hl-line-mode nil)
and (hl-line-mode nil)
globally and added to the mode hooks su开发者_如何学JAVAch as clojure-mode-hook, but it still shows up.
What elisp do I need to disable this feature?
In starter kit 2 the corresponding hook to remove is:
(remove-hook 'prog-mode-hook 'esk-turn-on-hl-line-mode)
You'll need to add that to your own configuration after starter kit has initialised.
hl-line-mode is turned on by the following line in starter-kit-defuns.el:
(add-hook 'coding-hook 'turn-on-hl-line-mode)
You can either comment out that line, or if you'd rather not touch the starter kit files, you can put the following in your personal init file at ~/.emacs.d/{username}.el:
(remove-hook 'coding-hook 'turn-on-hl-line-mode)
I know this is an old question, but I recently had the same issue (using emacs 24) and found that it also can be solved simply by customizing the "hl-line" face:
- Do "M-x customize-face" and enter "hl-line".
- Customize to your liking and "save for future sessions".
If you turn off all attributes, you effectively disable the feature, at least from the user's point of view. For me, turning of the color highlighting and just setting "Weight" to "heavy" transformed hl-line from an annoyance to an unobtrusive, moderately useful feature.
Try to place (global-hl-line-mode nil)
at the bottom of your .emacs
so no other command overwrites it.
I don't think your problem came from ESK - it doesn't enable hl-line-mode. You'd have to have a line looking like (global-hl-line-mode t)
somewhere if that were true. I'd suggest to simply search for that line in your config and and remove it if you find it. There are other highlighting modes as well. ESK automatically installs idle-highlight from ELPA - maybe this is what you mean. You can remove it by deleting it's entry from this piece of code in starter-kit-elpa.el:
(defvar starter-kit-packages (list 'idle-highlight
'ruby-mode
'inf-ruby
'css-mode
'yaml-mode
'find-file-in-project
'magit
'gist)
You should also remove the downloaded package from ELPA's folder and restart Emacs.
If you use ESK then the best place to put your own customizations is not .emacs but .emacs.d/{username}.el or .emacs.d/{username}/{username}.el.
You asked how to disable hl-line-mode, but you said you want to do this because hl-line-mode obscures the normal syntax highlighting that you prefer to see instead. Well, what if I told you that it was possible to have both the highlighted line, and the syntax highlighting? Try this:
;; Change the :background setting to a value that is only very subtly
;; lighter than the default bg color.
(set-face-attribute 'hl-line nil
:background "#3d4753"
:foreground nil
:inherit t)
The end result is a highlighted line that has a very beautifully subtle highlight effect in the background and keeps all your valuable syntax highlighting present in the foreground. If you choose the background color carefully, you won't have any problems with readability clashes from fg/bg colors (I mean, if you choose a highly contrasty highlighted line color, then the syntax highlighting colors will clash and be hard to read, so by choosing a color that is only very subtly different, you can still see it without having to worry about fg colors that clash).
精彩评论