Add: app/irc: scroll to bottom on any input

more generalized which allows this to work for Emacs mode or for pastes.

Code inspired and adapted by eshell.
This commit is contained in:
Benjamin Andresen 2017-07-20 22:55:34 +02:00 committed by Henrik Lissner
parent 757a149064
commit 6fb8d0164b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -3,6 +3,10 @@
(defvar +irc-left-padding 13
"TODO")
(defvar +irc-scroll-to-bottom-on-commands
'(self-insert-command yank hilit-yank)
"If these commands are called pre prompt the buffer will scroll to `point-max'.")
(defvar +irc-disconnect-hook nil
"TODO")
@ -152,7 +156,30 @@ after prompt marker."
(goto-char (point-max))))
(add-hook! 'lui-mode-hook
(add-hook 'evil-insert-state-entry-hook #'+irc|evil-insert nil t)))
(add-hook 'evil-insert-state-entry-hook #'+irc|evil-insert nil t))
(mapc (lambda (cmd) (cl-pushnew cmd +irc-scroll-to-bottom-on-commands))
'(evil-paste-after evil-paste-before evil-open-above evil-open-below)))
(defun +irc|preinput-scroll-to-bottom ()
"Go to the end of the buffer in all windows showing it.
Courtesy of esh-mode.el"
(when (memq this-command +irc-scroll-to-bottom-on-commands)
(let* ((selected (selected-window))
(current (current-buffer)))
(when (> (marker-position lui-input-marker) (point))
(walk-windows
(function
(lambda (window)
(when (eq (window-buffer window) current)
(select-window window)
(goto-char (point-max))
(select-window selected))))
nil t)))))
(add-hook! 'lui-mode-hook
(add-hook 'pre-command-hook #'+irc|preinput-scroll-to-bottom nil t))
(defun +irc|init-lui-margins ()
(setq lui-time-stamp-position 'right-margin