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 23:28:56 +0100 Organization: EUR Message-ID: <87fw2t22c7.fsf@gmail.com> References: <87a9t7bl8o.fsf@gmail.com> <50D47143.40702@gmx.at> <87pq1z7zm7.fsf_-_@gmail.com> <50D9EBE2.5050609@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1356474573 26703 80.91.229.3 (25 Dec 2012 22:29:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Dec 2012 22:29:33 +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 23:29:48 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 1Tnd0N-0007kk-8P for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Dec 2012 23:29:47 +0100 Original-Received: from localhost ([::1]:35399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tnd08-0003Uo-Vm for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Dec 2012 17:29:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tnd03-0003Uc-WF for bug-gnu-emacs@gnu.org; Tue, 25 Dec 2012 17:29:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tnd01-0001BQ-5W for bug-gnu-emacs@gnu.org; Tue, 25 Dec 2012 17:29:27 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tnd01-0001BL-0r for bug-gnu-emacs@gnu.org; Tue, 25 Dec 2012 17:29:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Tnd0c-0004Zh-HB for bug-gnu-emacs@gnu.org; Tue, 25 Dec 2012 17:30: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 22:30: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.135647458217532 (code B ref 13248); Tue, 25 Dec 2012 22:30:02 +0000 Original-Received: (at 13248) by debbugs.gnu.org; 25 Dec 2012 22:29:42 +0000 Original-Received: from localhost ([127.0.0.1]:59704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tnd0H-0004Yj-FN for submit@debbugs.gnu.org; Tue, 25 Dec 2012 17:29:41 -0500 Original-Received: from mail-wi0-f172.google.com ([209.85.212.172]:57156) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tnd0E-0004Yb-TB for 13248@debbugs.gnu.org; Tue, 25 Dec 2012 17:29:40 -0500 Original-Received: by mail-wi0-f172.google.com with SMTP id o1so6849496wic.5 for <13248@debbugs.gnu.org>; Tue, 25 Dec 2012 14:29:00 -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=bBIhkgdzG/58Q4A0fFrVqjK5+dpVJdGV1nqCYCke8cM=; b=pIJy8XPv4bo5jcMcfzzfY7KiNcFd0JDz/jHI7n7G4mr/IgcnadHpfmgQTVjcowWL8t 4Qvv0zRpY/+qJ0vQe5EreOTYFJ+4iGTvinNAMysqqdMIk17d753suaaewNLch7zTrJwP Hroz65+84js2o82wzFB400+shrVTHpezE8O6tOps1DFRnybeVpPjbfIWfkONFfeWfd37 6OEmFBiC4V7p0Coy6pXPw45uz6slwKyJBm/iSNLKWEZUMlneIlgLLoLtTKgrJ3x6qT/z ufskdmy0LSa+g5RGbJvn3RrF/zKL5Z2Ct/CKZV6Z7eSMCT8oOHvC77NEzgXb16P0npgs ZgeA== X-Received: by 10.194.93.40 with SMTP id cr8mr41448180wjb.16.1356474540022; Tue, 25 Dec 2012 14:29:00 -0800 (PST) Original-Received: from localhost (i108036.upc-i.chello.nl. [62.195.108.36]) by mx.google.com with ESMTPS id dw4sm40919180wib.1.2012.12.25.14.28.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Dec 2012 14:28:58 -0800 (PST) In-Reply-To: <50D9EBE2.5050609@gmx.at> (martin rudalics's message of "Tue, 25 Dec 2012 19:09:38 +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:69046 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> martin rudalics >> on Tue, 25 Dec 2012 19:09:38 +0100 wrote: >> Here is a patch of the comint-postoutput-scroll-to-bottom to circumvent >> resetting the point on select-window. > I'm too silly to understand what this is supposed to do. But the > doc-string of `comint-adjust-point' says "Move point in the selected > window based on Comint settings." which, together with the fact that you > call this in a loop over all windows showing some buffer, indicates to > use `set-window-point' rather than `goto-char'.=20=20 It is indeed tricky, I also was bothered by goto-char intricacy, but decided not to intrude too much. > So why can't you write something like > (dolist (w (get-buffer-window-list current nil t)) > (when (and (< (window-point) (process-mark process)) > ...) > (set-window-point w ...))) > here? Because of the recentering in this piece:=20 =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2132 =E2=94=80 /home/vitoshka/TVC/emacs/lisp/comint.el =E2=94=80=E2= =94=80 =E2=94=82 (and comint-scroll-show-maximum-output =E2=94=82 (eobp) =E2=94=82 (recenter (- -1 scroll-margin)))) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2134 =E2=94=80 And this code: =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2140 =E2=94=80 /home/vitoshka/TVC/emacs/lisp/comint.el =E2=94=80=E2= =94=80 =E2=94=82 (and (< (point) (process-mark process)) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2140 =E2=94=80 which implicitly relies on previous reseting of point by select-window. And this: =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2144 =E2=94=80 /home/vitoshka/TVC/emacs/lisp/comint.el =E2=94=80=E2= =94=80 =E2=94=82 (if (eq (selected-window) selected) 'this 'others)) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #2144 =E2=94=80 which compares current window with the original one.=20 Because of this "implicitness" this piece of code is very tricky. I have cleaned it up. Note that the internal function comint-adjust-point is no longer used anywhere in emacs. I left it in the code for backward compatibility. I think it is quite safe to remove it completely. It is very unlikely that it has been used outside of this specific context. Vitalie --=-=-= Content-Type: text/x-diff Content-Disposition: inline commit 1099eb540d2246836007a83d249db4bf2565c753 (refs/heads/comint-fix) Author: Vitalie Spinu Date: Tue Dec 25 00:22:55 2012 +0100 Cleanup comint-postoutput-scroll-to-bottom (Bug#13248) Modified lisp/ChangeLog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6d5e77d..cf782e9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-12-24 Vitalie Spinu + + * comint.el (comint-postoutput-scroll-to-bottom): Cleanup + comint-postoutput-scroll-to-bottom (Bug#13248). + 2012-12-24 Dmitry Gutov * progmodes/ruby-mode.el: Bump the version to 1.2 (Bug#13200). Modified lisp/comint.el diff --git a/lisp/comint.el b/lisp/comint.el index cff9afe..7530f24 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2120,19 +2120,31 @@ 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))) - (dolist (w (get-buffer-window-list current nil t)) - (select-window w) - (unwind-protect - (progn - (comint-adjust-point selected) - ;; Optionally scroll to the bottom of the window. - (and comint-scroll-show-maximum-output - (eobp) - (recenter (- -1 scroll-margin)))) - (select-window selected)))))) + (dolist (w (get-buffer-window-list current nil t)) + (comint-adjust-window-point w process) + ;; Optionally scroll to the bottom of the window. + (and comint-scroll-show-maximum-output + (eq (window-point w) (point-max)) + (with-selected-window w + (recenter (- -1 scroll-margin))))))) (set-buffer current)))) + +(defun comint-adjust-window-point (window process) + "Move point in WINDOW based on Comint settings. +For point adjustment use the process-mark of PROCESS." + (and (< (window-point window) (process-mark process)) + (or (memq comint-move-point-for-output '(t all)) + ;; Maybe user wants point to jump to end. + (eq comint-move-point-for-output + (if (eq (selected-window) window) 'this 'others)) + ;; If point was at the end, keep it at end. + (and (marker-position comint-last-output-start) + (>= (window-point window) comint-last-output-start))) + (set-window-point window (process-mark process)))) + + +;; this function is nowhere used (defun comint-adjust-point (selected) "Move point in the selected window based on Comint settings. SELECTED is the window that was originally selected." --=-=-=--