From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.bugs 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 Organization: EUR Message-ID: <87pq1z7zm7.fsf_-_@gmail.com> References: <87a9t7bl8o.fsf@gmail.com> <50D47143.40702@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1356394785 26614 80.91.229.3 (25 Dec 2012 00:19:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Dec 2012 00:19:45 +0000 (UTC) Cc: 13248@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 25 01:20:00 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TnIFR-0008Oa-Uc for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Dec 2012 01:19:58 +0100 Original-Received: from localhost ([::1]:35540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnIFD-0001bl-8n for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Dec 2012 19:19:43 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnIF3-0001bP-AW for bug-gnu-emacs@gnu.org; Mon, 24 Dec 2012 19:19:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TnIF0-0006ma-Dc for bug-gnu-emacs@gnu.org; Mon, 24 Dec 2012 19:19:33 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnIF0-0006lw-9m for bug-gnu-emacs@gnu.org; Mon, 24 Dec 2012 19:19:30 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TnIFW-0001PN-Qj for bug-gnu-emacs@gnu.org; Mon, 24 Dec 2012 19:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vitalie Spinu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Dec 2012 00:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13248 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13248-submit@debbugs.gnu.org id=B13248.13563947785369 (code B ref 13248); Tue, 25 Dec 2012 00:20:02 +0000 Original-Received: (at 13248) by debbugs.gnu.org; 25 Dec 2012 00:19:38 +0000 Original-Received: from localhost ([127.0.0.1]:58527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TnIF7-0001OX-Rf for submit@debbugs.gnu.org; Mon, 24 Dec 2012 19:19:38 -0500 Original-Received: from mail-we0-f176.google.com ([74.125.82.176]:55986) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TnIF3-0001ON-GF for 13248@debbugs.gnu.org; Mon, 24 Dec 2012 19:19:35 -0500 Original-Received: by mail-we0-f176.google.com with SMTP id r5so3360322wey.21 for <13248@debbugs.gnu.org>; Mon, 24 Dec 2012 16:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version:content-type; bh=I1+s6FCVas49lKYwh+jLiMYzfx3HDaFM66g8fBGbOJU=; b=gjmeaHDwvDVXwhhCoLsjWwoMS22ohx3mgOSng840LDAX9jifJbXBDTXu+49x4XCVIC fyyeMe8zWgcPxyPKuhNTiY/OnzPSYWJkOZhLabIwOY4ywLAR8bfRuK2pepkT++PtQIrz P4YwAAbcEVnRYOkEozl4CAn2BA8PaxzwSfznKpMmmoeiLj5m2r7EUP9KE53ObS8omWxa tObnZe/pc/LJEIMM7/gE9SOgCG8r0pI+bYNtq4ge7ChbVujsFXM7oBqGAN81dzEoEBCO RoTOvafnMzqyQepwzVFre0kgZzpAHufDMcJrPcJk1rir6HeyDUaFk7IORgaWP3v9N+V8 q1XQ== X-Received: by 10.180.72.146 with SMTP id d18mr28872539wiv.33.1356394739496; Mon, 24 Dec 2012 16:18:59 -0800 (PST) Original-Received: from localhost (i108036.upc-i.chello.nl. [62.195.108.36]) by mx.google.com with ESMTPS id bd7sm35876165wib.8.2012.12.24.16.18.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Dec 2012 16:18:58 -0800 (PST) In-Reply-To: <50D47143.40702@gmx.at> (martin rudalics's message of "Fri, 21 Dec 2012 15:25:07 +0100") User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69021 Archived-At: --=-=-= Content-Type: text/plain >> martin rudalics >> 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=comint-fix.patch 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 + + * comint.el (comint-postoutput-scroll-to-bottom): Don't reset + buffer point on select-window (Bug#13248). + 2012-12-24 Dmitry Gutov * 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) --=-=-=--