]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/xref.el: Support outline-minor-mode (bug#49731)
authorJuri Linkov <juri@linkov.net>
Wed, 23 Nov 2022 08:38:28 +0000 (10:38 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 23 Nov 2022 08:38:28 +0000 (10:38 +0200)
(xref--xref-buffer-mode): Set buffer-local variables outline-minor-mode-cycle,
outline-minor-mode-use-buttons, outline-search-function, outline-level
as settings for enabling outline-minor-mode in xref output buffers where
outline headings are xref groups, and their lines can be hidden by
outline commands.

lisp/progmodes/xref.el

index 89a090ae932509a0e1e3aef82cbfd7074bca6ae2..139929dc8a47fc68b16116fea7160f89ae31134a 100644 (file)
@@ -919,6 +919,8 @@ ITEMS is an xref item which " ; FIXME: Expand documentation.
     (define-key map (kbd "M-,") #'xref-quit-and-pop-marker-stack)
     map))
 
+(declare-function outline-search-text-property "outline" (property &optional value bound move backward looking-at))
+
 (define-derived-mode xref--xref-buffer-mode special-mode "XREF"
   "Mode for displaying cross-references."
   (setq buffer-read-only t)
@@ -927,7 +929,14 @@ ITEMS is an xref item which " ; FIXME: Expand documentation.
   (setq imenu-prev-index-position-function
         #'xref--imenu-prev-index-position)
   (setq imenu-extract-index-name-function
-        #'xref--imenu-extract-index-name))
+        #'xref--imenu-extract-index-name)
+  (setq-local outline-minor-mode-cycle t
+              outline-minor-mode-use-buttons t
+              outline-search-function
+              (lambda (&optional bound move backward looking-at)
+                (outline-search-text-property
+                 'xref-group nil bound move backward looking-at))
+              outline-level (lambda () 1)))
 
 (defvar xref--transient-buffer-mode-map
   (let ((map (make-sparse-keymap)))