summary refs log tree commit diff stats
path: root/lisp/+ace-window.el
blob: fca27d97ce52f40e4dcdc76b7ab9581deca2b859 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;;; +ace-window.el -*- lexical-binding: t; -*-

;;; Code:

(require 'ace-window)

;;;###autoload
(define-minor-mode +ace-window-display-mode
  "Minor mode for updating data for `+modeline-ace-window-display'."
  ;; This is stolen from ace-window.el but with the mode-line stuff ripped out.
  :global t
  (if +ace-window-display-mode
      (progn
        (aw-update)
        (force-mode-line-update t)
        (add-hook 'window-configuration-change-hook 'aw-update)
        (add-hook 'after-make-frame-functions 'aw--after-make-frame t)
        (advice-add 'aw--lead-overlay :override 'ignore))
    (remove-hook 'window-configuration-change-hook 'aw-update)
    (remove-hook 'after-make-frame-functions 'aw--after-make-frame)
    (advice-remove 'aw--lead-overlay 'ignore)))

;;;###autoload
(defun +ace-window-or-switch-buffer (arg)
  "Call `ace-window' with ARG if more than one window is visible.
Switch to most recent buffer otherwise."
  ;; cribbed from `crux-other-window-or-switch-buffer'
  (interactive "p")
  (if (one-window-p)
      (switch-to-buffer nil)
    (ace-window arg)))

(defun +ace-window@disable-overlay (_fn &rest _args)
  "ADVICE for FN `aw--lead-overlay' (and ARGS) to not show overlays.")

(provide '+ace-window)
;;; +ace-window.el ends here