From 5127bfdaaed4e4fc30654cf5e5e78c2044585cb3 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Fri, 18 Jul 2014 10:50:58 +0200 Subject: [PATCH] ace-window.el (aw-generic): finalize improve for hscroll * ace-window.el (aw-offset): New function. The issue with top left part of the window being after the newline, i.e. it can't be written to without modifying the buffer, is fixed by displaying the jump character on the next available line. Fixes #11. --- ace-window.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ace-window.el b/ace-window.el index 26f7d51..a9e2001 100644 --- a/ace-window.el +++ b/ace-window.el @@ -152,8 +152,8 @@ HANDLER is a function that takes a window argument." (with-current-buffer b (insert " ")))) (make-aj-position - :offset (+ (window-start (aj-visual-area-window va)) - (window-hscroll (aj-visual-area-window va))) + :offset + (aw-offset (aj-visual-area-window va)) :visual-area va)) visual-area-list))) ;; create background for each visual area @@ -281,6 +281,23 @@ Windows are numbered top down, left to right." (get-buffer-window (current-buffer)) window)))))) +(defun aw-offset (window) + "Return point in WINDOW that's closest to top left corner. +The point is writable, i.e. it's not part of space after newline." + (let ((h (window-hscroll window)) + (beg (window-start window)) + (end (window-end window))) + (with-current-buffer + (window-buffer window) + (save-excursion + (goto-char beg) + (while (and (< (point) end) + (< (- (line-end-position) + (line-beginning-position)) + h)) + (forward-line)) + (+ (point) h))))) + (provide 'ace-window) ;;; ace-window.el ends here