(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))
(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)