unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Gergely Risko <gergely@risko.hu>
To: emacs-devel@gnu.org
Subject: Re: find-file-hook, recenter, scroll-conservatively and save-place
Date: Thu, 31 Jan 2019 14:46:40 +0100	[thread overview]
Message-ID: <87zhrhszwf.fsf@errge.nilcons.com> (raw)
In-Reply-To: 877eelupkc.fsf@errge.nilcons.com

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




  reply	other threads:[~2019-01-31 13:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31  9:46 find-file-hook, recenter, scroll-conservatively and save-place Gergely Risko
2019-01-31 13:46 ` Gergely Risko [this message]
2019-01-31 14:43   ` Eli Zaretskii
2019-01-31 15:31     ` Gergely Risko
2019-01-31 13:49 ` martin rudalics
2019-01-31 14:32   ` Eli Zaretskii
2019-01-31 18:44     ` martin rudalics
2019-01-31 23:47       ` Gergely Risko
2019-02-01  9:05         ` martin rudalics
2019-01-31 20:57   ` Juri Linkov
2019-01-31 22:45     ` Gergely Risko
2019-02-01  9:05       ` martin rudalics
2019-02-02 21:03       ` Juri Linkov
2019-02-03 20:18         ` Juri Linkov
2019-02-01  9:04     ` martin rudalics
2019-02-01 11:18       ` Gergely Risko
2019-02-02  9:30         ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhrhszwf.fsf@errge.nilcons.com \
    --to=gergely@risko.hu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).