[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ace-window ac89475 73/92: Fix handling of horizontally
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ace-window ac89475 73/92: Fix handling of horizontally scrolled windows and buffer-begin error |
Date: |
Wed, 17 Mar 2021 18:39:25 -0400 (EDT) |
branch: externals/ace-window
commit ac89475dcb9eac40fe0a6b1c7da58c506abe8718
Author: Bob Weiner <rsw@gnu.org>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
Fix handling of horizontally scrolled windows and buffer-begin error
Re #78
Fixes #142
Fixes #166
Fixes #168
---
ace-window.el | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 8 deletions(-)
diff --git a/ace-window.el b/ace-window.el
index 2753c19..458a300 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -268,6 +268,10 @@ or
"Store the read-only empty buffers which had to be modified.
Modify them back eventually.")
+(defvar aw--windows-hscroll nil
+ "List of (window . hscroll-columns) items, each listing a window whose
+ horizontal scroll will be restored upon ace-window action completion.")
+
(defun aw--done ()
"Clean up mode line and overlays."
;; mode line
@@ -281,8 +285,20 @@ Modify them back eventually.")
(when (string= (buffer-string) " ")
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))))))
+ (aw--restore-windows-hscroll)
(setq aw-empty-buffers-list nil))
+(defun aw--restore-windows-hscroll ()
+ "Restore horizontal scroll of windows from `aw--windows-hscroll' list."
+ (let (wnd hscroll)
+ (mapc (lambda (wnd-and-hscroll)
+ (setq wnd (car wnd-and-hscroll)
+ hscroll (cdr wnd-and-hscroll))
+ (when (window-live-p wnd)
+ (set-window-hscroll wnd hscroll)))
+ aw--windows-hscroll))
+ (setq aw--windows-hscroll nil))
+
(defun aw--overlay-str (wnd pos path)
"Return the replacement text for an overlay in WND at POS,
accessible by typing PATH."
@@ -312,18 +328,35 @@ accessible by typing PATH."
(max 0 (1- (string-width old-str)))
?\ ))))))
+(defun aw--point-visible-p ()
+ "Return non-nil if point is visible in the selected window, else nil when
horizontal scrolling has moved it off screen."
+ (and (>= (- (current-column) (window-hscroll)) 0)
+ (< (- (current-column) (window-hscroll))
+ (window-width))))
+
(defun aw--lead-overlay (path leaf)
"Create an overlay using PATH at LEAF.
LEAF is (PT . WND)."
;; Properly adds overlay in visible region of most windows except for any one
;; receiving output while this function is executing, since that moves point,
;; potentially shifting the added overlay outside the window's visible
region.
- (let ((wnd (cdr leaf)))
+ (let ((wnd (cdr leaf))
+ ;; Prevent temporary movement of point from scrolling any window.
+ (scroll-margin 0))
(with-selected-window wnd
(when (= 0 (buffer-size))
(push (current-buffer) aw-empty-buffers-list)
(let ((inhibit-read-only t))
(insert " ")))
+ ;; If point is not visible due to horizontal scrolling of the
+ ;; window, this next expression temporarily scrolls the window
+ ;; right until point is visible, so that the leading-char can be
+ ;; seen when it is inserted. When ace-window's action finishes,
+ ;; the horizontal scroll is restored by (aw--done).
+ (while (and (not (aw--point-visible-p))
+ (not (zerop (window-hscroll)))
+ (progn (push (cons (selected-window) (window-hscroll))
aw--windows-hscroll) t)
+ (not (zerop (scroll-right)))))
(let* ((prev)
(vertical-pos (if (eq aw-char-position 'left) -1 0))
(horizontal-pos (if (zerop (window-hscroll)) 0 (1+
(window-hscroll))))
@@ -340,7 +373,7 @@ LEAF is (PT . WND)."
(while (and (/= prev (point)) (eolp))
(setq prev (point))
(unless (bobp)
- (line-move -1 nil)
+ (line-move -1 t)
(move-to-column horizontal-pos)))
(recenter vertical-pos)
(point)))
@@ -564,6 +597,7 @@ selected window).
Prefixed with two \\[universal-argument]'s, deletes the selected
window."
(interactive "p")
+ (setq avy-current-path "")
(cl-case arg
(0
(let ((aw-ignore-on (not aw-ignore-on)))
@@ -588,12 +622,12 @@ window."
This is determined by their respective window coordinates.
Windows are numbered top down, left to right."
(let* ((f1 (window-frame wnd1))
- (f2 (window-frame wnd2))
- (e1 (window-edges wnd1))
- (e2 (window-edges wnd2))
- (p1 (frame-position f1))
- (p2 (frame-position f2))
- (nl (or (null (car p1)) (null (car p2)))))
+ (f2 (window-frame wnd2))
+ (e1 (window-edges wnd1))
+ (e2 (window-edges wnd2))
+ (p1 (frame-position f1))
+ (p2 (frame-position f2))
+ (nl (or (null (car p1)) (null (car p2)))))
(cond ((and (not nl) (< (car p1) (car p2)))
(not aw-reverse-frame-list))
((and (not nl) (> (car p1) (car p2)))
- [elpa] externals/ace-window 94986cb 65/92: ace-window.el (aw-ignored-p): Don't ignore window if it's selected, (continued)
- [elpa] externals/ace-window 94986cb 65/92: ace-window.el (aw-ignored-p): Don't ignore window if it's selected, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 2d132ba 75/92: ace-window.el (aw-transpose-frame): Add and bind to "t", Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window a534492 85/92: ace-window.el (aw-minibuffer-leading-char-face): New face, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 15b0639 34/92: ace-window.el (aw-make-frame-char): New defcustom, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window d4066b1 44/92: Revert "Make window ordering rely on frame position", Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 3fe86fb 51/92: Update the name of the LV buffer, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window bd48027 54/92: ace-window.el (aw-ignored-p): Only call frame-parent if defined, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 21fb8ab 58/92: ace-window.el (aw--after-make-frame): Extract, add make-frame-visible, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window d7bdb53 70/92: Make aw-make-frame disable-able, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window a429c66 72/92: ace-window.el (aw--lead-overlay): Handle windhow hscroll better, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window ac89475 73/92: Fix handling of horizontally scrolled windows and buffer-begin error,
Stefan Monnier <=
- [elpa] externals/ace-window a3ad48f 74/92: ace-window.el (aw--point-visible-p): Prettify doc, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 091150b 84/92: .github/FUNDING.yml: Add, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window 301c762 76/92: ace-window.el (aw-transpose-frame): Move to "T" binding, Stefan Monnier, 2021/03/17
- [elpa] externals/ace-window a36c147 88/92: ace-window.el (aw-dispatch-alist): Add hyperbole comment, Stefan Monnier, 2021/03/17