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

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

[elpa] externals/embark 4f2770a4b3 7/9: Merge pull request #498 from min


From: ELPA Syncer
Subject: [elpa] externals/embark 4f2770a4b3 7/9: Merge pull request #498 from minad/outline-review
Date: Mon, 2 May 2022 09:57:33 -0400 (EDT)

branch: externals/embark
commit 4f2770a4b3f591359a1e1178f2b3dc9587f41ee4
Merge: 7a2487f5bb fa0ef92a96
Author: Omar AntolĂ­n Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #498 from minad/outline-review
    
    Outline review
---
 embark-consult.el | 26 +++++++++++++++-----------
 embark.el         | 35 +++++++++++++++++------------------
 2 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index 503da3e93f..72cb479f1a 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,16 @@ Meant as :after-until advice for 
`completion-metadata-get'."
          (transform cand)
          (type (car (alist-get type config))))))))
 
+(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
diff --git a/embark.el b/embark.el
index 7faad21dea..f207730ec8 100644
--- a/embark.el
+++ b/embark.el
@@ -113,8 +113,7 @@
 
 (eval-when-compile (require 'subr-x))
 
-(require 'ffap)    ; used to recognize file and url targets
-(require 'outline) ; used for group-function support in collect buffers
+(require 'ffap) ; used to recognize file and url targets
 
 ;;; User facing options
 
@@ -381,14 +380,13 @@ wre obtained from a `delete-file' prompt.  In that case 
you can
 configure that by adding an entry to this variable pairing `file'
 with `find-file'.
 
-In addition to target types, you can also use as keys in this
-alist, pairs of a target type and a command name.  Such a pair
-indicates that the override only applies if the target was
-obtained from minibuffer completion from that command.  For
-example adding an entry '((file . delete-file) . find-file) to
-this alist would indicate that for files at the prompt of the
-`delete-file' command, `find-file' should be used as the default
-action."
+In addition to target types, you can also use as keys in this alist,
+pairs of a target type and a command name. Such a pair indicates that
+the override only applies if the target was obtained from minibuffer
+completion from that command. For example adding an
+entry (cons (cons 'file 'delete-file) 'find-file) to this alist would
+indicate that for files at the prompt of the `delete-file' command,
+`find-file' should be used as the default action."
   :type '(alist :key-type (choice (symbol :tag "Type")
                                   (cons (symbol :tag "Type")
                                         (symbol :tag "Command")))
@@ -2644,6 +2642,7 @@ If NESTED is non-nil subkeymaps are not flattened."
   'face 'embark-collect-candidate
   'action 'embark-collect-choose)
 
+(declare-function outline-toggle-children "outline")
 (define-button-type 'embark-collect-group
   'face 'embark-collect-group-title
   'action (lambda (_) (outline-toggle-children)))
@@ -2676,18 +2675,18 @@ If NESTED is non-nil subkeymaps are not flattened."
   ("A" embark-act-all)
   ("M-a" embark-collect-direct-action-minor-mode)
   ("z" embark-collect-zebra-minor-mode)
-  ("e" embark-export)
+  ("E" embark-export)
   ("t" embark-collect-toggle-marks)
   ("m" embark-collect-mark)
   ("u" embark-collect-unmark)
   ("U" embark-collect-unmark-all)
   ("s" isearch-forward)
-  ("f" forward-button)
-  ("b" backward-button)
-  ("<right>" forward-button)
-  ("<left>" backward-button)
-  ("M-n" outline-next-heading)
-  ("M-p" outline-previous-heading))
+  ("n" forward-button)
+  ("p" backward-button)
+  ([remap forward-paragraph] 'outline-next-heading)
+  ("}" 'outline-next-heading)
+  ([remap backward-paragraph] 'outline-previous-heading)
+  ("{" 'outline-previous-heading))
 
 (define-derived-mode embark-collect-mode tabulated-list-mode "Embark Collect"
   "List of candidates to be acted on.
@@ -3313,7 +3312,7 @@ With a prefix argument, prompt the user (unless STRINGS 
has 0 or
     "\n"))
 
 (defun embark-copy-as-kill (strings)
-  "Join STRINGS and save on the kill-ring.
+  "Join STRINGS and save on the `kill-ring'.
 With a prefix argument, prompt for the separator to join the
 STRINGS, which defaults to a newline."
   (kill-new (string-join strings (embark--separator strings))))



reply via email to

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