[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark a3f418154d 3/9: Use a more localized advice only
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark a3f418154d 3/9: Use a more localized advice only for embark-collect--metadatum |
Date: |
Mon, 2 May 2022 09:57:31 -0400 (EDT) |
branch: externals/embark
commit a3f418154da2c979ba85a482bded9096b2477e9b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Use a more localized advice only for embark-collect--metadatum
---
embark-consult.el | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/embark-consult.el b/embark-consult.el
index 503da3e93f..898cde0281 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -7,7 +7,7 @@
;; Keywords: convenience
;; Version: 0.5
;; Homepage: https://github.com/oantolin/embark
-;; Package-Requires: ((emacs "26.1") (embark "0.12") (consult "0.10"))
+;; Package-Requires: ((emacs "27.1") (embark "0.12") (consult "0.10"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -216,6 +216,7 @@ This function is meant to be added to
`embark-collect-mode-hook'."
(declare-function xref--show-xref-buffer "ext:xref")
(declare-function consult-xref "ext:consult-xref")
+(defvar xref-auto-jump-to-first-xref)
(defvar consult-xref--fetcher)
(defun embark-consult-export-xref (items)
@@ -281,8 +282,8 @@ This function is meant to be added to
`embark-collect-mode-hook'."
"Keymap for Consult sync search commands"
:parent nil
("o" consult-outline)
- ("i" consult-imenu)
- ("I" consult-imenu-multi)
+ ("i" 'consult-imenu)
+ ("I" 'consult-imenu-multi)
("l" consult-line)
("L" consult-line-multi))
@@ -373,15 +374,18 @@ for any action that is a Consult async command."
(cons 'imenu (mapcar #'car (consult-imenu--items))))
(defvar consult-imenu-config)
-(defun embark-consult--imenu-group-function (metadata prop)
- "Return a suitable group-function for imenu METADATA.
-Meant as :after-until advice for `completion-metadata-get'."
- (when-let (((eq (alist-get 'category metadata) 'imenu))
+(defun embark-consult--imenu-group-function (type prop)
+ "Return a suitable group-function for imenu.
+TYPE is the completion category.
+PROP is the metadata property.
+Meant as :after-until advice for `embark-collect--metadatum'."
+ (when-let (((and (eq type 'imenu) (eq prop 'group-function)))
(config (plist-get
(cdr (seq-find (lambda (x) (derived-mode-p (car x)))
consult-imenu-config))
:types)))
;; taken from consult-imenu
+ ;; TODO extract the function from consult-imenu, reuse it here.
(lambda (cand transform)
(let ((type (get-text-property 0 'consult--type cand)))
(cond
@@ -391,16 +395,18 @@ Meant as :after-until advice for
`completion-metadata-get'."
(transform cand)
(type (car (alist-get type config))))))))
+;; TODO can we find a better solution than the advice here?
+;; Can we hook more directly into `embark-collect--metadatum'?
+(advice-add #'embark-collect--metadatum :after-until
+ #'embark-consult--imenu-group-function)
+
(defun embark-consult-imenu-or-outline-candidates ()
"Collect imenu items in prog modes buffer or outline headings otherwise."
(if (derived-mode-p 'prog-mode)
(embark-consult-imenu-candidates)
(embark-consult-outline-candidates)))
-(advice-add 'completion-metadata-get :after-until
- #'embark-consult--imenu-group-function)
-
-(setf (alist-get 'imenu embark-default-action-overrides) #'consult-imenu)
+(setf (alist-get 'imenu embark-default-action-overrides) 'consult-imenu)
(add-to-list 'embark-candidate-collectors
#'embark-consult-imenu-or-outline-candidates
- [elpa] externals/embark updated (7a2487f5bb -> a8bc5d602d), ELPA Syncer, 2022/05/02
- [elpa] externals/embark a26044888e 1/9: Fix doc string warnings, ELPA Syncer, 2022/05/02
- [elpa] externals/embark a3f418154d 3/9: Use a more localized advice only for embark-collect--metadatum,
ELPA Syncer <=
- [elpa] externals/embark 25217ccddf 2/9: outline-minor-mode is autoloaded, ELPA Syncer, 2022/05/02
- [elpa] externals/embark 2d017739a0 4/9: Remap paragraph commands to outline heading commands, ELPA Syncer, 2022/05/02
- [elpa] externals/embark e6a991c322 5/9: Let's not be embarrased about advising an internal Embark function, ELPA Syncer, 2022/05/02
- [elpa] externals/embark 4f2770a4b3 7/9: Merge pull request #498 from minad/outline-review, ELPA Syncer, 2022/05/02
- [elpa] externals/embark a3e2a186ec 8/9: Make the group title format configurable (fix #497), ELPA Syncer, 2022/05/02
- [elpa] externals/embark a8bc5d602d 9/9: Make the collect group headers normal-sized, ELPA Syncer, 2022/05/02
- [elpa] externals/embark fa0ef92a96 6/9: Add {, } for outline navigation in collect buffers, ELPA Syncer, 2022/05/02