Skip to content

Instantly share code, notes, and snippets.

@Chouser
Last active October 11, 2015 11:08
Show Gist options
  • Save Chouser/3849645 to your computer and use it in GitHub Desktop.
Save Chouser/3849645 to your computer and use it in GitHub Desktop.
(defun toggle-tags-invisible ()
(interactive)
(save-excursion
(goto-char (point-min))
(when (not (remove-text-properties (point-min) (point-max) '(invisible t)))
(let ((spew (make-progress-reporter "Hiding all tags..." (point-min) (point-max))))
(while (re-search-forward "</.*?>" nil t)
(add-text-properties (match-beginning 0) (- (match-end 0) 1) '(invisible t) nil)
(progress-reporter-update spew (point)))
(goto-char (point-min))
(while (re-search-forward "<[a-z].*?>" nil t)
(add-text-properties (+ 1 (match-beginning 0)) (match-end 0) '(invisible t) nil)
(progress-reporter-update spew (point)))
(progress-reporter-done spew)))))
(add-hook 'nxml-mode-hook
(lambda ()
(visual-line-mode)))
(font-lock-add-keywords
'nxml-mode `(("<[a-z].*?>"
(0 (progn (compose-region (match-beginning 0)
(match-end 0) "\u27e6")
nil)))
("</.*?>"
(0 (progn (compose-region (match-beginning 0)
(match-end 0) "\u27e7")
nil)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment