Skip to content

Releases: abo-abo/ace-window

ace-window 0.9.0

13 May 15:20
Compare
Choose a tag to compare

New Features

Display the window decision chars in the mode line

Enable ace-window-display-mode for this. This gives you the advantage of always being aware which window corresponds to which char.

New defcustom: aw-ignore-current

This is off by default. When t, ace-window will ignore selected-window.

Allow to switch the window action midway

Ace-window has many commands available, like:

  • ace-select-window
  • ace-delete-window
  • ace-swap-window
  • ...

But did you wish sometimes when you called ace-select-window that you should have called ace-delete-window? In the old way, you would cancel ace-select-window with C-g and call ace-delete-window.

With the new way, you can, just press x followed by the decision char. All keys are customizable through aw-dispatch-alist.

(defvar aw-dispatch-alist
  '((?x aw-delete-window " Ace - Delete Window")
    (?m aw-swap-window " Ace - Swap Window")
    (?n aw-flip-window)
    (?v aw-split-window-vert " Ace - Split Vert Window")
    (?b aw-split-window-horz " Ace - Split Horz Window")
    (?i delete-other-windows " Ace - Maximize Window")
    (?o delete-other-windows))
  "List of actions for `aw-dispatch-default'.")

The strings beside each command are important: they are used to update the mode line when you press a char. They also mean that a window should be selected using aw-keys for the corresponding command. If there's no string, the command is just called straight away, with no arguments. To reiterate, for each entry without a string, its command will be called immediately, and for others the window will be selected first.

Also, take note of aw-flip-window. Suppose the you have a lot (say 7) windows, but you only want to cycle between the most recent two. You can do so with n, with no need to press the decision char.

I call this feature "the dispatch". The dispatch normally happens when:

  1. you're prompted for aw-keys
  2. you press a char that isn't in aw-keys
  3. there's an entry in aw-dispatch-alist for this char

If you want to skip step 1 always (since, by default, you're not prompted for aw-keys when you have 2 or less windows), use:

(setq aw-dispatch-always t)

Be careful though, setting this means that you'll always have to select a window with aw-keys, even if there are only two. This is a large toll on the muscle memory. On the other hand, even with one window, assuming you've bound ace-window to M-p, you get:

  • split-window-vertically on M-p v
  • split-window-horizontally on M-p b
  • delete-other-windows on M-p o

What's also nice is that these commands scale with the amount of windows: if you have only one window, you get no prompt for M-p v, so it acts just like C-x 2. But if you have more windows, you don't have to select the window that you want to split beforehand: you can select it after you decided to issue a split operation.

See the wiki for a nice customization setup by @joedicastro.

ace-window 0.7.1

02 Mar 15:21
Compare
Choose a tag to compare

Fixes

Fix regression not respecting aw-ignored-buffers.

New features

Allow customizing the leading char. Example:

(custom-set-faces
     '(aw-leading-char-face
       ((t (:inherit ace-jump-face-foreground :height 2.0)))))

ace-window 0.7.0

07 Feb 13:59
Compare
Choose a tag to compare

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))

ace-window 0.6.0

26 Dec 09:48
Compare
Choose a tag to compare

Library

After this release, ace-window can be used a library.

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 very simple to
implement. For example, here's the implementation of ace-delete-window:

(require 'ace-window)
;;;###autoload
(defun ace-delete-window ()
  "Ace delete window."
  (interactive)
  (setq aw--current-op 'aw-delete-window)
  (aw--doit " Ace - Delete Window"))

(defun aw-delete-window (aj-data)
  "Delete window of `aj-position' structure AJ-DATA."
  (let ((frame (aj-position-frame aj-data))
        (window (aj-position-window aj-data)))
    (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 "Bad aj-data, aw-delete-window: %S" aj-data)))))

Fixes/Improvements since 0.5.0

  • ace-delete-window can now close frames.
  • ace-swap-window now works properly when you have, for instance, two
    frames with one window each.
  • aw-list-visual-area now works in a non-silly way to detect the
    invisible Emacs frame. Thanks, @oantolin.
  • aw-offset now works properly with comint buffers.

ace-window 0.5.1

19 Dec 10:08
Compare
Choose a tag to compare

This is a stable fallback before aw-generic macro is removed in
master.

If no issues arise with MELPA users, an aw-generic-less 0.6.0
will be released soon.