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: Re: find-file-hook, recenter, scroll-conservatively and save-place Date: Thu, 31 Jan 2019 14:46:40 +0100 Message-ID: <87zhrhszwf.fsf@errge.nilcons.com> References: <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="134103"; 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 14:52:50 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 1gpClu-000YhD-Ft for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 14:52:50 +0100 Original-Received: from localhost ([127.0.0.1]:55207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpClt-0000fi-EX for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 08:52:49 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpCg7-0004te-GR for emacs-devel@gnu.org; Thu, 31 Jan 2019 08:46:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpCg6-0003X1-AB for emacs-devel@gnu.org; Thu, 31 Jan 2019 08:46:51 -0500 Original-Received: from [195.159.176.226] (port=54888 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpCg5-0003Vg-Rk for emacs-devel@gnu.org; Thu, 31 Jan 2019 08:46:50 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gpCg4-000Rz2-3k for emacs-devel@gnu.org; Thu, 31 Jan 2019 14:46:48 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:QN8nGwPWWKabC39AiDQZm+KqmDU= 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:232858 Archived-At: Hi, After more digging: - find-file-* calls find-file-noselect - find-file-noselect always returns a buffer - find-file-noselect doesn't return the information if this is a new buffer just visiting a file right now or an old one that was open - find-file-* then selects the returned buffer and chooses a window, displays the window, etc. 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. The communication between the find-file-noselect function and the find-file-* user facing commands can be implemented in two ways: - return some kind of structured data from find-file-noselect (with the buffer and my new boolean about "is this a new buffer?") - setq a buffer local variable inside find-file-noselect that is later queried at the end of the find-file-* commands to decide whether to run the find-file-with-window-hook or not. Conceptually the first sounds cleaner and better, but find-file-noselect is a function that is documented and therefore this would been a breaking change. Therefore I prefer solution 2. A third alternative would be to rename find-file-noselect to find-file--noselect-internal, implement my API and provide a backward compatibility find-file-noselect function. Any opinions on the mentioned designs? Which should I go ahead with and prepare a patch or does anyone have a simpler/better idea or any other suggestion? Also, please tell me if this is already a solved issue and I'm just being dense. :-) Cheers, Gergely