(defvar jsmrs-fixup-function-end nil) (make-variable-buffer-local 'jsmrs-fixup-function-end) (defun jsmrs-fixup-recorder-next-action () (interactive) (forward-line 0) (unless (looking-at "^TraceRecorder::") (error "not at function name in recording function definition")) (unless (looking-back "\\(bool\\s-*\\)\n") (error "recording function not declared as bool")) (save-excursion (replace-match "JSMonitorRecordingStatus" t t nil 1)) (save-excursion (c-end-of-defun) (setq jsmrs-fixup-function-end (point-marker))) (save-excursion (while (re-search-forward "return true;" jsmrs-fixup-function-end t) (replace-match "return JSMRS_CONTINUE;"))) (save-excursion (while (re-search-forward "return false;" jsmrs-fixup-function-end t) (replace-match "return JSMRS_STOP;")))) (defun jsmrs-check-status () (interactive) (save-excursion (skip-syntax-forward "-") (unless (looking-at "if (!\\(.*\\))\n\\s-*return JSMRS_STOP;") (ding)) (replace-match "CHECK_STATUS(\\1);"))) (global-set-key "\C-cn" 'jsmrs-fixup-recorder-next-action) (global-set-key "\C-cs" 'jsmrs-check-status)