From b47a018f22b04f2b5f747b57d30a33d9341b9a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Tue, 2 May 2023 15:14:37 +0100 Subject: [PATCH] my-git: tweaks for grabbing id --- my-git.el | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/my-git.el b/my-git.el index 282dcf5..e585a3f 100644 --- a/my-git.el +++ b/my-git.el @@ -53,6 +53,8 @@ not, I'd rather just go to magit-status. Lets make it so." :bind (("C-x g" . my-magit-dispatch) :map magit-hunk-section-map (" magit-visit-thing" . magit-diff-visit-file-worktree) + :map magit-revision-mode-map + ("C-c s" . my-mu4e-search-for-id) :map magit-mode-map ("C-x t" . hydra-magit/body)) :hook (magit-log-edit-mode . auto-fill-mode) @@ -75,7 +77,16 @@ not, I'd rather just go to magit-status. Lets make it so." ;; we use magit-git-string ourselves but there is no autoload (use-package magit-git - :commands magit-git-string) + :requires magit + :commands (magit-git-string magit-git-lines)) + +(use-package magit-process + :requires magit + :commands magit-process-git) + +(use-package magit-files + :requires magit + :commands magit-file-dispatch) ;; DCO helpers ;; @@ -196,9 +207,35 @@ This works by looking for a message-id in the buffer or prompting for (interactive (list (magit-read-range-or-commit "Fixes commit:"))) (insert (magit-git-string "showfix" commit))) + +(defun my-commit-kill-message-id (&optional no-kill) + "Snarf the message-id into the kill ring unless NO-KILL prefix." + (interactive "P") + (let ((refs)) + ;; References + (save-excursion + (goto-char (point-min)) + (while (re-search-forward my-capture-msgid-re nil t) + (let ((id (match-string-no-properties 1))) + (push (propertize (format "reference: %s" id) + 'id id) refs)))) + ;; do it + (let ((final + (get-text-property 0 'id + (if (< 1 (length refs)) + (ivy-read "select reference:" refs) + (car refs))))) + (message "message-id: %s" final) + (unless no-kill + (kill-new final)) + final))) + + (use-package git-commit + :ensure t :bind (:map git-commit-mode-map ("C-c b" . my-commit-update-with-b4) + ("C-c i" . my-commit-kill-message-id) ("C-c x" . my-commit-mode-check-and-apply-tags) ("C-c f" . my-commit-mode-add-fixes) ("C-c s" . my-mu4e-search-for-id))