From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#29111: 26.0.90; Erc keep-place module broken with new default of switch-to-buffer-preserve-window-point Date: Sat, 04 Nov 2017 09:36:55 +0100 Message-ID: <59FD7C27.7090803@gmx.at> References: <87inetcppp.fsf@gmail.com> <59FAEA9C.1050608@gmx.at> <877ev7zz3e.fsf@gmail.com> <59FC21B8.5030508@gmx.at> <87zi83xij9.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1509784697 6991 195.159.176.226 (4 Nov 2017 08:38:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Nov 2017 08:38:17 +0000 (UTC) Cc: 29111@debbugs.gnu.org To: Jay Kamat Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 04 09:38:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAtxv-000152-Rp for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Nov 2017 09:38:08 +0100 Original-Received: from localhost ([::1]:40147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAty0-00029Y-6M for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Nov 2017 04:38:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAtxt-00029O-S9 for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 04:38:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAtxq-0005ip-Na for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 04:38:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41454) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eAtxq-0005iM-JS for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 04:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eAtxq-0003VY-9X for bug-gnu-emacs@gnu.org; Sat, 04 Nov 2017 04:38:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Nov 2017 08:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29111 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29111-submit@debbugs.gnu.org id=B29111.150978462913385 (code B ref 29111); Sat, 04 Nov 2017 08:38:02 +0000 Original-Received: (at 29111) by debbugs.gnu.org; 4 Nov 2017 08:37:09 +0000 Original-Received: from localhost ([127.0.0.1]:50135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAtwy-0003Tn-Pq for submit@debbugs.gnu.org; Sat, 04 Nov 2017 04:37:09 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:55472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAtww-0003TC-Ad for 29111@debbugs.gnu.org; Sat, 04 Nov 2017 04:37:07 -0400 Original-Received: from [192.168.1.100] ([46.125.249.60]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M0h9K-1dHPiG327i-00upF6; Sat, 04 Nov 2017 09:36:58 +0100 In-Reply-To: <87zi83xij9.fsf@gmail.com> X-Provags-ID: V03:K0:OfWM8tepEibp3U4p6dPyB87BrSIvf714wiq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-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:139427 Archived-At: > Keep place adds a hook so that, when a new message comes in on a > non-visible buffer *and* point is at the bottom, point is moved up by > one line. Doing this means that point stays on the last 'read' > message. Here's the relevant code from keep-place: > >> (defun erc-keep-place (ignored) >> "Move point away from the last line in a non-selected ERC buffer." >> (when (and (not (eq (window-buffer (selected-window)) >> (current-buffer))) >> (>=3D (point) erc-insert-marker)) >> (deactivate-mark) >> (goto-char (erc-beg-of-input-line)) >> (forward-line -1))) You could try to pretend that the position at which the buffer was previously shown in a window is the position calculated here. Add after the (forward-line -1) something like ;; For all non-minibuffer windows on all frames check whether the ;; current buffer was shown in that window before. If so, update the ;; window point positions stored for the buffer to the position we just ;; calculated. (dolist (frame (frame-list)) (walk-window-tree (lambda (window) (let ((prev (assq (current-buffer) (window-prev-buffers window))) (next (assq (current-buffer) (window-next-buffers window)))) (when prev (setf (nth 2 prev) (point-marker))) (when next (setf (nth 2 next) (point-marker))))) frame nil 'nominibuf)) Completely _untested_ so you may have to tweak it appropriately! > Previously, this worked fine, since moving point on non-visible buffer= s > meant the movement persisted till the buffer was next 'shown'. However= , > the new default of `switch-to-buffer-preserve-window-point' ensures th= at > point stays wherever it was 'last seen'. I'm not sure how it does it, > but I think it's saving point when a buffer is hidden and restoring it= > when it's seen again > >> (when (and entry >> (or (eq switch-to-buffer-preserve-window-point t) >> displayed)) >> ;; Try to restore start and point of buffer in the selected >> ;; window (Bug#4041). >> (set-window-start (selected-window) (nth 1 entry) t) >> (set-window-point nil (nth 2 entry))) Right. So with the hack above you would set (nth 2 entry) to the value keep-place calculated. >> That's a possibility, but it would be too radical to go into 26.1, so= >> I think we should explore the less drastic alternatives first. > > I agree with Eli that this is too big of a change at this point, but I= > think this is the best long term solution. Perhaps we could > `make-variable-buffer-local' on `switch-to-buffer-preserve-window-poin= t' > when enabling keep-place (later, of course). I can't yet assess all implications of such a solution so I'd certainly defer it until all other measures have been exhausted. >> Since =E2=80=98keep-place=E2=80=99 is some sort of a minor mode, enab= ling it should warn >> the user about the =E2=80=98switch-to-buffer-preserve-window-point=E2= =80=99 >> incompatibility. But I'm not familiar with =E2=80=98define-erc-modul= e=E2=80=99 so we'd >> probably need someone knowledgeable to do that. > > I think this is probably the best idea before the emacs 26 release. Th= e > definition of 'keep-place' is currently > >> (define-erc-module keep-place nil >> "Leave point above un-viewed text in other channels." >> ((add-hook 'erc-insert-pre-hook 'erc-keep-place)) >> ((remove-hook 'erc-insert-pre-hook 'erc-keep-place))) > > I think we should be able to simply do something like > >> (define-erc-module keep-place nil >> "Leave point above un-viewed text in other channels." >> ((add-hook 'erc-insert-pre-hook 'erc-keep-place) >> ;; poor name, but just an example >> (erc-check-if-switch-to-buffer-preserve-and-warn)) >> ((remove-hook 'erc-insert-pre-hook 'erc-keep-place))) > > I would be happy to submit a patch for this, if the Erc maintainer is > busy. Does this seem like a good solution, or does anyone see a better= > way around this? If all else fails let's do that. First please try the proposal above. martin