diff options
| author | Lars Ingebrigtsen | 2019-10-23 11:55:13 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-23 11:55:13 +0200 |
| commit | b7037662e1111d55218fb2345f9ebb9ed3ebef13 (patch) | |
| tree | 6121349d6b192260c84088d799549dc897b38d29 | |
| parent | 496202d00ead9cdb649443f831e3cc8dfcf6aadd (diff) | |
| download | emacs-b7037662e1111d55218fb2345f9ebb9ed3ebef13.tar.gz emacs-b7037662e1111d55218fb2345f9ebb9ed3ebef13.zip | |
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.
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/erc/erc-goodies.el | 7 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 9 |
3 files changed, 23 insertions, 0 deletions
| @@ -1234,6 +1234,13 @@ fail. | |||
| 1234 | ** erc | 1234 | ** erc |
| 1235 | 1235 | ||
| 1236 | --- | 1236 | --- |
| 1237 | *** New hook 'erc-insert-done-hook'. | ||
| 1238 | This hook is called after strings have been inserted into the buffer, | ||
| 1239 | and is free to alter point and window configurations, as it's not | ||
| 1240 | called from inside a 'save-excursion', as opposed to | ||
| 1241 | 'erc-insert-post-hook'. | ||
| 1242 | |||
| 1243 | --- | ||
| 1237 | *** 'erc-button-google-url' has been renamed to 'erc-button-search-url' | 1244 | *** 'erc-button-google-url' has been renamed to 'erc-button-search-url' |
| 1238 | and its value has been changed to Duck Duck Go. | 1245 | and its value has been changed to Duck Duck Go. |
| 1239 | 1246 | ||
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 5e7946810be..b08970d2585 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el | |||
| @@ -55,14 +55,21 @@ argument to `recenter'." | |||
| 55 | (define-erc-module scrolltobottom nil | 55 | (define-erc-module scrolltobottom nil |
| 56 | "This mode causes the prompt to stay at the end of the window." | 56 | "This mode causes the prompt to stay at the end of the window." |
| 57 | ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) | 57 | ((add-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) |
| 58 | (add-hook 'erc-insert-done-hook 'erc-possibly-scroll-to-bottom) | ||
| 58 | (dolist (buffer (erc-buffer-list)) | 59 | (dolist (buffer (erc-buffer-list)) |
| 59 | (with-current-buffer buffer | 60 | (with-current-buffer buffer |
| 60 | (erc-add-scroll-to-bottom)))) | 61 | (erc-add-scroll-to-bottom)))) |
| 61 | ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) | 62 | ((remove-hook 'erc-mode-hook 'erc-add-scroll-to-bottom) |
| 63 | (remove-hook 'erc-insert-done-hook 'erc-possibly-scroll-to-bottom) | ||
| 62 | (dolist (buffer (erc-buffer-list)) | 64 | (dolist (buffer (erc-buffer-list)) |
| 63 | (with-current-buffer buffer | 65 | (with-current-buffer buffer |
| 64 | (remove-hook 'post-command-hook 'erc-scroll-to-bottom t))))) | 66 | (remove-hook 'post-command-hook 'erc-scroll-to-bottom t))))) |
| 65 | 67 | ||
| 68 | (defun erc-possibly-scroll-to-bottom () | ||
| 69 | "Like `erc-add-scroll-to-bottom', but only if window is selected." | ||
| 70 | (when (eq (selected-window) (get-buffer-window)) | ||
| 71 | (erc-scroll-to-bottom))) | ||
| 72 | |||
| 66 | (defun erc-add-scroll-to-bottom () | 73 | (defun erc-add-scroll-to-bottom () |
| 67 | "A hook function for `erc-mode-hook' to recenter output at bottom of window. | 74 | "A hook function for `erc-mode-hook' to recenter output at bottom of window. |
| 68 | 75 | ||
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 86f103ef231..1c5ecf99c6b 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." | |||
| 1097 | erc-make-read-only | 1097 | erc-make-read-only |
| 1098 | erc-save-buffer-in-logs)) | 1098 | erc-save-buffer-in-logs)) |
| 1099 | 1099 | ||
| 1100 | (defcustom erc-insert-done-hook nil | ||
| 1101 | "This hook is called after inserting strings into the buffer. | ||
| 1102 | This hook is not called from inside `save-excursion' and should | ||
| 1103 | preserve point if needed." | ||
| 1104 | :group 'erc-hooks | ||
| 1105 | :version "27.1" | ||
| 1106 | :type 'hook) | ||
| 1107 | |||
| 1100 | (defcustom erc-send-modify-hook nil | 1108 | (defcustom erc-send-modify-hook nil |
| 1101 | "Sending hook for functions that will change the text's appearance. | 1109 | "Sending hook for functions that will change the text's appearance. |
| 1102 | This hook is called just after `erc-send-pre-hook' when the values | 1110 | 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." | |||
| 2419 | (when erc-remove-parsed-property | 2427 | (when erc-remove-parsed-property |
| 2420 | (remove-text-properties (point-min) (point-max) | 2428 | (remove-text-properties (point-min) (point-max) |
| 2421 | '(erc-parsed nil)))))))) | 2429 | '(erc-parsed nil)))))))) |
| 2430 | (run-hooks 'erc-insert-done-hook) | ||
| 2422 | (erc-update-undo-list (- (or (marker-position erc-insert-marker) | 2431 | (erc-update-undo-list (- (or (marker-position erc-insert-marker) |
| 2423 | (point-max)) | 2432 | (point-max)) |
| 2424 | insert-position)))))) | 2433 | insert-position)))))) |