11

just add this to your .emacs or init.el file : (global-hl-line-mode 1).


9

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. This ...


9

@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 ...


7

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 () (setq-local global-hl-line-mode nil))) (add-hook 'term-...


7

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 ...


5

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 ...


5

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 ...


5

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.


3

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 () (interactive) (if (org-at-table-p) (hl-line-mode 1) (hl-line-mode -1))) (defun ...


3

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+). There's ...


3

Just for reference, try (set-face-attribute 'hl-line nil :inherit nil :background "gray6")


3

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) (when window-system (require 'hl-line) (set-face-attribute 'hl-line nil :inherit nil :background "light yellow") (setq global-hl-line-...


2

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 () (cons (+ (line-beginning-position 1) (current-indentation)) (line-beginning-position 2))) (...


2

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: (...


2

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'...


1

That's what hooks are for: (add-hook 'dired-mode-hook 'hl-line-mode)


1

There was an unrelated problem where a symbolic link was not set so the changes I made to the init file were not being loaded. Now it works.


1

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") (global-hl-line-mode 1)


1

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. (defadvice gdb-disassembly-handler-custom (after nispio/ad-after-disas-handler-hl-line activate) "Make sure that `hl-line' gets updated after updating disassembly buffer" (let* ...


1

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 (...


1

How 'bout (defun my-hl-line-range-function () (cons ;; (point) ;; works nice too, cursor instead of indentation (save-excursion (back-to-indentation) (point)) (line-beginning-position 2)))


1

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-...


1

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 ...


1

This works for ansi-term if you're using emacs 24.3+: (add-hook 'term-mode-hook (lambda () (setq-local global-hl-line-mode nil))) Thanks to Jonathan and glucas.


Only top voted, non community-wiki answers of a minimum length are eligible