[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ace-window 702bc27 45/92: Show the overlay in the botto
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ace-window 702bc27 45/92: Show the overlay in the bottom of the window too |
Date: |
Wed, 17 Mar 2021 18:39:19 -0400 (EDT) |
branch: externals/ace-window
commit 702bc2767a173d67bcdf4f082729671162b9bbd8
Author: Wilfred Hughes <Wilfred.Hughes@man.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
Show the overlay in the bottom of the window too
This is useful when point overlaps the overlay at the top of the
window, making it difficult to read the label.
Fixes #129.
Fixes #132.
---
ace-window.el | 86 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 57 insertions(+), 29 deletions(-)
diff --git a/ace-window.el b/ace-window.el
index 1e3d0b1..37a8ee6 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -138,6 +138,13 @@ Its value is a (width . height) pair in pixels or nil for
the default frame size
(0 . 0) is special and means make the frame size the same as the last selected
frame size."
:type '(cons integer integer))
+(defcustom aw-char-position 'top-left
+ "Window positions of the character overlay.
+Consider changing this if the overlay tends to overlap with other things."
+ :type '(choice
+ (const :tag "top left corner only" 'top-left)
+ (const :tag "both left corners" 'left)))
+
;; Must be defined before `aw-make-frame-char' since its :set function
references this.
(defvar aw-dispatch-alist
'((?x aw-delete-window "Delete Window")
@@ -264,6 +271,35 @@ Modify them back eventually.")
(delete-region (point-min) (point-max))))))
(setq aw-empty-buffers-list nil))
+(defun aw--overlay-str (wnd pos path)
+ "Return the replacement text for an overlay in WND at POS,
+accessible by typing PATH."
+ (let ((old-str (or
+ (ignore-errors
+ (with-selected-window wnd
+ (buffer-substring pos (1+ pos))))
+ "")))
+ (concat
+ (cl-case aw-leading-char-style
+ (char
+ (string (avy--key-to-char (car (last path)))))
+ (path
+ (mapconcat
+ (lambda (x) (string (avy--key-to-char x)))
+ (reverse path)
+ ""))
+ (t
+ (error "Bad `aw-leading-char-style': %S"
+ aw-leading-char-style)))
+ (cond ((string-equal old-str "\t")
+ (make-string (1- tab-width) ?\ ))
+ ((string-equal old-str "\n")
+ "\n")
+ (t
+ (make-string
+ (max 0 (1- (string-width old-str)))
+ ?\ ))))))
+
(defun aw--lead-overlay (path leaf)
"Create an overlay using PATH at LEAF.
LEAF is (PT . WND)."
@@ -273,38 +309,30 @@ LEAF is (PT . WND)."
(push (current-buffer) aw-empty-buffers-list)
(let ((inhibit-read-only t))
(insert " ")))
+
(let* ((pt (car leaf))
- (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
- (old-str (or
- (ignore-errors
- (with-selected-window wnd
- (buffer-substring pt (1+ pt))))
- ""))
- (new-str
- (concat
- (cl-case aw-leading-char-style
- (char
- (string (avy--key-to-char (car (last path)))))
- (path
- (mapconcat
- (lambda (x) (string (avy--key-to-char x)))
- (reverse path)
- ""))
- (t
- (error "Bad `aw-leading-char-style': %S"
- aw-leading-char-style)))
- (cond ((string-equal old-str "\t")
- (make-string (1- tab-width) ?\ ))
- ((string-equal old-str "\n")
- "\n")
- (t
- (make-string
- (max 0 (1- (string-width old-str)))
- ?\ ))))))
+ (ol (make-overlay pt (1+ pt) (window-buffer wnd))))
+ (overlay-put ol 'display (aw--overlay-str wnd pt path))
(overlay-put ol 'face 'aw-leading-char-face)
(overlay-put ol 'window wnd)
- (overlay-put ol 'display new-str)
- (push ol avy--overlays-lead)))))
+ (push ol avy--overlays-lead))
+
+ (when (eq aw-char-position 'left)
+ (let* ((pt
+ (save-excursion
+ ;; Move to the start of the last visible line in the buffer.
+ (move-to-window-line -1)
+ (move-beginning-of-line nil)
+ ;; If this line is empty, use the previous line so we
+ ;; have space for the overlay.
+ (when (equal (point) (point-max))
+ (previous-line))
+ (point)))
+ (ol (make-overlay pt (1+ pt) (window-buffer wnd))))
+ (overlay-put ol 'display (aw--overlay-str wnd pt path))
+ (overlay-put ol 'face 'aw-leading-char-face)
+ (overlay-put ol 'window wnd)
+ (push ol avy--overlays-lead))))))
(defun aw--make-backgrounds (wnd-list)
"Create a dim background overlay for each window on WND-LIST."
- [elpa] externals/ace-window 196382b 78/92: ace-window.el (aw-display-mode-overlay): New defcustom, (continued)
- [elpa] externals/ace-window 196382b 78/92: ace-window.el (aw-display-mode-overlay): New defcustom, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window cd82d83 77/92: Use call-interactively if the callee function is a command, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 138a80c 83/92: ace-window.el (aw--lead-overlay): Fix double recenter problem, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 7003c88 91/92: ace-window.el: Bump version, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window d93e16b 48/92: ace-window.el: Fix frame-parameter being a cons sometimes, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 2e3b956 53/92: ace-window.el (aw-ignored-p): Ignore child frames, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window a2f1dd5 61/92: ace-window.el (aw--face-rel-height): Fix for int height, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 88e48db 56/92: ace-window.el: Fix leading char not displayed if the face height isn't 1.0, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window c963bb9 79/92: ace-window.el: Fix compiler warning, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window b93380c 90/92: ace-window.el: Remove obsolete variables, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 702bc27 45/92: Show the overlay in the bottom of the window too,
Stefan Monnier <=
- [elpa] externals/ace-window 746ffd2 52/92: ace-window.el (aw-ignored-buffers): Clean up doc, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 2307fd1 64/92: ace-window.el (aw-dispatch-alist): Don't bind anything on home row, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 379413c 60/92: ace-window.el (aw-offset): Update, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 9ca16c6 62/92: Fix aw-switch-buffer-other-window bug, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 58463b4 67/92: ace-window.el (aw-select): Fix when selecting from an ignored window, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window d0a5559 66/92: ace-window.el (ace-window): M-0 should not modify aw-ignore-on permanently, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window d20bd7c 59/92: ace-window.el (aw-delete-window): Add optional kill-buffer arg, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 706f24e 69/92: Fix typo, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window fc0d19c 80/92: ace-window.el (aw-select): Fix, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 27bb0b7 81/92: test/elpa.el: Put .elpa in ~ instead of the current directory, Stefan Monnier, 2021/03/17