From 48c0bcb851f67589ed922c87b8caa74252afc779 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 11 Dec 2025 14:09:03 +0100 Subject: emacs: Remove dead code --- .config/emacs/modules/mm-projects.el | 41 +----------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) (limited to '.config/emacs/modules/mm-projects.el') diff --git a/.config/emacs/modules/mm-projects.el b/.config/emacs/modules/mm-projects.el index 25c1a18..720cea3 100644 --- a/.config/emacs/modules/mm-projects.el +++ b/.config/emacs/modules/mm-projects.el @@ -110,43 +110,4 @@ This is intended to be called interactively via (require 'gh) (keymap-global-set "C-c p" #'gh-create-pr) -;; (defun mm-gh--get-labels () -;; (with-temp-buffer -;; (call-process "gh" nil t nil "label" "list" "--json" "name") -;; (goto-char (point-min)) -;; (let* ((data (json-parse-buffer)) -;; (labels (seq-map (lambda (x) (gethash "name" x)) data))) -;; (sort labels -;; :in-place t -;; :lessp (lambda (x y) -;; (let ((prefix-x-p (string-prefix-p "Sprint " x)) -;; (prefix-y-p (string-prefix-p "Sprint " y))) -;; (cond -;; ((and prefix-x-p prefix-y-p) (string> x y)) -;; (prefix-x-p t) -;; (prefix-y-p nil) -;; (:else (string< x y))))))))) - -;; (defun mm-gh-create-pr (title draftp labels) -;; "Create a GitHub pull request using the gh CLI. -;; If DRAFT is non-nil, the PR will be created as a draft. -;; LABELS should be a comma-separated string of GitHub labels." -;; (interactive -;; (list -;; (read-string (format-prompt "PR Title" nil)) -;; (y-or-n-p "Create as draft PR? ") -;; (completing-read-multiple (format-prompt "PR Labels" nil) -;; (mm-gh--get-labels)))) -;; (let* ((branch (car (vc-git-branches))) -;; (title (format "%s %s" branch title)) -;; (flags `("--fill-verbose" "--title" ,title "--assignee" "@me")) -;; (label-string (mapconcat #'identity labels ","))) -;; (when draftp -;; (setq flags (append flags '("--draft")))) -;; (when labels -;; (setq flags (append flags `("--label" ,label-string)))) -;; (with-temp-buffer -;; (apply #'call-process "gh" nil t nil "pr" "create" flags) -;; (message (buffer-string))))) - -(provide 'mm-projects) \ No newline at end of file +(provide 'mm-projects) -- cgit v1.2.3 From 6200092afe794866017a87db2c4b0967e1135b19 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 11 Dec 2025 14:09:13 +0100 Subject: emacs: Add ‘gh-open-previous-pr’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/emacs/modules/mm-projects.el | 3 ++- .config/emacs/site-lisp/gh.el | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to '.config/emacs/modules/mm-projects.el') diff --git a/.config/emacs/modules/mm-projects.el b/.config/emacs/modules/mm-projects.el index 720cea3..02d7af4 100644 --- a/.config/emacs/modules/mm-projects.el +++ b/.config/emacs/modules/mm-projects.el @@ -108,6 +108,7 @@ This is intended to be called interactively via ;;; GitHub Pull Requests (require 'gh) -(keymap-global-set "C-c p" #'gh-create-pr) +(keymap-global-set "C-c p c" #'gh-create-pr) +(keymap-global-set "C-c p o" #'gh-open-previous-pr) (provide 'mm-projects) 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) -- cgit v1.2.3