diff options
Diffstat (limited to 'lisp/textmodes/enriched.el')
-rw-r--r-- | lisp/textmodes/enriched.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el index 50ff668a9ff..935be06812f 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el @@ -539,6 +539,30 @@ the range of text to assign text property SYMBOL with value VALUE." (list start end 'display prop) (list start end 'display (list 'disable-eval prop))))) +(defvar enriched--markup-shown) +(defun enriched-toggle-markup () + "Toggle whether to see markup in the current buffer." + (interactive) + (save-excursion + (save-restriction + (widen) + (with-silent-modifications + (if (bound-and-true-p enriched--markup-shown) + (progn + (setq-local enriched--markup-shown nil) + ;; Remove any faces, because they will be decoded, too. + (goto-char (point-min)) + (let (match) + (while (setq match (text-property-search-forward 'face)) + (put-text-property (prop-match-beginning match) + (prop-match-end match) + 'face nil))) + (enriched-decode (point-min) (point-max)) + (enriched-mode 1)) + (setq-local enriched--markup-shown t) + (enriched-encode (point-min) (point-max) (current-buffer)) + (enriched-mode -1)))))) + (provide 'enriched) ;;; enriched.el ends here |