]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
doc: Improve Emacs macros for editing command help texts
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 16 Jul 2015 16:44:38 +0000 (18:44 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 16 Jul 2015 17:15:27 +0000 (19:15 +0200)
rpp-test-sw/commands/doc/help-format.el

index 1ce4f5b8f47cd6ebf6e3fc7acfbba88be38554a0..e2f046f2968c039af3816c2a459061651698a539 100644 (file)
       (while (re-search-forward "^\\(.*\\)$" nil t)
        (replace-match "\"\\1\\\\n\"" t)))))
 
+(defun wsh/escape-quotes (beg end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (while (re-search-forward "\"" nil t)
+       (replace-match "\\\\\"" t)))))
+
+(defun wsh/unescape-quotes (beg end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (while (re-search-forward "\\\\\"" nil t)
+       (replace-match "\"" t)))))
+
 (defun wsh/edit-multiline-string (beg end)
   (interactive "r")
   (let ((text (buffer-substring beg end))
@@ -66,7 +84,8 @@
     (insert text)
     (goto-char pos)
     (wsh/strip-quotes-and-newline (point-min) (point-max))
-    (text-mode)
+    (wsh/unescape-quotes (point-min) (point-max))
+    (markdown-mode)
     (save-excursion
       (goto-char (point-max))
       (skip-chars-backward "\n")
     (goto-char (point-max))
     (skip-chars-backward " \t\n\r\f\v")
     (delete-region (point) (point-max))
+    (wsh/escape-quotes (point-min) (point-max))
     (wsh/add-quotes-and-newline (point-min) (point-max))
     (let ((text (buffer-string)))
       (switch-to-buffer wsh/c-buffer)