unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* recenter after visiting file (with savehist-mode)
@ 2019-02-09 11:24 Jarosław Rzeszótko
  2019-02-10 15:50 ` martin rudalics
  0 siblings, 1 reply; 2+ messages in thread
From: Jarosław Rzeszótko @ 2019-02-09 11:24 UTC (permalink / raw)
  To: emacs-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

I am trying to get Emacs to recenter the window around point after opening
a file with savehist-mode. I tried adding an :after advise to
save-place-find-file-hook, I tried setting a global display-buffer
function, but no matter what I try I keep getting the dreaded:

`recenter'ing a window that does not display current-buffer.

Does anyone know any way around this?

Cheers,
Jarosław Rzeszótko

[-- Attachment #2: Type: text/html, Size: 531 bytes --]

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

* Re: recenter after visiting file (with savehist-mode)
  2019-02-09 11:24 recenter after visiting file (with savehist-mode) Jarosław Rzeszótko
@ 2019-02-10 15:50 ` martin rudalics
  0 siblings, 0 replies; 2+ messages in thread
From: martin rudalics @ 2019-02-10 15:50 UTC (permalink / raw)
  To: Jarosław Rzeszótko, emacs-devel@gnu.org

 > I am trying to get Emacs to recenter the window around point after opening
 > a file with savehist-mode. I tried adding an :after advise to
 > save-place-find-file-hook, I tried setting a global display-buffer
 > function, but no matter what I try I keep getting the dreaded:
 >
 > `recenter'ing a window that does not display current-buffer.

You probably have to use a function like the below.

(defun recenter-window (&optional window)
   "Recenter WINDOW.
WINDOW must be a live window and defaults to the selected one."
   (let ((window (window-normalize-window window t)))
     (if (eq window (selected-window))
	(recenter)
       (with-selected-window window
	(recenter)))))

martin



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

end of thread, other threads:[~2019-02-10 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-09 11:24 recenter after visiting file (with savehist-mode) Jarosław Rzeszótko
2019-02-10 15:50 ` martin rudalics

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).