Skip to content

ace-window 0.7.0

Compare
Choose a tag to compare
@abo-abo abo-abo released this 07 Feb 13:59
· 155 commits to master since this release

Updated API

With this release, ace-window API has been greatly simplified: it now provides only a
single function called aw-select. This function takes one argument: a string to
temporarily append the mode line with, so that you have an idea which function is asking
you to select an ace char. It returns a selected window object, without actually
switching to it. You can use that window object as you wish.

Previously, the problem was that aw--doit would immediately return, although the window
was not yet selected, and some hooks manipulation had to be done to handle the execution
flow. Now, it's very simple: aw-select will not return until it has a window object.

If your code needs to select a window from the current Emacs instance, and you'd like to
do it with the same method that ace-window does it, it has become even simpler to
implement. For example, here's the implementation of ace-delete-window:

(require 'ace-window)
;;;###autoload
(defun ace-delete-window ()
  "Ace delete window."
  (interactive)
  (aw-delete-window
   (aw-select " Ace - Delete Window")))

(defun aw-delete-window (window)
  "Delete window WINDOW."
  (let ((frame (window-frame window)))
    (when (and (frame-live-p frame)
               (not (eq frame (selected-frame))))
      (select-frame-set-input-focus (window-frame window)))
    (if (= 1 (length (window-list)))
        (delete-frame frame)
      (if (window-live-p window)
          (delete-window window)
        (error "Got a dead window %S" window)))))

And here's the two line implementation of ace-maximize-window:

;;;###autoload
(defun ace-maximize-window ()
  "Ace maximize window."
  (interactive)
  (select-window (aw-select " Ace - Maximize Window"))
  (delete-other-windows))