summaryrefslogtreecommitdiff
path: root/.config/emacs/site-lisp/gh.el
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-12-11 19:50:33 +0100
committerThomas Voss <mail@thomasvoss.com> 2025-12-11 19:50:33 +0100
commite89cab0aae8bc79270a79fe23edad09e43ba823b (patch)
treecc13943e1d843fa8d92a0a936a9493036849c1a7 /.config/emacs/site-lisp/gh.el
parentb978f0d12c54e2754bea6463f072513838474bc7 (diff)
parentdad93f009a27699ffc58c7949cd826d3c1487136 (diff)
Merge branch 'master' of github.com:Mango0x45/dotfiles
Diffstat (limited to '.config/emacs/site-lisp/gh.el')
-rw-r--r--.config/emacs/site-lisp/gh.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/.config/emacs/site-lisp/gh.el b/.config/emacs/site-lisp/gh.el
index 0461b18..23086e5 100644
--- a/.config/emacs/site-lisp/gh.el
+++ b/.config/emacs/site-lisp/gh.el
@@ -36,4 +36,24 @@ via `gh-get-labels'."
(apply #'call-process "gh" nil t nil "pr" "create" flags)
(message (buffer-string)))))
-(provide 'gh) \ No newline at end of file
+(defvar gh-pr-regexp
+ "\\`https://\\(?:www\\.\\)?github\\.com/[^/]+/[^/]+/pull/[[:digit:]]+\\'")
+
+(defun gh--pr-link-p (s)
+ (declare (pure t) (side-effect-free t))
+ (string-match-p gh-pr-regexp s))
+
+(defun gh-open-previous-pr ()
+ "Open the previous GitHub pull request.
+Opens the previous pull request created by `gh-create-pr' by searching
+for the echoed URL in the `*Messages*' buffer."
+ (interactive)
+ (with-current-buffer "*Messages*"
+ (goto-char (point-max))
+ (while (not (gh--pr-link-p (buffer-substring-no-properties
+ (pos-bol) (pos-eol))))
+ (unless (line-move -1 :noerror)
+ (user-error "No previous pull request found.")))
+ (browse-url-at-point)))
+
+(provide 'gh)