]> code.delx.au - gnu-emacs-elpa/commitdiff
Start the decoupling of ace-window and avy-jump
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 5 May 2015 14:20:30 +0000 (16:20 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 5 May 2015 14:26:52 +0000 (16:26 +0200)
The dependencies now are ace-window -> avy-jump -> avy.

* ace-window.el (aw-overlays-lead): Rename to `avy--overlays-lead'.
(aw--done): Update.
(aw--remove-leading-chars): Rename to `aw--remove-leading-chars'.
(aw-select): Update.

* avy-init.el: Move requires after byte compiling.

* avy-jump.el (ace-window): Remove require.
(avy-background-face): New defface.
(avi--process): Update.
(avy--overlays-back): New defvar.
(avy--make-backgrounds): New defun.
(avy--done): New defun.
(avy--overlays-lead): Rename from `aw-overlays-lead'.
(avy--remove-leading-chars): Rename from `aw--remove-leading-chars'.
(avi--overlay): Update.
(avi--overlay-at): Update.

Makefile
ace-window.el
avy-init.el
avy-jump.el

index 69da5870f7d932ec0a96bb74c5ea9af2afd7a37f..e1551794f322973d621792247566711c188cd973 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ LOAD = -l avy.el -l avy-test.el
 all: test
 
 test:
-       $(EMACS) -batch $(LOAD) -f ert-run-tests-batch-and-exit
+       $(emacs) -batch $(LOAD) -f ert-run-tests-batch-and-exit
 
 compile:
        $(emacs) -batch -l avy-init.el
index 68e28cfffc83b67447e1311f88051c843db3c793..ffae3e5ce13aa928f014544fd5e2585e3742dfca 100644 (file)
@@ -59,7 +59,7 @@
 ;; deleted instead.
 
 ;;; Code:
-(require 'avy)
+(require 'avy-jump)
 (require 'ring)
 
 ;;* Customization
@@ -141,9 +141,6 @@ Use M-0 `ace-window' to toggle this value."
        (error "Invalid `aw-scope': %S" aw-scope))))
    'aw-window<))
 
-(defvar aw-overlays-lead nil
-  "Hold overlays for leading chars.")
-
 (defvar aw-overlays-back nil
   "Hold overlays for when `aw-background' is t.")
 
@@ -163,7 +160,7 @@ Use M-0 `ace-window' to toggle this value."
   ;; background
   (mapc #'delete-overlay aw-overlays-back)
   (setq aw-overlays-back nil)
-  (aw--remove-leading-chars))
+  (avy--remove-leading-chars))
 
 (defun aw--lead-overlay (path leaf)
   "Create an overlay using PATH at LEAF.
@@ -197,12 +194,7 @@ LEAF is (PT . WND)."
     (overlay-put ol 'face 'aw-leading-char-face)
     (overlay-put ol 'window wnd)
     (overlay-put ol 'display new-str)
-    (push ol aw-overlays-lead)))
-
-(defun aw--remove-leading-chars ()
-  "Remove leading char overlays."
-  (mapc #'delete-overlay aw-overlays-lead)
-  (setq aw-overlays-lead nil))
+    (push ol avy--overlays-lead)))
 
 (defun aw--make-backgrounds (wnd-list)
   "Create a dim background overlay for each window on WND-LIST."
@@ -265,7 +257,7 @@ Amend MODE-LINE to the mode line for the duration of the selection."
               (condition-case err
                   (or (cdr (avy-read (avy-tree candidate-list aw-keys)
                                      #'aw--lead-overlay
-                                     #'aw--remove-leading-chars))
+                                     #'avy--remove-leading-chars))
                       start-window)
                 (error
                  (if (memq (nth 2 err) aw--flip-keys)
index 929a2c6369afe67e394de3d8a066cfac2a8b9cf1..cc2a21fd487e4587f2c2662a79adc0737f2391ff 100644 (file)
@@ -20,8 +20,8 @@
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 (add-to-list 'load-path default-directory)
+(mapc #'byte-compile-file '("avy.el" "avy-jump.el" "ace-window.el"))
 (require 'ace-window)
 (require 'avy-jump)
-(mapc #'byte-compile-file '("avy.el" "avy-jump.el" "ace-window.el"))
 (global-set-key (kbd "C-c j") 'avi-goto-char)
 (global-set-key (kbd "C-'") 'avi-goto-char-2)
index 7443e3dfec2abb74f8e5e9c6f0809eac9e5a5d86..ef854f3335a642fd50ec0ee949bb6c6ca1aa1e80 100644 (file)
@@ -27,7 +27,6 @@
 ;;; Code:
 ;;* Requires
 (require 'avy)
-(require 'ace-window)
 
 ;;* Customization
 (defgroup avy-jump nil
   '((t (:foreground "white" :background "#e52b50")))
   "Face used for the leading chars.")
 
+(defface avy-background-face
+  '((t (:foreground "gray40")))
+  "Face for whole window background during selection.")
+
 ;;* Internals
 (defun avi--goto (x)
   "Goto X.
@@ -69,18 +72,39 @@ POS is either a position or (BEG . END)."
 (defun avi--process (candidates overlay-fn)
   "Select one of CANDIDATES using `avy-read'."
   (unwind-protect
-       (let ((aw-background avi-background))
-         (cl-case (length candidates)
-           (0
-            nil)
-           (1
-            (car candidates))
-           (t
-            (aw--make-backgrounds (list (selected-window)))
-            (avy-read (avy-tree candidates avi-keys)
-                      overlay-fn
-                      #'aw--remove-leading-chars))))
-    (aw--done)))
+       (cl-case (length candidates)
+         (0
+          nil)
+         (1
+          (car candidates))
+         (t
+          (avy--make-backgrounds (list (selected-window)))
+          (avy-read (avy-tree candidates avi-keys)
+                    overlay-fn
+                    #'avy--remove-leading-chars)))
+    (avy--done)))
+
+(defvar avy--overlays-back nil
+  "Hold overlays for when `avi-background' is t.")
+
+(defun avy--make-backgrounds (wnd-list)
+  "Create a dim background overlay for each window on WND-LIST."
+  (when avi-background
+    (setq avy--overlays-back
+          (mapcar (lambda (w)
+                    (let ((ol (make-overlay
+                               (window-start w)
+                               (window-end w)
+                               (window-buffer w))))
+                      (overlay-put ol 'face 'avy-background-face)
+                      ol))
+                  wnd-list))))
+
+(defun avy--done ()
+  "Clean up overlays."
+  (mapc #'delete-overlay avy--overlays-back)
+  (setq avy--overlays-back nil)
+  (avy--remove-leading-chars))
 
 (defcustom avi-all-windows t
   "When non-nil, loop though all windows for candidates."
@@ -110,6 +134,14 @@ When PRED is non-nil, it's a filter for matching point positions."
 (defvar avi--overlay-offset 0
   "The offset to apply in `avi--overlay'.")
 
+(defvar avy--overlays-lead nil
+  "Hold overlays for leading chars.")
+
+(defun avy--remove-leading-chars ()
+  "Remove leading char overlays."
+  (mapc #'delete-overlay avy--overlays-lead)
+  (setq avy--overlays-lead nil))
+
 (defun avi--overlay (str pt wnd)
   "Create an overlay with STR at PT in WND."
   (let* ((pt (+ pt avi--overlay-offset))
@@ -118,10 +150,10 @@ When PRED is non-nil, it's a filter for matching point positions."
                     (buffer-substring pt (1+ pt)))))
     (when avi-background
       (setq old-str (propertize
-                     old-str 'face 'aw-background-face)))
+                     old-str 'face 'avy-background-face)))
     (overlay-put ol 'window wnd)
     (overlay-put ol 'display (concat str old-str))
-    (push ol aw-overlays-lead)))
+    (push ol avy--overlays-lead)))
 
 (defun avi--overlay-pre (path leaf)
   "Create an overlay with STR at LEAF.
@@ -157,10 +189,10 @@ LEAF is ((BEG . END) . WND)."
                      (buffer-substring pt (1+ pt)))))
       (when avi-background
         (setq old-str (propertize
-                       old-str 'face 'aw-background-face)))
+                       old-str 'face 'avy-background-face)))
       (overlay-put ol 'window wnd)
       (overlay-put ol 'display str)
-      (push ol aw-overlays-lead))))
+      (push ol avy--overlays-lead))))
 
 (defun avi--overlay-post (path leaf)
   "Create an overlay with STR at LEAF.