all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* find-file-hook, recenter, scroll-conservatively and save-place
@ 2019-01-31  9:46 Gergely Risko
  2019-01-31 13:46 ` Gergely Risko
  2019-01-31 13:49 ` martin rudalics
  0 siblings, 2 replies; 17+ messages in thread
From: Gergely Risko @ 2019-01-31  9:46 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-02-03 20:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31  9:46 find-file-hook, recenter, scroll-conservatively and save-place Gergely Risko
2019-01-31 13:46 ` 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

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.