
(defun name-checkpoints ()
  (interactive)
  (let ((name  (cfm--get-defun))
        (count 0))
    (goto-char (point-min))
    ;;(debug "fence")
    (while (re-search-forward "(checkpoint [^()]*)" nil t)
      (incf count)
      (setq chk (buffer-substring-no-properties (match-beginning 0) (match-end 0)))

      (cond
       ((string-match "\\((checkpoint\\) \"\\([^()\"]\\)\")" chk)

        (setq s1 (substring chk (match-beginning 1) (match-end 1)))
        (setq s2 (concat name ":" (format "%s" count)))
        (setq s3 (concat s1 " \"" s2 "\")"))
        )
       ((string-match "\\((checkpoint\\) \\([^()\"]\\))" chk)

        (setq s1 (substring chk (match-beginning 1) (match-end 1)))
        (setq s2 (concat name ":" (format "%s" count)))
        (setq s3 (concat s1 " \"" s2 "\")"))
        )
       (t
        (error "Smeg")))
      (checkpoint ":0")
      (delete-region (point-at-bol) (point-at-eol))
      (checkpoint ":0")
      (insert s3))
    (indent-region (point-min) (point-max) nil)
    (checkpoint ":0")
    ))

;;; name-checkpoints.el ends here
