Hi Eli, Thanks. You are right, vanilla ​Emacs indeed recenters a new file by default. I'm using spacemacs, which won't and I'm investigating the problem. If the file is already visited in Emacs, it won't recenter. Is it possible to make Emacs recenter even if it's already visited? I've check with Notepad++, which will recenter even if it's already opened. Best, Xiaolong On Sat, Oct 28, 2017 at 2:49 PM, Eli Zaretskii wrote: > > From: Xiaolong Zhang > > Date: Sat, 28 Oct 2017 11:30:27 +0800 > > > > I'm using emacs for LaTeX file editing and emacsclient support the nice > command line option "+linenum file" > > to "visit file using find-file, then go to line number linenum in it", > which works well. > > > > Is it possible to recenter to linenum at the sametime? This is the > default behavior for Notepad++ and I've tried > > the "--eval" option, but it won't switch focus to emacs automatically. > > Emacs recenters by default, so unless you have some customizations > which disable that as side effect, it should already do what you > want. I just tried the command > > emacsclient +150 configure.ac > > and got line 150 centered in the window where Emacs shows the file. > If that doesn't work for you, please show the exact recipe. You seem > to invoke emacsclient from another program (I tried from the shell > prompt), so perhaps there's something in that context which affects > the issue; I'm not familiar with "SumatraPDF" and the "inverse search > feature". > > Another possible reason for not recentering is that the file whose > name is passed to emacsclient is already visited in Emacs, and the > line whose number you pass to emacsclient is already visible in some > window, but not at the center of that window. In that case, Emacs > will not recenter. >