[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13248: [PATCH] bug#13248: 24.2.50; select-window moves point (in com
From: |
Vitalie Spinu |
Subject: |
bug#13248: [PATCH] bug#13248: 24.2.50; select-window moves point (in comint-postoutput-scroll-to-bottom) |
Date: |
Tue, 25 Dec 2012 01:18:56 +0100 |
User-agent: |
Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.2.50 (gnu/linux) |
>> martin rudalics <rudalics@gmx.at>
>> on Fri, 21 Dec 2012 15:25:07 +0100 wrote:
[...]
>> So the point is clearly moved in select-window. Moreover the (point)
>> equals (window-end) just before select-window is called, so it is
>> visible. Consequently, the following (comint-adjust-point selected) is
>> completely screwed because it relies on point *not* being moved!
[...]
>>
>> The variable `comint-scroll-show-maximum-output' is the default t, this
>> is why comint runs `comint-postoutput-scroll-to-bottom' in its
>> `comint-output-filter-functions'.
>>
>> I can propose a patch for commit to reset the point,
[...]
Here is a patch of the comint-postoutput-scroll-to-bottom to circumvent
resetting the point on select-window.
Thanks,
Vitalie
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6d5e77d..dc5a4be 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-24 Vitalie Spinu <spinuvit@gmail.com>
+
+ * comint.el (comint-postoutput-scroll-to-bottom): Don't reset
+ buffer point on select-window (Bug#13248).
+
2012-12-24 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el: Bump the version to 1.2 (Bug#13200).
diff --git a/lisp/comint.el b/lisp/comint.el
index cff9afe..fa3764d 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -2120,12 +2120,14 @@ This function should be in the list
`comint-output-filter-functions'."
((bound-and-true-p follow-mode)
(follow-comint-scroll-to-bottom))
(t
- (let ((selected (selected-window)))
+ (let ((selected (selected-window))
+ ;; select-window resets point; thus, save
+ (old-point (point)))
(dolist (w (get-buffer-window-list current nil t))
(select-window w)
(unwind-protect
(progn
- (comint-adjust-point selected)
+ (comint-adjust-point selected old-point)
;; Optionally scroll to the bottom of the window.
(and comint-scroll-show-maximum-output
(eobp)
@@ -2133,9 +2135,12 @@ This function should be in the list
`comint-output-filter-functions'."
(select-window selected))))))
(set-buffer current))))
-(defun comint-adjust-point (selected)
+(defun comint-adjust-point (selected &optional saved-point)
"Move point in the selected window based on Comint settings.
-SELECTED is the window that was originally selected."
+SELECTED is the window that was originally selected.
+
+If SAVED-POINT is given, use it as reference instead of the
+current point."
(let ((process (get-buffer-process (current-buffer))))
(and (< (point) (process-mark process))
(or (memq comint-move-point-for-output '(t all))
@@ -2144,7 +2149,8 @@ SELECTED is the window that was originally selected."
(if (eq (selected-window) selected) 'this 'others))
;; If point was at the end, keep it at end.
(and (marker-position comint-last-output-start)
- (>= (point) comint-last-output-start)))
+ (>= (or saved-point (point))
+ comint-last-output-start)))
(goto-char (process-mark process)))))
(defun comint-truncate-buffer (&optional _string)