Last active
December 16, 2015 21:21
-
-
Save lionicsheriff/5499373 to your computer and use it in GitHub Desktop.
Log the path a program through branches. Currently perl only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun warn-unique () | |
"Inserts a warn statement with an incrementing buffer local id" | |
(interactive nil) | |
(if (not (boundp 'warn-unique-count)) | |
(set (make-local-variable 'warn-unique-count) 0) | |
(set 'warn-unique-count (+ 1 warn-unique-count))) | |
(end-of-line) | |
(newline-and-indent) | |
(insert (concat "warn '**** " (number-to-string warn-unique-count) "';"))) | |
(defun warn-line () | |
"Inserts a warn statement with the current line number" | |
(interactive nil) | |
(end-of-line) | |
(newline-and-indent) | |
(insert (concat "warn '**** " (what-line) "';"))) | |
(defun flag-branches () | |
"Flag each branch in a condition with a unique id and log it when that branch is hit" | |
(interactive nil) | |
(save-excursion | |
(beginning-of-buffer) | |
(while (re-search-forward "\\(?:if\\|else\\|elsif\\)") ;; branching keywords | |
(when (text-property-any (match-beginning 0) (match-end 0) 'face 'font-lock-keyword-face) | |
(save-match-data | |
(re-search-forward "{$" nil t) | |
(goto-char (match-end 0)) | |
(message (match-string 0)) | |
(warn-line)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment