[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/frog-menu 6abd002 34/43: Use own avy style function and
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/frog-menu 6abd002 34/43: Use own avy style function and allow padding |
Date: |
Sun, 24 Mar 2019 05:14:49 -0400 (EDT) |
branch: externals/frog-menu
commit 6abd002e97f240ed9dfb2bb6fe9c2a805edccc4c
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Use own avy style function and allow padding
---
frog-menu.el | 46 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/frog-menu.el b/frog-menu.el
index 2fdc4f8..4ad977d 100644
--- a/frog-menu.el
+++ b/frog-menu.el
@@ -161,6 +161,10 @@ exits through an error."
:type '(alist :key-type symbol
:value-type function))
+(defcustom frog-menu-avy-padding nil
+ "If non-nil use padding between avy hints and candidates."
+ :type 'boolean)
+
(defcustom frog-menu-format-actions-function #'frog-menu-action-format
"Function used to format the actions passed to `frog-menu-read'."
:type 'function)
@@ -169,6 +173,10 @@ exits through an error."
"Function used to format the strings passed to `frog-menu-read'."
:type 'function)
+(defcustom frog-menu-min-col-padding 2
+ "Minimal padding between columns of grid."
+ :type 'integer)
+
(defcustom frog-menu-grid-width-function
(lambda () (cond ((eq frog-menu-type 'avy-posframe)
(/ (frame-width) 2))
@@ -287,7 +295,8 @@ ACTIONS."
(goto-char (point-min))
(while (not (eobp))
(goto-char (line-end-position))
- (insert " ")
+ ;; Fix: assumes only one avy char...
+ (insert (concat " " (if frog-menu-avy-padding " " "")))
(forward-line 1)))
;; posframe needs point at start,
;; otherwise it fails on first init
@@ -297,10 +306,10 @@ ACTIONS."
;; * Formatting
(defun frog-menu-grid-format (strings)
- (frog-menu--grid-format
- strings
- (funcall frog-menu-grid-column-function)
- (funcall frog-menu-grid-width-function)))
+ (frog-menu--grid-format
+ strings
+ (funcall frog-menu-grid-column-function)
+ (funcall frog-menu-grid-width-function)))
(defun frog-menu-action-format (actions)
(when actions
@@ -337,7 +346,7 @@ Returns the buffer containing the formatted grid."
(let* ((length (apply 'max
(mapcar #'string-width strings)))
(wwidth (or width (frame-width)))
- (columns (min cols (/ wwidth (+ 2 length))))
+ (columns (min cols (/ wwidth (+ frog-menu-min-col-padding length))))
(colwidth (/ wwidth columns))
(column 0)
(first t)
@@ -478,6 +487,29 @@ 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.
@@ -498,7 +530,7 @@ gets hidden after the query."
(avy-action #'identity)
(pos (avy--process
candidates
- (avy--style-fn avy-style))))
+ #'frog-menu--avy-style)))
(cond ((number-or-marker-p pos)
;; string
(with-current-buffer buffer
- [elpa] externals/frog-menu f45005d 42/43: Merge branch 'master' of github.com:clemera/frog-menu, (continued)
- [elpa] externals/frog-menu f45005d 42/43: Merge branch 'master' of github.com:clemera/frog-menu, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 9c382dc 08/43: Improve description, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu fbe8f88 10/43: Fix adding padding for avy char, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu b73b59a 11/43: Mention avy-menu, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 7f403de 12/43: Link to ace-popup-menu, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 60ed0a5 15/43: Support passing only actions, too, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu e2307a0 19/43: Add actions face, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 8b7213d 27/43: Merge branch 'master' of github.com:clemera/frog-menu, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 2a29f34 29/43: Add usage description for flyspell-correct, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 37ad44b 21/43: Refactor and add new menu type for non graphical displays, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 6abd002 34/43: Use own avy style function and allow padding,
Clemens Radermacher <=
- [elpa] externals/frog-menu 3d84ba3 38/43: allow flexible way to customize posframe parameters, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 6373133 37/43: Merge pull request #2 from waymondo/master, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 173aea7 41/43: Add more padding to the right of menu, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 75f5243 39/43: Merge pull request #3 from waymondo/posframe-parameters, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu cd5dd46 43/43: Checkdoc fixes, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu 7c3262c 30/43: Add terminal screenshot, Clemens Radermacher, 2019/03/24
- [elpa] externals/frog-menu c555913 35/43: add face for customizing posframe background, Clemens Radermacher, 2019/03/24