]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ace-window/ace-window.el
Merge commit 'cc38c044a13e6df822431d6c706cf4b9255900bd' from ace-window
[gnu-emacs-elpa] / packages / ace-window / ace-window.el
index 5aa389d8b0a401631ecd5c612d96caff23280bcc..f34a77afcd15daa4e0414bf39d0f47959c9fc5a5 100644 (file)
@@ -5,7 +5,8 @@
 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
 ;; Maintainer: Oleh Krehel <ohwoeowho@gmail.com>
 ;; URL: https://github.com/abo-abo/ace-window
-;; Version: 0.8.0
+;; Version: 0.8.1
+;; Package-Requires: ((avy "0.1.0"))
 ;; Keywords: window, location
 
 ;; This file is part of GNU Emacs.
@@ -26,7 +27,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 +42,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 +50,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.
 ;;
@@ -56,7 +60,7 @@
 ;; deleted instead.
 
 ;;; Code:
-(require 'avy)
+(require 'avy-jump)
 (require 'ring)
 
 ;;* Customization
@@ -138,9 +142,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.")
 
@@ -160,7 +161,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.
@@ -168,8 +169,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
@@ -191,12 +195,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."
@@ -259,7 +258,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)