branch: elpa/git-commit
commit 6df1347ccda1c160222f2e9643d5815f8a0c0ef1
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-section-context-menu: Run magit-menu-alternative-section-hook
The code, that is being moved to the new hook function
`magit--painted-branch-as-menu-section', didn't belong
in "magit-section.el" as it is specific to Magit.
---
lisp/magit-refs.el | 14 ++++++++++++++
lisp/magit-section.el | 17 +++++------------
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el
index 797284aacf..0452e66822 100644
--- a/lisp/magit-refs.el
+++ b/lisp/magit-refs.el
@@ -495,6 +495,20 @@ Branch %s already exists.
map)
"Keymap for `tag' sections.")
+(defun magit--painted-branch-as-menu-section (section)
+ (and-let* ((branch (and (magit-section-match 'commit)
+ (magit--painted-branch-at-point))))
+ (let ((dummy (magit-section :type 'branch :value branch)))
+ (oset dummy keymap magit-branch-section-map)
+ (dolist (slot '(start content hidden parent children))
+ (when (slot-boundp section slot)
+ (setf (eieio-oref dummy slot)
+ (eieio-oref section slot))))
+ dummy)))
+
+(add-hook 'magit-menu-alternative-section-hook
+ #'magit--painted-branch-as-menu-section)
+
(defun magit-insert-branch-description ()
"Insert header containing the description of the current branch.
Insert a header line with the name and description of the
diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 27b4299d1b..aeb1a4586b 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -554,18 +554,11 @@ The return value has the form (TYPE...)."
(magit-section-at))))
(unless (region-active-p)
(setq magit--context-menu-buffer (current-buffer))
- (if-let ((branch (save-excursion
- (mouse-set-point click)
- (and (magit-section-match 'commit)
- (magit--painted-branch-at-point)))))
- (let ((dummy (magit-section :type 'branch :value branch)))
- (dolist (slot '(start content hidden parent children))
- (when (slot-boundp section slot)
- (setf (eieio-oref dummy slot)
- (eieio-oref section slot))))
- (oset dummy keymap magit-branch-section-map)
- (setq section dummy)
- (setq magit--context-menu-section section))
+ (if-let ((alt (save-excursion
+ (mouse-set-point click)
+ (run-hook-with-args-until-success
+ 'magit-menu-alternative-section-hook section))))
+ (setq magit--context-menu-section (setq section alt))
(setq magit--context-menu-section section)
(magit-section-update-highlight t)))
(when (magit-section-content-p section)