0

I am edting latex files with Emacs+AucTeX. When working I have two windows in the frame: the latex file window and the reftex-toc window. I set the reftex-toc window dedicated to its buffer by

(defadvice reftex-toc (after reftex-toc-window-dedicated activate)
   (set-window-dedicated-p (selected-window) t))

to keep it from being replaced.

But problems arise when I call (TeX-recenter-output-buffer) by C-c C-l. The output buffer can't be displayed. I have to manually switch to the output buffer by C-x b. And if I call help commands, e.g. C-h f, the help buffer is not displayed in a new window as it should be. Instead, it replaces the latex file window. How can I fix this problem?

EDIT

I found that the problem is due to function (display-buffer BUFFER), which is internally called by (TeX-recenter-output-buffer). Under normal circumstances where there is no dedicated window in the frame, (display-buffer BUFFER) creates a new window for BUFFER. But if there are a dedicated window and some normal windows, (display-buffer BUFFER) just displays BUFFER in one of the normal windows w/o creating a new one.

As a workaround, I open another (the 3rd) window, so that if I call C-c C-l, the compilation output is displayed there and the latex file window is kept. However, I am still looking forward to a real solution. Could any one help? Thank you.

hanli8
  • 1
  • 3
  • 1
    Change `TeX-recenter-output-buffer` so that it uses your own `display-bufer` function instead of `TeX-pop-to-buffer` -- you decide which window to select, or to create a new one if nothing matches your criteria for choosing an existing window. – lawlist Jun 24 '14 at 05:23
  • 1
    Here is a link to the Emacs manual that demonstrates how to control some of the options using `display-buffer`: http://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Action-Functions.html Be prepared to spend some time reading / experimenting. Then, have a look at the source code for `window.el` and be prepared to spend more time reading / experimenting. Then write your own function that does exactly what you want. – lawlist Jun 24 '14 at 05:30
  • @lawlist Thanks for your comments. I am reading `window.el` and the manual. It will take me some time. Maybe I need to modify `pop-to-buffer` or `display-buffer`. Just wondering why the developers introduced the *dedicated* window but didn't make the display function aligned. Is there any special consideration? – hanli8 Jun 24 '14 at 11:06
  • It is usually best to touch/modify only the behavior relating to the specific function at issue, otherwise it might have unintended side effects (which may not show up immediately) when that modified function is used somewhere else by something else. Perhaps you could word search *all* AUCTeX source files to see where else `TeX-recenter-output-buffer` is used so you can have an idea as to the far reaching scope (if any) of modifying *only* that function with your own `display-buffer` custom function. – lawlist Jun 24 '14 at 15:43
  • Perhaps someone on the development team (if they read this thread) can shed some light on the rationale of why `display-buffer` reacts a particular way when dealing with a `dedicated` window. I usually just write my own function once I see that the default behavior is not what I'm looking for. I have a few of my own that I use frequently, including a whopper function that chooses what frame and what window to display: http://stackoverflow.com/a/18371427/2112489 See also the following examples: http://stackoverflow.com/a/21591259/2112489 and http://stackoverflow.com/a/21544307/2112489 – lawlist Jun 24 '14 at 15:51

0 Answers0