You can set hl-line-sticky-flag to nil
hl-line-sticky-flag is a variable defined in hl-line.el.
Non-nil means the HL-Line mode highlight appears in all windows.
Otherwise Hl-Line mode will highlight only in the selected
window. Setting this variable takes effect the next time you use
the command hl-line-mode to turn Hl-Line mode on.
@Chakravarthy Raghunandan answered your question completely and succinctly.
But you owe it to yourself to learn to ask Emacs -- that will help you much more, both immediately and in the long run. One of the goals of this particular Stack-Exchange site is to help not only by answering specific questions, but by helping you learn to help yourself.
This kind ...
global-hl-line-mode sets variable global-hl-line-mode to t. The global mode is separate from the non-global (hl-line-mode).
The following will disable it in the selected mode:
(add-hook 'eshell-mode-hook (lambda ()
highlight-symbol-mode uses text properties, not an overlay.
hl-line-mode uses an overlay, not text properties.
Overlays always take precedence over text properties, no matter how low the overlay priority is.
So without some coding or code tweaking, I don't see a solution.
However, if you use the Highlight library (highlight.el) then the solution is ...
The problem is that sometimes text property face is used for highlighting, and hl-line-mode uses an overlay. And overlays always appear "on top of" text property face highlighting.
diff-mode, for example, uses the text property, not an overlay. So for cases like this you are out of luck.
But for highlighting that is produced by an overlay you can just ...
I end with partial solution - highlight only from the end of line:
(defun my-hl-line-range-function ()
(cons (line-end-position) (line-beginning-position 2)))
(setq hl-line-range-function #'my-hl-line-range-function)
(set-face-attribute 'hl-line nil :inherit nil :background "light yellow")
This is the case by default for me: hl-line-mode by default uses a face which only specifies a background color. That face is hl-line which by default just inherits from highlight. So maybe the problem is simply your that highlight face specifies both a background and a foreground color. I recommend you M-x customize-face and either change your highlight ...
Likely many ways to do this but the built in package called hl-line works very nicely. M-x hl-line-mode works as a local minor mode. or M-x global-hl-line-mode works as a global mode. goto https://github.com/emacs-mirror/emacs/blob/master/lisp/hl-line.el to see more in the comments section.
Org mode does provide the org-at-table-p function that can be used to determine if the cursor is inside an org table.
You would need to check this every time the cursor moves, which could be done using the post-command-hook.
(defun highlight-current-table-line ()
It was on MELPA. It's not on MELPA anymore because MELPA doesn't want to pull from Emacs Wiki anymore. It's on Emacs Wiki because that's where I prefer to upload it. And it is a "package" - a single library.
If you want to use it, just (1) download it from the wiki, (2) put it in a directory that's in your load-path, and (3) do (require 'hl-line+).
Stumbled on this question when attempting not to make the hl-line override the background (although it was indentation guides in this case):
I settled on this, which starts drawing the highlight line after the indentation:
(defun my-hl-line-range-function ()
(+ (line-beginning-position 1) (current-indentation))
I believe what you need to do is check the inheritance of the various faces. This can be done with describe-face. The available options are given in the manual under Face Attributes, but I believe the one you want is unspecified.
Here is what I use in my init.el for highlighting and how I solved the problem of the highlight clobbering other faces:
You are right that describe-face ultimately calls get-char-property
(via face-at-point). get-char-property, unlike its cousin
get-text-property, doesn't return just text properties, but also overlay
properties. And that's how hl-line-mode works: By setting the face
property on an overlay.
A cursory glance at Emacs' git repository at savannah.gnu.org, doesn'...
This works for me, with this in my .emacs. See how the syntax colours are nicely preserved? (thx Yadoo86)
;; highlight line with the cursor, preserving the colours.
(set-face-attribute 'hl-line nil :inherit nil :background "gray80")
This is the solution I came up with using hl-line. I needed to advise the function that updates the disassembly buffer and invoke hl-line-highlight directly to make it work.
(after nispio/ad-after-disas-handler-hl-line activate)
"Make sure that `hl-line' gets updated after updating disassembly buffer"
Thanks to @lawlist nudging me into the source code, I found out that gdb mode will highlight the line for me, but only on the condition that the window containing the disassembly does not have fringes. The following was enough to make that happen:
;; Enable automatic highlighting of the active line in disassembly window
(defun nispio/disable-window-fringes (...
The problem is coming from:
(add-hook 'pre-command-hook #'my-hl-line-after-unhighlight nil t)
(add-hook 'post-command-hook #'my-hl-line-after-current-line nil t)
The nil t at the end means that you only add those to the local part of the hook, i.e. it will only apply to commands executed in "the current buffer" where "current" means "current when the add-...
After some answers I got it.
The answers in other threads didn't work right away in Spacemacs (I'm really new to Emacs world so I don't know why), but mixing parts of them I managed to do it.
It's still not perfect. I would prefer to get the color from Emacs theme instead of using the color that hl-line figures out it should use, but I don't understand how ...