[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b703766: Ensure that the prompt is kept on the fina
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master b703766: Ensure that the prompt is kept on the final line |
Date: |
Wed, 23 Oct 2019 05:55:24 -0400 (EDT) |
branch: master
commit b7037662e1111d55218fb2345f9ebb9ed3ebef13
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Ensure that the prompt is kept on the final line
* lisp/erc/erc-goodies.el (erc-possibly-scroll-to-bottom): New
function.
(scrolltobottom): Add to erc-insert-done-hook.
* lisp/erc/erc.el (erc-insert-done-hook): New hook (bug#11697).
(erc-display-line-1): Use it.
---
etc/NEWS | 7 +++++++
lisp/erc/erc-goodies.el | 7 +++++++
lisp/erc/erc.el | 9 +++++++++
3 files changed, 23 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index 43411b7..01fdf39 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1234,6 +1234,13 @@ fail.
** erc
---
+*** New hook 'erc-insert-done-hook'.
+This hook is called after strings have been inserted into the buffer,
+and is free to alter point and window configurations, as it's not
+called from inside a 'save-excursion', as opposed to
+'erc-insert-post-hook'.
+
+---
*** 'erc-button-google-url' has been renamed to 'erc-button-search-url'
and its value has been changed to Duck Duck Go.
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 5e79468..b08970d 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -55,14 +55,21 @@ argument to `recenter'."
(define-erc-module scrolltobottom nil
"This mode causes the prompt to stay at the end of the window."
((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
+ (add-hook 'erc-insert-done-hook 'erc-possibly-scroll-to-bottom)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer
(erc-add-scroll-to-bottom))))
((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom)
+ (remove-hook 'erc-insert-done-hook 'erc-possibly-scroll-to-bottom)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer
(remove-hook 'post-command-hook 'erc-scroll-to-bottom t)))))
+(defun erc-possibly-scroll-to-bottom ()
+ "Like `erc-add-scroll-to-bottom', but only if window is selected."
+ (when (eq (selected-window) (get-buffer-window))
+ (erc-scroll-to-bottom)))
+
(defun erc-add-scroll-to-bottom ()
"A hook function for `erc-mode-hook' to recenter output at bottom of window.
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 86f103e..1c5ecf9 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1097,6 +1097,14 @@ At this point, all modifications from prior hook
functions are done."
erc-make-read-only
erc-save-buffer-in-logs))
+(defcustom erc-insert-done-hook nil
+ "This hook is called after inserting strings into the buffer.
+This hook is not called from inside `save-excursion' and should
+preserve point if needed."
+ :group 'erc-hooks
+ :version "27.1"
+ :type 'hook)
+
(defcustom erc-send-modify-hook nil
"Sending hook for functions that will change the text's appearance.
This hook is called just after `erc-send-pre-hook' when the values
@@ -2419,6 +2427,7 @@ If STRING is nil, the function does nothing."
(when erc-remove-parsed-property
(remove-text-properties (point-min) (point-max)
'(erc-parsed nil))))))))
+ (run-hooks 'erc-insert-done-hook)
(erc-update-undo-list (- (or (marker-position erc-insert-marker)
(point-max))
insert-position))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b703766: Ensure that the prompt is kept on the final line,
Lars Ingebrigtsen <=