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

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

[elpa] master 3257d81 49/78: Add avy-candidate-* helper functions


From: Oleh Krehel
Subject: [elpa] master 3257d81 49/78: Add avy-candidate-* helper functions
Date: Sat, 23 Jan 2016 14:00:08 +0000

branch: master
commit 3257d81b4a513ae4e963015f685aa9be5144f7a2
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add avy-candidate-* helper functions
    
    * avy.el (avy-candidate-beg):
    (avy-candidate-end):
    (avy-candidate-wnd): New defun.
    (avy--overlay-pre):
    (avy--overlay-at):
    (avy--overlay-at-full):
    (avy--overlay-post): Update.
---
 avy.el |   55 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/avy.el b/avy.el
index 2bbbfe6..61dac3a 100644
--- a/avy.el
+++ b/avy.el
@@ -649,6 +649,30 @@ Do this even when the char is terminating."
     (or (cdr (assoc c avy-key-to-char-alist))
         (error "Unknown key %s" c))))
 
+(defun avy-candidate-beg (leaf)
+  "Return the start position for LEAF."
+  (cond ((numberp leaf)
+         leaf)
+        ((consp (car leaf))
+         (caar leaf))
+        (t
+         (car leaf))))
+
+(defun avy-candidate-end (leaf)
+  "Return the end position for LEAF."
+  (cond ((numberp leaf)
+         leaf)
+        ((consp (car leaf))
+         (cdar leaf))
+        (t
+         (car leaf))))
+
+(defun avy-candidate-wnd (leaf)
+  "Return the window for LEAF."
+  (if (consp leaf)
+      (cdr leaf)
+    (selected-window)))
+
 (defun avy--overlay-pre (path leaf)
   "Create an overlay with PATH at LEAF.
 PATH is a list of keys from tree root to LEAF.
@@ -664,15 +688,8 @@ LEAF is normally ((BEG . END) . WND)."
                str))
     (avy--overlay
      str
-     (cond ((numberp leaf)
-            leaf)
-           ((consp (car leaf))
-            (caar leaf))
-           (t
-            (car leaf)))
-     (if (consp leaf)
-         (cdr leaf)
-       (selected-window)))))
+     (avy-candidate-beg leaf)
+     (avy-candidate-wnd leaf))))
 
 (defun avy--overlay-at (path leaf)
   "Create an overlay with PATH at LEAF.
@@ -682,10 +699,7 @@ LEAF is normally ((BEG . END) . WND)."
          (str (propertize
                (string (car (last path)))
                'face 'avy-lead-face))
-         (pt (+ (if (consp (car leaf))
-                    (caar leaf)
-                  (car leaf))
-                avy--overlay-offset))
+         (pt (+ (avy-candidate-beg leaf) avy--overlay-offset))
          (wnd (cdr leaf))
          (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
          (old-str (avy--old-str pt wnd)))
@@ -707,9 +721,7 @@ LEAF is normally ((BEG . END) . WND)."
                (apply #'string (reverse path))
                'face 'avy-lead-face))
          (len (length path))
-         (beg (if (consp (car leaf))
-                  (caar leaf)
-                (car leaf)))
+         (beg (avy-candidate-beg leaf))
          (wnd (cdr leaf))
          oov)
     (dotimes (i len)
@@ -791,15 +803,8 @@ LEAF is normally ((BEG . END) . WND)."
                str))
     (avy--overlay
      str
-     (cond ((numberp leaf)
-            leaf)
-           ((consp (car leaf))
-            (cdar leaf))
-           (t
-            (car leaf)))
-     (if (consp leaf)
-         (cdr leaf)
-       (selected-window)))))
+     (avy-candidate-end leaf)
+     (avy-candidate-wnd leaf))))
 
 (defun avy--style-fn (style)
   "Transform STYLE symbol to a style function."



reply via email to

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