]> git.eshelyaron.com Git - emacs.git/commitdiff
Add imenu support to package-menu-mode
authorDamien Cassou <damien@cassou.me>
Mon, 24 Jun 2019 22:55:45 +0000 (00:55 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jun 2019 23:31:10 +0000 (01:31 +0200)
* lisp/emacs-list/package.el
(package--imenu-prev-index-position-function
package--imenu-extract-index-name-function): Add Imenu functions
to package-menu-mode (bug#27134).

etc/NEWS
lisp/emacs-lisp/package.el

index 0f764cd9986286743b4bd18bfcd4025404ef501b..101b7f5b7bb26bdb7ac54ca859b2a37ae580ba47 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -812,6 +812,9 @@ early init file.
 
 *** New function 'package-activate-all'.
 
+---
+*** Imenu support has been added to `package-menu-mode'.
+
 ** Info
 
 ---
index 670831d9630b4d0ce68396931ec5e53498d6ce5d..b60a8a136a11952736a1868565b77696dd0c71f4 100644 (file)
@@ -2640,7 +2640,11 @@ Letters do not insert themselves; instead, they are commands.
   (setq tabulated-list-padding 2)
   (setq tabulated-list-sort-key (cons "Status" nil))
   (add-hook 'tabulated-list-revert-hook #'package-menu--refresh nil t)
-  (tabulated-list-init-header))
+  (tabulated-list-init-header)
+  (setf imenu-prev-index-position-function
+        #'package--imenu-prev-index-position-function)
+  (setf imenu-extract-index-name-function
+        #'package--imenu-extract-index-name-function))
 
 (defmacro package--push (pkg-desc status listname)
   "Convenience macro for `package-menu--generate'.
@@ -3671,6 +3675,24 @@ activations need to be changed, such as when `package-load-list' is modified."
 ;; End:
 "))))
 
+(defun package--imenu-prev-index-position-function ()
+  "Move point to previous line in package-menu buffer.
+This function is used as a value for
+`imenu-prev-index-position-function'."
+  (unless (bobp)
+    (forward-line -1)))
+
+(defun package--imenu-extract-index-name-function ()
+  "Return imenu name for line at point.
+This function is used as a value for
+`imenu-extract-index-name-function'.  Point should be at the
+beginning of the line."
+  (let ((package-desc (tabulated-list-get-id)))
+    (format "%s (%s): %s"
+            (package-desc-name package-desc)
+            (package-version-join (package-desc-version package-desc))
+            (package-desc-summary package-desc))))
+
 (provide 'package)
 
 ;;; package.el ends here