[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/coterm 8f0a13b 44/80: Refactor scroll snapping, snap in
From: |
ELPA Syncer |
Subject: |
[elpa] externals/coterm 8f0a13b 44/80: Refactor scroll snapping, snap in all windows |
Date: |
Wed, 13 Oct 2021 18:57:33 -0400 (EDT) |
branch: externals/coterm
commit 8f0a13bca7084d9c444791ad973fb1d1b617be6e
Author: m <>
Commit: m <>
Refactor scroll snapping, snap in all windows
---
coterm.el | 57 ++++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 15 deletions(-)
diff --git a/coterm.el b/coterm.el
index 902035b..c835605 100644
--- a/coterm.el
+++ b/coterm.el
@@ -111,16 +111,45 @@ Usually enabled for full-screen terminal programs to keep
them on
screen."
:keymap nil
(if coterm-scroll-snap-mode
- (unless coterm--char-old-scroll-margin
- (setq coterm--char-old-scroll-margin
- (cons scroll-margin
- (local-variable-p 'scroll-margin)))
- (setq-local scroll-margin 0))
+ (progn
+ (unless coterm--char-old-scroll-margin
+ (setq coterm--char-old-scroll-margin
+ (cons scroll-margin
+ (local-variable-p 'scroll-margin)))
+ (setq-local scroll-margin 0))
+ (add-hook 'coterm-t-after-insert-hook #'coterm--scroll-snap nil t))
(when-let ((margin coterm--char-old-scroll-margin))
(setq coterm--char-old-scroll-margin nil)
(if (cdr margin)
(setq scroll-margin (car margin))
- (kill-local-variable 'scroll-margin)))))
+ (kill-local-variable 'scroll-margin)))
+ (remove-hook 'coterm-t-after-insert-hook #'coterm--scroll-snap t)))
+
+(defun coterm--scroll-snap ()
+ (let* ((buf (current-buffer))
+ (pmark (process-mark (get-buffer-process buf)))
+ (sel-win (selected-window))
+ (w sel-win))
+ ;; Avoid infinite loop in strange case where minibuffer window
+ ;; is selected but not active.
+ (while (window-minibuffer-p w)
+ (setq w (next-window w nil t)))
+ (while
+ (progn
+ (when (and (eq buf (window-buffer w))
+ ;; Only snap if point is on pmark
+ (= (window-point w) pmark))
+ (if (eq sel-win w)
+ (progn
+ (coterm--t-goto 0 0)
+ (recenter 0)
+ (goto-char pmark))
+ (with-selected-window w
+ (coterm--t-goto 0 0)
+ (recenter 0)
+ (goto-char pmark))))
+ (setq w (next-window w nil t))
+ (not (eq w sel-win))))))
;;; Terminal emulation
@@ -178,6 +207,9 @@ In sync with variables `coterm--t-home-marker',
(defvar-local coterm--t-insert-mode nil)
(defvar-local coterm--t-unhandled-fragment nil)
+(defvar coterm-t-after-insert-hook nil
+ "Hook run after inserting process output.")
+
(defun coterm--comint-strip-CR (_)
"Remove all \\r characters from last output."
(save-excursion
@@ -690,14 +722,7 @@ If `coterm--t-home-marker' is nil, initialize it sensibly."
(goto-char pmark)
(skip-chars-forward " \n")
(when (eobp)
- (delete-region pmark (point)))
-
- ;; Scroll window, but only if selected and if point is on pmark
- (when (and coterm-scroll-snap-mode
- (= restore-point pmark)
- (eq buf (window-buffer (selected-window))))
- (coterm--t-goto 0 0)
- (recenter 0)))
+ (delete-region pmark (point))))
;; Restore point (this restores it only for the selected window)
(goto-char restore-point)
@@ -717,7 +742,9 @@ If `coterm--t-home-marker' is nil, initialize it sensibly."
(= (window-point w) old-pmark)
(set-window-point w pmark))
(setq w (next-window w nil t)))
- (set-marker old-pmark nil)))))))
+ (set-marker old-pmark nil))
+
+ (run-hooks 'coterm-t-after-insert-hook))))))
(provide 'coterm)
;;; coterm.el ends here
- [elpa] externals/coterm bd103f9 56/80: [auto-char] Fix searching in less, (continued)
- [elpa] externals/coterm bd103f9 56/80: [auto-char] Fix searching in less, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm d5042f6 65/80: Inhibit Emacs from automatically decoding \r\n into \n, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 90823af 77/80: Revert "Inhibit Emacs from automatically decoding \r\n into \n", ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 066cd45 70/80: Explain how coterm does/doesn't do line-wrapping, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 08208f3 33/80: Handle \r\n sequence properly, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm f334168 24/80: Rename function, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 8b2836e 28/80: Fix incorrect handling of incomplete escape sequences, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 1ec97d2 29/80: \n doesn't go to column 0, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 9184a46 34/80: Always synchronize pmark at the end, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm e64027a 43/80: Restore 'window-point' of non-selected windows, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 8f0a13b 44/80: Refactor scroll snapping, snap in all windows,
ELPA Syncer <=
- [elpa] externals/coterm dc5f8db 38/80: Improve doc string, add autoload cookie, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm ee37b4b 39/80: Initial support for char-mode and scroll snapping, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 6f42ba6 45/80: Initialize home marker properly, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 5e40af4 47/80: Prevent modification of user input harder, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm dc9466e 57/80: Implement \t (move cursor to tab stop), needed for "emacs -nw", ELPA Syncer, 2021/10/13
- [elpa] externals/coterm db17a99 62/80: Describe terminal emulation, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c52f413 67/80: Keep char mode in less after pressing a digit, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c717c84 75/80: Bind inhibit-read-only to t for terminal emulation, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm 570ae6d 74/80: Mention auto char mode as a difference from term.el, ELPA Syncer, 2021/10/13
- [elpa] externals/coterm c825746 27/80: Fix issue with ansi-color context marker, ELPA Syncer, 2021/10/13