dired no hiline

Table of Contents

img

I was trying to make sure that hl-line mode (to highlight a line) is not on in my dired buffers without changing its presence anywhere else, since it messes up display of my diredfl permission faces. Unfortunately, the following didn’t work, probably because “setting” isn’t the same thing as calling the variable. What was the best way to selectively disable hl-line-mode? There were many good answers on Reddit1.

    (add-hook 'dired-mode-hook (lambda ()
                                 (setq-local global-hl-line-mode nil
                                             hl-line-mode nil)
                                 ;; I wasn't sure on the relationship between
                                 ;; these two, or even which one was being used
))

Learning along the way: global- is unrelated to hl-line-mode

It turns out that global-hl-line does not share anything in common with hl-line-mode other than the end result, so altering one does not alter the other.

Answer selected: hl-line+

Though various answers were offered, the simplest one was to use hl-line+2 from Drew Adams, which provides an easy option to remove lines from an otherwise global highlight mode.

(use-package hl-line+
  :custom
  (global-hl-line-mode t)
  (hl-line-flash-show-period 1.0)
  (hl-line-inhibit-highlighting-for-modes '(dired-mode))
  (hl-line-overlay-priority -100) ;; sadly, seems not observed by diredfl
)

Addendum: Diredfl

I like to have a color scheme that allows my eye to follow the permissions down a directory listing and easily recognize differences, and diredfl3 is excellent for this. Here is the line with my configuration of diredfl, as demonstrated in the screenshot above:

(use-package diredfl
  :demand t
  :config
  (add-hook 'dired-mode-hook 'diredfl-mode)
  :custom-face
  (diredfl-dir-name ((t (:foreground "#3679D8" :box (:line-width 2 :color "grey75" :style released-button)))))
  (diredfl-dir-priv ((t (:foreground "#3679D8" :underline t))))
  (diredfl-exec-priv ((t (:background "#79D836" :foreground "black"))))
  (diredfl-read-priv ((t (:background "#D8B941" :foreground "black"))))
  (diredfl-write-priv ((t (:background "#D83441" :foreground "black")))))

Footnotes

1 Answers explaining what’s going on, cleaner (non-)use of lambdas in hooks, and the solution I chose: https://www.reddit.com/r/emacs/comments/nqp1ww/how_to_turn_off_hlline_only_in_dired_mode/

2 The probably cannonical version of hl-line is here: https://www.emacswiki.org/emacs/download/hl-line%2b.el . However, with straight-use-package it is automatically drawn from this github url: https://github.com/emacsmirror/hl-line-plus.git

3 Diredfl (that’s fl for “Font Lock”) is here: https://github.com/purcell/diredfl

Tory Anderson avatar
Tory Anderson
Full-time Web App Engineer, Digital Humanist, Researcher, Computer Psychologist