From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Gergely Risko Newsgroups: gmane.emacs.devel Subject: find-file-hook, recenter, scroll-conservatively and save-place Date: Thu, 31 Jan 2019 10:46:59 +0100 Message-ID: <877eelupkc.fsf@errge.nilcons.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="121041"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: GNU Emacs with Gnus To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 31 10:47:22 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 1gp8wM-000VQA-CC for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 10:47:22 +0100 Original-Received: from localhost ([127.0.0.1]:51687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp8wL-0002VW-AU for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 04:47:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp8w8-0002UV-2Y for emacs-devel@gnu.org; Thu, 31 Jan 2019 04:47:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gp8w7-0005M4-DN for emacs-devel@gnu.org; Thu, 31 Jan 2019 04:47:08 -0500 Original-Received: from [195.159.176.226] (port=60810 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gp8w7-0005Ku-6v for emacs-devel@gnu.org; Thu, 31 Jan 2019 04:47:07 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gp8w5-000VAP-43 for emacs-devel@gnu.org; Thu, 31 Jan 2019 10:47:05 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:p9BfOpckQciFx4QU6/0bBy/cwq4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 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:232856 Archived-At: Hi, I'm using save-place in my .emacs and I also set scroll-conservatively to 101 with a scroll-margin of 3. I like the smooth scrolling experience, but I would prefer to have new files open at their previous save-place location recentered in their window, not at the end. This works as intended with scroll-conservatively 0, but breaks with scroll-conservatively 101. I did the following digging: - scroll-conservatively achieves its behavior in redisplay asynchronously to find-file-hook, therefore any kind of dynamic binding hackery of setting scroll-conservatively temporarily to 0 doesn't work for me in save-place, - recenter refuses to run when the current window is not showing the current buffer (makes sense), - find-file-hook is ran with the new buffer as current, but the window is not changed to the new buffer yet. If I have this in find-file-hook: (defun test () (message "foobar: %s %s" (current-buffer) (selected-window)) ) And I open new-file.c while standing in old-file.c, I receive this: Debugger entered--returning value: "foobar: old-file.c #" My question: is there a better hook that we could use for save-place restoration purposes? I also looked into xref, and there the behavior is much better: the (recenter) is included in the default configuration of xref-after-jump-hook and it works in all the scenarios that I have tried. Thanks, Gergely