diff --git jabber-chatbuffer el jabber-chatbuffer el index d0a4628 ac1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
diff --git a/jabber-chatbuffer.el b/jabber-chatbuffer.el
index d0a4628..ac11d3a 100644
--- a/jabber-chatbuffer.el
+++ b/jabber-chatbuffer.el
@@ -38,6 +38,11 @@ window or at `fill-column', whichever is shorter."
:group 'jabber-chat
:type 'boolean)
+(defcustom jabber-scroll-to-bottom-p t
+ "Non-nil to keep input line at the end of the window."
+ :type 'boolean
+ :group 'jabber-chat)
+
(defvar jabber-chat-ewoc nil
"The ewoc showing the messages of this chat buffer.")
@@ -76,6 +81,10 @@ window or at `fill-column', whichever is shorter."
mode-name "jabber-chat")
(use-local-map jabber-chat-mode-map)
+ (add-hook 'window-scroll-functions
+ 'jabber-scroll-to-bottom
+ nil t)
+
(if (fboundp 'run-mode-hooks)
(run-mode-hooks 'jabber-chat-mode-hook)
(run-hooks 'jabber-chat-mode-hook)))
@@ -133,5 +142,26 @@ window or at `fill-column', whichever is shorter."
(widen))
(forward-line 1)))))))
+(defun jabber-scroll-to-bottom (window display-start)
+ "Scroll the input line to the bottom of the window."
+ (when (and window
+ (window-live-p window)
+ jabber-scroll-to-bottom-p)
+ (let ((resize-mini-windows nil))
+ ;; This is to prevent an XEmacs byte compilation warning
+ ;; "variable bound but not referred to". XEmacs is trying to be
+ ;; too intelligent.
+ (when (featurep 'xemacs)
+ (declare (special resize-mini-windows)))
+ (save-selected-window
+ (select-window window)
+ (save-restriction
+ (widen)
+ (when (>= (point) jabber-point-insert)
+ (save-excursion
+ (goto-char (point-max))
+ (recenter -1)
+ (sit-for 0))))))))
+
(provide 'jabber-chatbuffer)
;; arch-tag: 917e5b60-5894-4c49-b3bc-12e1f97ffdc6