(defun auto-quote (m p) (interactive "r") (save-excursion (let ((count 0)) (goto-char m) (while (and (search-forward "\"" nil t) (< (point) (+ count p))) (replace-match "\\\"" nil t) (setq count (+ count 1))) (goto-char m) (insert "\"") (goto-char (+ count p 1)) (insert "\""))))