]> code.delx.au - gnu-emacs-elpa/commitdiff
Fix the at-full style interaction with tabs
authorOleh Krehel <ohwoeowho@gmail.com>
Sun, 17 May 2015 11:44:17 +0000 (13:44 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Sun, 17 May 2015 11:44:17 +0000 (13:44 +0200)
* avy.el (avy--overlay-at-full): When at tab, visualize it using
  `tab-width' spaces. Assume the path is shorter than `tab-width'.

Fixes #43

avy.el

diff --git a/avy.el b/avy.el
index ebf558e8c9bc7a393cd21a552fbc0b03cb4a8b54..183880848ad96d7c6ea1aca53a1db58c8c4ab6cb 100644 (file)
--- a/avy.el
+++ b/avy.el
@@ -453,7 +453,11 @@ LEAF is normally ((BEG . END) . WND)."
           (setq len 1))
         (let* ((end (if (= beg (line-end-position))
                         (1+ beg)
-                      (min (+ beg len) (line-end-position))))
+                      (min (+ beg
+                              (if (eq (char-after) ?\t)
+                                  1
+                                len))
+                           (line-end-position))))
                (ol (make-overlay
                     beg end
                     (current-buffer)))
@@ -463,9 +467,13 @@ LEAF is normally ((BEG . END) . WND)."
                            old-str 'face 'avy-background-face)))
           (overlay-put ol 'window wnd)
           (overlay-put ol 'category 'avy)
-          (overlay-put ol 'display (if (string= old-str "\n")
-                                       (concat str "\n")
-                                     str))
+          (overlay-put ol 'display
+                       (cond ((string= old-str "\n")
+                              (concat str "\n"))
+                             ((string= old-str "\t")
+                              (concat str (make-string (- tab-width len) ?\ )))
+                             (t
+                              str)))
           (push ol avy--overlays-lead))))))
 
 (defun avy--overlay-post (path leaf)