I user dired to browse file, and I would like to use hl-line-mode which highlights the currents line, but I only want it to be enabled automatically when using dired


That's what hooks are for:

(add-hook 'dired-mode-hook 'hl-line-mode)
  • It worked. Thanks. I'll search more about hooks. – user168651 Apr 14 '19 at 8:06

(add-hook 'dired-mode-hook 'global-hl-line-mode)

  • Welcome to Emacs SE! Unfortunately, this will turn on hl-mode globally as soon as the user enters a dired buffer for the first time. – Dan Apr 14 '19 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.