0

To avoid conflicts with highlighting indentation, I made the highlight line begin after the current indentation.

This works well, except when tabs are used as leading white space.

How could the my-hl-line-range-function calculate offsets taking tabs into account?

(global-hl-line-mode 1)

;; don't draw over indentation (annoying/distracting with indent guides)
(defun my-hl-line-range-function ()
  (cons
   ;; (point)  ;; works nice too, cursor instead of indentation
   (+ (line-beginning-position 1) (current-indentation))
   (line-beginning-position 2)))
(setq hl-line-range-function #'my-hl-line-range-function)
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)))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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