[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c53b0d2 14/17: Start the decoupling of ace-window and avy-
From: |
Oleh Krehel |
Subject: |
[elpa] master c53b0d2 14/17: Start the decoupling of ace-window and avy-jump |
Date: |
Fri, 08 May 2015 13:43:43 +0000 |
branch: master
commit c53b0d2b778b8f5ca6b985dac37190519e564229
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Start the decoupling of ace-window and avy-jump
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 | 2 +-
ace-window.el | 16 +++----------
avy-init.el | 2 +-
avy-jump.el | 66 ++++++++++++++++++++++++++++++++++++++++++--------------
4 files changed, 55 insertions(+), 31 deletions(-)
diff --git a/Makefile b/Makefile
index 69da587..e155179 100644
--- 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
diff --git a/ace-window.el b/ace-window.el
index 68e28cf..ffae3e5 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -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)
diff --git a/avy-init.el b/avy-init.el
index 929a2c6..cc2a21f 100644
--- a/avy-init.el
+++ b/avy-init.el
@@ -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)
diff --git a/avy-jump.el b/avy-jump.el
index 7443e3d..ef854f3 100644
--- a/avy-jump.el
+++ b/avy-jump.el
@@ -27,7 +27,6 @@
;;; Code:
;;* Requires
(require 'avy)
-(require 'ace-window)
;;* Customization
(defgroup avy-jump nil
@@ -52,6 +51,10 @@
'((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.
- [elpa] master cd6583b 04/17: avy-jump.el (avi-all-windows): New defcustom, (continued)
- [elpa] master cd6583b 04/17: avy-jump.el (avi-all-windows): New defcustom, Oleh Krehel, 2015/05/08
- [elpa] master f92689a 06/17: avy-jump.el (avi--line): Fixup the issue with org outlines, Oleh Krehel, 2015/05/08
- [elpa] master 17b44a8 05/17: Update a few commands to jump in one or more windows, Oleh Krehel, 2015/05/08
- [elpa] master 3bbd404 08/17: Make sure avi-move-line and avi-copy-line behave consistently., Oleh Krehel, 2015/05/08
- [elpa] master ca92a08 09/17: avy-jump.el (avi-goto-word-1): Count some syms as words, Oleh Krehel, 2015/05/08
- [elpa] master dfe24f3 11/17: Add `avi-word-punc-regexp` defcustom, Oleh Krehel, 2015/05/08
- [elpa] master 6a0acfc 10/17: Add "make compile" and "make run", Oleh Krehel, 2015/05/08
- [elpa] master ee76efd 12/17: Fix rounding error, Oleh Krehel, 2015/05/08
- [elpa] master d1780dd 07/17: avy-jump.el (avi-goto-line): Work with one or more windows, Oleh Krehel, 2015/05/08
- [elpa] master 1e94459 13/17: avy-jump.el (avi--goto): Push mark before moving, Oleh Krehel, 2015/05/08
- [elpa] master c53b0d2 14/17: Start the decoupling of ace-window and avy-jump,
Oleh Krehel <=
- [elpa] master cc38c04 16/17: Bump version, Oleh Krehel, 2015/05/08
- [elpa] master 269e61a 17/17: Merge commit 'cc38c044a13e6df822431d6c706cf4b9255900bd' from ace-window, Oleh Krehel, 2015/05/08
- [elpa] master 05e7016 15/17: Ace Window now depends on Avy, Oleh Krehel, 2015/05/08