Compare commits

..

17 Commits

Author SHA1 Message Date
Jacopo De Simoi f1f7839f8d [margin-path] Tentative fix for background clean-up 3 years ago
Jacopo De Simoi 79ac9016d6 [margin-path] Move label to the margin 3 years ago
Vincent Zhang 77115afc1b Get inherited faces in posframe. 4 years ago
Grant Rosson 3fe3534c75
Make posframe buffers hidden 4 years ago
Oleh Krehel 0d9a89edaf ace-window-posframe.el (ace-window-posframe-disable): Fixup 4 years ago
Oleh Krehel aec8fd680a ace-window-posframe.el: map -> cl-map 4 years ago
Mark Skilbeck e3e6ec105a Fix slowness of posframe 4 years ago
Mark Skilbeck 751bd326db Allow configuration of the posframe position 4 years ago
Mark Skilbeck b2cc22a164 Provide ace-window-posframe-mode 4 years ago
Stefan Kangas 0577c426a9 Add GNU ELPA badge 4 years ago
ramblehead c7cb315c14 ace-window.el (aw-copy-window): Copy window-start and point 6 years ago
Oleh Krehel 7003c88cd9 ace-window.el: Bump version 6 years ago
Oleh Krehel b93380cdf3 ace-window.el: Remove obsolete variables 6 years ago
Oleh Krehel e445b2c29b ace-window.el (aw-select): Disable transient-mark-mode for the duration 6 years ago
Oleh Krehel a36c1472d0 ace-window.el (aw-dispatch-alist): Add hyperbole comment 6 years ago
Jack Kamm 7e0777b39a ace-window.el (ace-display-buffer): Add 6 years ago
Oleh Krehel edbbb1b77c ace-window.el (ace-window): Extend doc 6 years ago
  1. 1
      README.md
  2. 64
      ace-window-posframe.el
  3. 67
      ace-window.el

@ -1,5 +1,6 @@
# ace-window
[![GNU ELPA](https://elpa.gnu.org/packages/ace-window.svg)](https://elpa.gnu.org/packages/ace-window.html)
[![MELPA](https://melpa.org/packages/ace-window-badge.svg)](https://melpa.org/#/ace-window)
[![MELPA Stable](https://stable.melpa.org/packages/ace-window-badge.svg)](https://stable.melpa.org/#/ace-window)

@ -0,0 +1,64 @@
;;; ace-window-posframe.el --- posframe support for ace-window -*- lexical-binding: t -*-
;; Copyright (C) 2015-2022 Free Software Foundation, Inc.
(require 'ace-window)
;; Suppress warnings
(declare-function posframe-poshandler-window-center "ext:posframe")
(declare-function posframe-show "ext:posframe")
(declare-function posframe-hide "ext:posframe")
(declare-function posframe-workable-p "ext:posframe")
(defvar aw--posframe-frames '())
(defvar aw-posframe-position-handler #'posframe-poshandler-window-center)
(defun aw--lead-overlay-posframe (path leaf)
(let* ((wnd (cdr leaf))
(str (format "%s" (apply #'string path)))
;; It's important that buffer names are not unique across
;; multiple invocations: posframe becomes very slow when
;; creating new frames, and so being able to reuse old ones
;; makes a huge difference. What defines "able to reuse" is
;; something like: a frame exists which hasn't been deleted
;; (with posframe-delete) and has the same configuration as
;; the requested new frame.
(bufname (format " *aw-posframe-buffer-%s*" path)))
(with-selected-window wnd
(push bufname aw--posframe-frames)
(posframe-show bufname
:string str
:poshandler aw-posframe-position-handler
:font (face-font 'aw-leading-char-face)
:foreground-color (face-foreground 'aw-leading-char-face nil t)
:background-color (face-background 'aw-leading-char-face nil t)))))
(defun aw--remove-leading-chars-posframe ()
;; Hide rather than delete. See aw--lead-overlay-posframe for why.
(mapc #'posframe-hide aw--posframe-frames)
(setq aw--posframe-frames nil))
(defun ace-window-posframe-enable ()
(unless (and (require 'posframe nil t) (posframe-workable-p))
(error "Posframe is not workable"))
(setq aw--lead-overlay-fn #'aw--lead-overlay-posframe)
(setq aw--remove-leading-chars-fn #'aw--remove-leading-chars-posframe))
(defun ace-window-posframe-disable ()
(setq aw--lead-overlay-fn #'aw--lead-overlay)
(setq aw--remove-leading-chars-fn #'aw--remove-leading-chars))
;;;###autoload
(define-minor-mode ace-window-posframe-mode
"Minor mode for showing the ace window key with child frames."
:global t
:require 'ace-window
:group 'ace-window
:init-value nil
(if ace-window-posframe-mode
(ace-window-posframe-enable)
(ace-window-posframe-disable)))
(provide 'ace-window-posframe)

@ -1,12 +1,12 @@
;;; ace-window.el --- Quickly switch windows. -*- lexical-binding: t -*-
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Copyright (C) 2015-2022 Free Software Foundation, Inc.
;; Author: Oleh Krehel <ohwoeowho@gmail.com>
;; Maintainer: Oleh Krehel <ohwoeowho@gmail.com>
;; URL: https://github.com/abo-abo/ace-window
;; Version: 0.9.0
;; Package-Requires: ((avy "0.2.0"))
;; Version: 0.10.0
;; Package-Requires: ((avy "0.5.0"))
;; Keywords: window, location
;; This file is part of GNU Emacs.
@ -168,6 +168,7 @@ Consider changing this if the overlay tends to overlap with other things."
(?b aw-split-window-horz "Split Horz Window")
(?o delete-other-windows "Delete Other Windows")
(?T aw-transpose-frame "Transpose Frame")
;; ?i ?r ?t are used by hyperbole.el
(?? aw-show-dispatch-help))
"List of actions for `aw-dispatch-default'.
Each action is a list of either:
@ -399,13 +400,26 @@ LEAF is (PT . WND)."
(when (/= pt old-pt)
(goto-char (+ pt 1))
(push (cons wnd old-pt) aw--windows-points)))
(overlay-put ol 'display (aw--overlay-str wnd pt path))
(if (window-minibuffer-p wnd)
(overlay-put ol 'face 'aw-minibuffer-leading-char-face)
(overlay-put ol 'face 'aw-leading-char-face))
;; this is where we would need to add a display-margin thingie
(let ((str-margin (concat " " (aw--overlay-str wnd pt path))))
(add-face-text-property 0 (length str-margin) `(:background ,(face-attribute 'default :background)) nil str-margin)
(overlay-put ol 'before-string
(propertize "." 'display
`((margin left-margin)
,(propertize str-margin
'face (if (window-minibuffer-p wnd) 'aw-minibuffer-leading-char-face 'aw-leading-char-face))))))
(overlay-put ol 'window wnd)
(push ol avy--overlays-lead)))))
(defvar aw--lead-overlay-fn #'aw--lead-overlay
"Function used to display the lead chars.")
(defun aw--remove-leading-chars ()
(avy--remove-leading-chars))
(defvar aw--remove-leading-chars-fn #'aw--remove-leading-chars
"Function used to cleanup lead chars.")
(defun aw--make-backgrounds (wnd-list)
"Create a dim background overlay for each window on WND-LIST."
(when aw-background
@ -419,10 +433,6 @@ LEAF is (PT . WND)."
ol))
wnd-list))))
(define-obsolete-variable-alias
'aw-flip-keys 'aw--flip-keys "0.1.0"
"Use `aw-dispatch-alist' instead.")
(defvar aw-dispatch-function 'aw-dispatch-default
"Function to call when a character not in `aw-keys' is pressed.")
@ -569,12 +579,13 @@ Amend MODE-LINE to the mode line for the duration of the selection."
(unwind-protect
(let* ((avy-handler-function aw-dispatch-function)
(avy-translate-char-function aw-translate-char-function)
(transient-mark-mode nil)
(res (avy-read (avy-tree candidate-list aw-keys)
(if (and ace-window-display-mode
(null aw-display-mode-overlay))
(lambda (_path _leaf))
#'aw--lead-overlay)
#'avy--remove-leading-chars)))
aw--lead-overlay-fn)
aw--remove-leading-chars-fn)))
(if (eq res 'exit)
(setq aw-action nil)
(or (cdr res)
@ -613,20 +624,34 @@ Amend MODE-LINE to the mode line for the duration of the selection."
(aw-select " Ace - Delete Other Windows"
#'delete-other-windows))
;;;###autoload
(defun ace-display-buffer (buffer alist)
"Make `display-buffer' and `pop-to-buffer' select using `ace-window'.
See sample config for `display-buffer-base-action' and `display-buffer-alist':
https://github.com/abo-abo/ace-window/wiki/display-buffer."
(let* ((aw-ignore-current (cdr (assq 'inhibit-same-window alist)))
(rf (cdr (assq 'reusable-frames alist)))
(aw-scope (cl-case rf
((nil) 'frame)
(visible 'visible)
((0 t) 'global))))
(unless (or (<= (length (aw-window-list)) 1)
(not aw-scope))
(window--display-buffer
buffer (aw-select "Ace - Display Buffer") 'reuse))))
(declare-function transpose-frame "ext:transpose-frame")
(defun aw-transpose-frame (w)
"Select any window on frame and `tranpose-frame'."
(transpose-frame (window-frame w)))
(define-obsolete-function-alias
'ace-maximize-window 'ace-delete-other-windows "0.10.0")
;;;###autoload
(defun ace-window (arg)
"Select a window.
Perform an action based on ARG described below.
By default, behaves like extended `other-window'.
See `aw-scope' which extends it to work with frames.
Prefixed with one \\[universal-argument], does a swap between the
selected window and the current window, so that the selected
@ -804,10 +829,14 @@ Switch the current window to the previous buffer."
(switch-to-buffer buffer)))
(defun aw-copy-window (window)
"Copy the current buffer to WINDOW."
(let ((buffer (current-buffer)))
"Copy the current buffer to WINDOW - including window-start and point."
(let ((buffer (current-buffer))
(window-start (window-start))
(point (point)))
(aw-switch-to-window window)
(switch-to-buffer buffer)))
(switch-to-buffer buffer)
(set-window-start (frame-selected-window) window-start)
(goto-char point)))
(defun aw-split-window-vert (window)
"Split WINDOW vertically."

Loading…
Cancel
Save