Created
February 4, 2016 19:15
-
-
Save wasamasa/9e3afb228d8694383e22 to your computer and use it in GitHub Desktop.
Helping out viccuad on #emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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