Skip to content

Instantly share code, notes, and snippets.

@wasamasa
Created February 4, 2016 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasamasa/9e3afb228d8694383e22 to your computer and use it in GitHub Desktop.
Save wasamasa/9e3afb228d8694383e22 to your computer and use it in GitHub Desktop.
Helping out viccuad on #emacs
(defface hl-tab-line
'((((type graphic)) :strike-through t)
(((type tty)) :underline t))
"Tab line")
(defun hl-tab-fontify (beg end)
(let ((bol (save-excursion (goto-char beg) (line-beginning-position)))
(eol (save-excursion (goto-char end) (line-end-position))))
(save-excursion
(goto-char bol)
(while (search-forward-regexp "^\t+" eol t)
(with-silent-modifications
(add-text-properties (line-beginning-position) (point)
'(font-lock-face hl-tab-line)
(current-buffer)))))))
(defun hl-tab-unfontify ()
(save-excursion
(goto-char (point-min))
(while (search-forward-regexp "^\t+" (point-max) t)
(with-silent-modifications
(remove-text-properties (line-beginning-position) (point)
'(font-lock-face hl-tab-line)
(current-buffer))))))
(define-minor-mode hl-tab-mode
"Highlight tabs with a line."
:lighter "\\t"
(if hl-tab-mode
(jit-lock-register 'hl-tab-fontify)
(jit-lock-unregister 'hl-tab-fontify)
(hl-tab-unfontify)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment