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

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

[elpa] externals/frog-menu 586aadf 5/6: Handle avy display differently


From: Clemens Radermacher
Subject: [elpa] externals/frog-menu 586aadf 5/6: Handle avy display differently
Date: Mon, 29 Apr 2019 08:35:04 -0400 (EDT)

branch: externals/frog-menu
commit 586aadfa08156a0f19309b77c86612776e1d6475
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Handle avy display differently
---
 frog-menu.el | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/frog-menu.el b/frog-menu.el
index 1e0a6c1..0259ae5 100644
--- a/frog-menu.el
+++ b/frog-menu.el
@@ -316,7 +316,14 @@ ACTIONS."
 (defun frog-menu-grid-format (strings)
   "Format STRINGS to a grid."
     (frog-menu--grid-format
-     strings
+     (mapcar (lambda (str)
+               (concat (propertize
+                        "_"
+                        'face (list :foreground
+                                (face-background
+                                 'frog-menu-posframe-background-face nil t)))
+                       (if frog-menu-avy-padding " " "")
+                       str)) strings)
      (funcall frog-menu-grid-column-function)
      (funcall frog-menu-grid-width-function)))
 
@@ -509,29 +516,6 @@ action result. ACTIONS is the argument of 
`frog-menu-read'."
     (define-key frog-menu--avy-action-map (kbd (car action))
       (lambda () (interactive) (car (cddr action))))))
 
-(defun frog-menu--avy-style (path leaf)
-  "Create an overlay with PATH at LEAF.
-PATH is a list of keys from tree root to LEAF.
-LEAF is normally ((BEG . END) . WND)."
-  (let* ((path (mapcar #'avy--key-to-char path))
-         (str (propertize (apply #'string (reverse path))
-                          'face 'avy-lead-face)))
-    (when (or avy-highlight-first (> (length str) 1))
-      (set-text-properties 0 1 '(face avy-lead-face-0) str))
-    (setq str (concat
-               (propertize avy-current-path
-                           'face 'avy-lead-face-1)
-               str))
-    (avy--overlay
-     str
-     (avy-candidate-beg leaf) nil
-     (avy-candidate-wnd leaf)
-     (lambda (str old-str)
-       (concat str
-               (if frog-menu-avy-padding " " "")
-               old-str)))))
-
-
 (defun frog-menu-query-with-avy (buffer window actions)
   "Query handler for avy-posframe.
 
@@ -550,19 +534,21 @@ ACTIONS is the argument of `frog-menu-read'."
                (avy-handler-function #'frog-menu--posframe-ace-handler)
                (avy-pre-action #'ignore)
                (avy-all-windows nil)
-               (avy-style 'pre)
+               (avy-style 'at-full)
                (avy-action #'identity)
                (pos (with-selected-window window
                       (avy--process
                        candidates
-                       #'frog-menu--avy-style))))
+                       (avy--style-fn avy-style)))))
           (cond ((number-or-marker-p pos)
                  ;; string
                  (with-current-buffer buffer
                    (let* ((start pos)
                           (end (or (next-single-property-change start 'face)
                                    (point-max))))
-                     (buffer-substring start end))))
+                     ;; get rid of the padding
+                     (replace-regexp-in-string
+                      "\\`_ *" "" (buffer-substring start end)))))
                 ((commandp pos)
                  ;; action
                  (call-interactively pos))))



reply via email to

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