Created
June 14, 2016 10:15
-
-
Save tzach/c7e46ca9476751eefa5a2797e926cc67 to your computer and use it in GitHub Desktop.
replace an issue number with a markdown link to github issue
This file contains hidden or 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
| (setq github-project-prefix "https://github.com/scylladb/scylla/issues/") | |
| (defun create-github-issue (string &optional from to) | |
| "replace a #xxx with [#xxx](https://github.com/scylladb/scylla/issues/xxx)" | |
| (interactive | |
| (if (use-region-p) | |
| (list nil (region-beginning) (region-end)) | |
| (let ((bds (bounds-of-thing-at-point 'paragraph)) ) | |
| (list nil (car bds) (cdr bds)) ) ) ) | |
| (let (workOnStringP inputStr outputStr) | |
| (setq workOnStringP (if string t nil)) | |
| (setq inputStr (if workOnStringP string (buffer-substring-no-properties from to))) | |
| (setq outputStr | |
| (let ((case-fold-search t)) | |
| (replace-regexp-in-string "#\\([0-9]+\\)" (concat "[#\\1](" github-project-prefix "\\1)") inputStr))) | |
| (if workOnStringP | |
| outputStr | |
| (save-excursion | |
| (delete-region from to) | |
| (goto-char from) | |
| (insert outputStr))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment