From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: find-file-hook, recenter, scroll-conservatively and save-place Date: Thu, 31 Jan 2019 16:43:27 +0200 Message-ID: <83womkzy40.fsf@gnu.org> References: <877eelupkc.fsf@errge.nilcons.com> <87zhrhszwf.fsf@errge.nilcons.com> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="91418"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Gergely Risko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 31 15:44:21 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpDZj-000Nfi-Sf for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 15:44:20 +0100 Original-Received: from localhost ([127.0.0.1]:55905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpDZi-0008KS-NO for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 09:44:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpDZ4-0008K7-64 for emacs-devel@gnu.org; Thu, 31 Jan 2019 09:43:39 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:33045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpDYz-0000wZ-7u; Thu, 31 Jan 2019 09:43:34 -0500 Original-Received: from [176.228.60.248] (port=4999 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gpDYy-0003ug-Ru; Thu, 31 Jan 2019 09:43:33 -0500 In-reply-to: <87zhrhszwf.fsf@errge.nilcons.com> (message from Gergely Risko on Thu, 31 Jan 2019 14:46:40 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232861 Archived-At: > From: Gergely Risko > Date: Thu, 31 Jan 2019 14:46:40 +0100 > > The hook that I need (something like find-file-with-window-hook) can > be described like this: similar to find-file-hook, but called after a > window has been chosen or created as necessary and the window's buffer > has been changed to the buffer being opened. This hook would > guarantee in its documentation that: > > current-buffer === (window-buffer (current-window)) > > This new hook can be run-hook'd at the end of the various find-file-* > user facing commands. Before you go further down this rabbit hole, I suggest to try setting scroll-conservatively to a smaller value, like 30. If that does what you want, and doesn't cause recentering in too many other use cases, you are done without any changes in Emacs. Once upon a time scroll-conservatively only affected scroll commands, such as scroll-up etc. But then users came up and demanded that this setting should affect any motion command, including goto-char etc. What you see is the consequence of that: Emacs does this by popular demand. Any command that moves point outside of the window will, under scroll-conservatively > 100, behave like you see, i.e. always put point on the last or the first window line. You could perhaps do what you want by some clever one-time setting in pre-redisplay-functions. But it might not be easy, I'm afraid, because you'd need to do that in a way that works only the first time a buffer is displayed whose place was saved by save-place.