Commit 68292cbebeba

Vincent Demeester <vincent@sbr.pm>
2025-03-13 13:50:43
tools/emacs: some consult-gh and pr-review configuration.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent f61d723
Changed files (3)
tools/emacs/config/config-keybindings.el
@@ -19,7 +19,7 @@
   (general-def "C-M-<SPC>" 'cycle-spacing)
 
   (general-leader
-   "f"   '(:ignore t :wk ("File" . "File prefix"))
+   "f"   '(:ignore t :wk "File")
    "ff"  #'(project-find-file :wk "Find in Project")
    ))
 
tools/emacs/config/config-vcs.el
@@ -296,6 +296,9 @@
 (use-package consult-gh
   :after consult
   :custom
+  (consult-gh-dashboard-maxnum 150)
+  (consult-gh-issues-maxnum 150)
+  (consult-gh-pr-maxnum 150)
   (consult-gh-default-clone-directory "~/projects")
   (consult-gh-show-preview t)
   (consult-gh-preview-key "C-o")
@@ -329,5 +332,46 @@
   :config
   (consult-gh-with-pr-review-mode +1))
 
+(use-package pr-review
+  :custom
+  (pr-review-ghub-host "api.github.com")
+  (pr-review-notification-include-read nil)
+  (pr-review-notification-include-unsubscribed nil)
+  :config
+  (require pr-review-notification)
+  (require pr-review-search)
+  (general-leader
+    "p" '(:ignore t :which-key "PR Review")
+    "pn" #'(pr-review-notification :wk "PR review notifications")
+    "pa" #'(pr-review-current-repository :wk "PR review current repository")
+    ;; This one doesn't really work it seems
+    "ps" #'(pr-review-current-repository-search :wk "PR review search current repository")))
+
+(defun pr-review-current-repository-search (query)
+  "Run pr-review-search on the current repository."
+  (interactive "sSearch query: ")
+  (pr-review-search (format "is:pr archived:false is:open repo:%s %s" (vde/gh-get-current-repo) query)))
+
+(defun pr-review-current-repository ()
+  "Run pr-review-search on the current repository."
+  (interactive)
+  (pr-review-search (format "is:pr archived:false is:open repo:%s" (vde/gh-get-current-repo))))
+
+;; (pr-review-search "build is:pr archive:false is:open repo:tektoncd/pipeline")
+;; (pr-review-search "build")
+
+;; TODO this is relatively slow. Cache result or ?
+(defun vde/gh-get-current-repo ()
+  "Get the current repository name using the `gh' command line."
+  (unless (executable-find "gh")
+    (error "GitHub CLI (gh) command not found"))
+
+  (with-temp-buffer
+    (let ((exit-code (call-process "gh" nil t nil "repo" "view" "--json" "owner,name" "--template" "{{.owner.login}}/{{.name}}")))
+      (unless (= exit-code 0)
+	(error "Failed to get repository info: gh command exited with code %d" exit-code))
+      (string-trim (buffer-string)))))
+
+
 (provide 'config-vcs)
 ;;; config-vcs.el ends here
tools/emacs/README.org
@@ -15,6 +15,7 @@
 - https://gitlab.com/andreyorst/dotfiles/
 - https://github.com/gopar/.emacs.d
 - https://github.com/precompute/CleanEmacs/
+- https://github.com/jakebox/jake-emacs
 
 * Packages "inspirations"