From: Gergely Risko <gergely@risko.hu>
To: emacs-devel@gnu.org
Subject: find-file-hook, recenter, scroll-conservatively and save-place
Date: Thu, 31 Jan 2019 10:46:59 +0100 [thread overview]
Message-ID: <877eelupkc.fsf@errge.nilcons.com> (raw)
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 #<window 85 on new-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
next reply other threads:[~2019-01-31 9:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 9:46 Gergely Risko [this message]
2019-01-31 13:46 ` find-file-hook, recenter, scroll-conservatively and save-place Gergely Risko
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877eelupkc.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.