         (insert new-quotes)
         (set-marker start (point))
         (replace-string new-quotes (concat "\\" new-quotes) nil start end)
-        (replace-string (concat "\\" old-quotes) old-quotes nil start end)))))
+        (replace-string (concat "\\" old-quotes) old-quotes nil start end)))
+    (error "Point isn't in a string")))
 
 ;; Select text in quotes
 (defun select-text-in-quotes ()

  (while (point-is-in-string-p) (backward-char)))

(defun alternate-quotes-char ()
  (if (= 34 (nth 3 (syntax-ppss))) "'" "\""))

(defun quotes-char ()
  (if (= 34 (nth 3 (syntax-ppss))) "\"" "'"))

(defun toggle-quotes ()
  (interactive)
  (when (point-is-in-string-p)
    (let ((old-quotes (quotes-char))
          (new-quotes (alternate-quotes-char))
          (start (make-marker))
          (end (make-marker)))
      (save-excursion


;; toggle quotes

(defun current-quotes-char ()
  (nth 3 (syntax-ppss)))

(defun point-is-in-string-p ()
  (current-quotes-char))

(defun move-point-forward-out-of-string ()
  (while (point-is-in-string-p) (forward-char)))
