emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit ace5ca4401: magit--imenu-goto-function: New fun


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit ace5ca4401: magit--imenu-goto-function: New function
Date: Sun, 3 Sep 2023 21:59:24 -0400 (EDT)

branch: elpa/git-commit
commit ace5ca440168389bbbf02dea37c40e1d71334626
Author: Adam Porter <adam@alphapapa.net>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit--imenu-goto-function: New function
    
    For it as `imenu-default-goto-function' in `magit-mode' buffers.
    
    Co-authored-by: Jonas Bernoulli <jonas@bernoul.li>
---
 lisp/magit-mode.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lisp/magit-mode.el b/lisp/magit-mode.el
index 007c4be470..c2ab1fea75 100644
--- a/lisp/magit-mode.el
+++ b/lisp/magit-mode.el
@@ -526,6 +526,7 @@ Magit is documented in info node `(magit)'."
   (setq-local revert-buffer-function #'magit-refresh-buffer)
   (setq-local bookmark-make-record-function #'magit--make-bookmark)
   (setq-local imenu-create-index-function #'magit--imenu-create-index)
+  (setq-local imenu-default-goto-function #'magit--imenu-goto-function)
   (setq-local isearch-filter-predicate #'magit-section--open-temporarily))
 
 ;;; Local Variables
@@ -1443,6 +1444,17 @@ mentioned caches completely."
         (substring heading 0 (match-beginning 0)))
        (t heading)))))
 
+(defun magit--imenu-goto-function (_name position &rest _rest)
+  "Go to the section at POSITION.
+Make sure it is visible, by showing its ancestors where
+necessary.  For use as `imenu-default-goto-function' in
+`magit-mode' buffers."
+  (goto-char position)
+  (let ((section (magit-current-section)))
+    (while (setq section (oref section parent))
+      (when (oref section hidden)
+        (magit-section-show section)))))
+
 ;;; Bookmark support
 
 (declare-function bookmark-get-filename "bookmark" (bookmark-name-or-record))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]