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

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

[elpa] master cf04c93 6/6: Merge commit 'd592e36f33ac7e1fece462c5b7157f3


From: Oleh Krehel
Subject: [elpa] master cf04c93 6/6: Merge commit 'd592e36f33ac7e1fece462c5b7157f330c732630' from ace-window
Date: Thu, 16 Apr 2015 12:13:07 +0000

branch: master
commit cf04c931cb46d2a38e5ef8357c31df0d53414914
Merge: f0c4778 d592e36
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Merge commit 'd592e36f33ac7e1fece462c5b7157f330c732630' from ace-window
---
 packages/ace-window/ace-window.el |   14 ++++++++---
 packages/ace-window/avy-jump.el   |   45 ++++++++++++++++++++++++++++++------
 2 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/packages/ace-window/ace-window.el 
b/packages/ace-window/ace-window.el
index 5aa389d..68e28cf 100644
--- a/packages/ace-window/ace-window.el
+++ b/packages/ace-window/ace-window.el
@@ -26,7 +26,7 @@
 ;;; Commentary:
 ;;
 ;; The main function, `ace-window' is meant to replace `other-window'.
-;; If fact, when there are only two windows present, `other-window' is
+;; In fact, when there are only two windows present, `other-window' is
 ;; called.  If there are more, each window will have its first
 ;; character highlighted.  Pressing that character will switch to that
 ;; window.
@@ -41,7 +41,7 @@
 ;;
 ;;    (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
 ;;
-;; This way they're all on the home row, although the intuitive
+;; This way they are all on the home row, although the intuitive
 ;; ordering is lost.
 ;;
 ;; If you don't want the gray background that makes the red selection
@@ -49,6 +49,9 @@
 ;;
 ;;    (setq aw-background nil)
 ;;
+;; If you want to know the selection characters ahead of time, you can
+;; turn on `ace-window-display-mode'.
+;;
 ;; When prefixed with one `universal-argument', instead of switching
 ;; to selected window, the selected window is swapped with current one.
 ;;
@@ -168,8 +171,11 @@ LEAF is (PT . WND)."
   (let* ((pt (car leaf))
          (wnd (cdr leaf))
          (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
-         (old-str (with-selected-window wnd
-                    (buffer-substring pt (1+ pt))))
+         (old-str (or
+                   (ignore-errors
+                     (with-selected-window wnd
+                       (buffer-substring pt (1+ pt))))
+                   ""))
          (new-str
           (concat
            (cl-case aw-leading-char-style
diff --git a/packages/ace-window/avy-jump.el b/packages/ace-window/avy-jump.el
index b83f7a8..50c7fce 100644
--- a/packages/ace-window/avy-jump.el
+++ b/packages/ace-window/avy-jump.el
@@ -75,9 +75,10 @@ POS is either a position or (BEG . END)."
                       #'aw--remove-leading-chars))))
     (aw--done)))
 
-(defun avi--regex-candidates (regex &optional wnd beg end)
+(defun avi--regex-candidates (regex &optional wnd beg end pred)
   "Return all elements that match REGEX in WND.
-Each element of the list is ((BEG . END) . WND)."
+Each element of the list is ((BEG . END) . WND)
+When PRED is non-nil, it's a filter for matching point positions."
   (setq wnd (or wnd (selected-window)))
   (let ((we (or end (window-end (selected-window) t)))
         candidates)
@@ -86,16 +87,22 @@ Each element of the list is ((BEG . END) . WND)."
       (save-excursion
         (goto-char (or beg (window-start)))
         (while (re-search-forward regex we t)
-          (push (cons (cons (match-beginning 0)
-                            (match-end 0))
-                      wnd) candidates)))
+          (when (or (null pred)
+                    (funcall pred))
+            (push (cons (cons (match-beginning 0)
+                              (match-end 0))
+                        wnd) candidates))))
       (nreverse candidates))))
 
+(defvar avi--overlay-offset 0
+  "The offset to apply in `avi--overlay'.")
+
 (defun avi--overlay (str pt wnd)
   "Create an overlay with STR at PT in WND."
-  (let ((ol (make-overlay pt (1+ pt) (window-buffer wnd)))
-        (old-str (with-selected-window wnd
-                   (buffer-substring pt (1+ pt)))))
+  (let* ((pt (+ pt avi--overlay-offset))
+         (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
+         (old-str (with-selected-window wnd
+                    (buffer-substring pt (1+ pt)))))
     (when avi-background
       (setq old-str (propertize
                      old-str 'face 'aw-background-face)))
@@ -115,6 +122,28 @@ LEAF is ((BEG . END) . WND)."
      (car leaf))
    (cdr leaf)))
 
+(defun avi--overlay-at (path leaf)
+  "Create an overlay with STR at LEAF.
+PATH is a list of keys from tree root to LEAF.
+LEAF is ((BEG . END) . WND)."
+  (let ((str (propertize
+              (string (car (last path)))
+              'face 'avi-lead-face))
+        (pt (if (consp (car leaf))
+                (caar leaf)
+              (car leaf)))
+        (wnd (cdr leaf)))
+    (let ((ol (make-overlay pt (1+ pt)
+                            (window-buffer wnd)))
+          (old-str (with-selected-window wnd
+                     (buffer-substring pt (1+ pt)))))
+      (when avi-background
+        (setq old-str (propertize
+                       old-str 'face 'aw-background-face)))
+      (overlay-put ol 'window wnd)
+      (overlay-put ol 'display str)
+      (push ol aw-overlays-lead))))
+
 (defun avi--overlay-post (path leaf)
   "Create an overlay with STR at LEAF.
 PATH is a list of keys from tree root to LEAF.



reply via email to

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