emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7fe33b6ba0: Add new command 'enriched-toggle-markup'


From: Lars Ingebrigtsen
Subject: master 7fe33b6ba0: Add new command 'enriched-toggle-markup'
Date: Thu, 19 May 2022 19:17:15 -0400 (EDT)

branch: master
commit 7fe33b6ba0823d4794417ef205ee1f011c09db0b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add new command 'enriched-toggle-markup'
    
    * lisp/textmodes/enriched.el (enriched-toggle-markup): New command
    (bug#33855).
---
 etc/NEWS                   |  8 ++++++++
 lisp/textmodes/enriched.el | 24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index c3bc1f0f58..6185c6ff6a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -816,6 +816,13 @@ so automatically.
 
 * Changes in Specialized Modes and Packages in Emacs 29.1
 
+** Enriched Mode
+
+---
+*** New command 'enriched-toggle-markup'.
+This allows you to see the markup in 'enriched-mode' buffers (e.g.,
+the HELLO file).
+
 ** Shell Script Mode
 
 ---
@@ -2190,6 +2197,7 @@ platforms.
 This command lets you examine all data in the current selection and
 the clipboard, and insert it into the buffer.
 
++++
 ** New user option 'yank-transform-functions'.
 This function allows the user to alter the string to be inserted.
 
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el
index 50ff668a9f..935be06812 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]