Customizing the size of the tex-shell window
January 25, 2007 11:31 AM   Subscribe

I want to make a very small but critical change in the way emacs behaves in latex-mode. Can I force the tex-shell window to be a different size than half the current window?

When I'm editing a *.tex file, I hit C-c C-f to typeset it. The first result of this is that the window splits vertically into two equal windows, of which the top is the *.tex file and the bottom is the tex-shell buffer. Then various typesetting stuff happens (which I don't care about at the moment). What I'd like is for the new tex-shell window to be only about 5 lines tall, rather than taking up half of the current window. I found the emacs manual section about splitting windows, which indicates that 'split-window' accepts optional arguments for the size of the new window, but I can't figure out how to change the way 'C-c C-f' calls the split-window command.
posted by gleuschk to Computers & Internet (6 answers total)
C-c C-f is bound to the function tex-file in tex-mode.el (which includes latex-mode). tex-file doesn't call split-window, at least not directly.

I don't see any built-in hooks that would make this easy.

Probably the easiest thing to do would be to write an elisp function that calls tex-file and then resizes the buffers, then bind C-c C-f in latex-mode to this new function. If you're not already an elisp hacker, that's probably not a very attractive value for easiest, but there you are.
posted by Zed_Lopez at 12:14 PM on January 25, 2007

Well, you can enarge/shrink a window vertically with the 'enlarge-window' command, and you can set a tex-mode hook, so maybe something like:
(setq tex-mode-hook   '(lambda ()      (enlarge-window -8)      ))
(where -8 is the adjustment to be made to the height; I don't know which window this will apply to, so maybe you'd have to enlarge one instead of shrinking the other.)
posted by Rhomboid at 12:29 PM on January 25, 2007

You want sticky-repl.el

Download this file:

and put it somewhere like ~/.emacs_addons/sticky-repl.el

Then add the following to ~/.emacs:

(load "~/.emacs_addons/sticky-repl.el")
(setq special-display-function 'sticky-repl-display)
(setq compilation-window-height 5)
(setq same-window-buffer-names nil)
(setq special-display-buffer-names
"*Shell Command Output*"
(setq special-display-regexps
'("\\*shell\\(< [0-9]+>\\)?\\*"
"\\*slime-repl .*\\*"
"\\*sldb .*\\*"))

Now, every time a buffer called "*tex-shell*" (or any of those other names) is opened, it will be given special characteristics. You can set the buffer height to something else than 5 by changing compilation-window-height.
posted by beniamino at 12:44 PM on January 25, 2007

That works perfectly, beniamino, thanks.
posted by gleuschk at 2:06 PM on January 25, 2007

That is awesome. I hate my perforce windows taking over half the display.
posted by RustyBrooks at 2:46 PM on January 25, 2007

Rhomboid, it doesn’t actually matter for that example, but lambda expressions are self-quoting--so this is equivalent to what you wrote:
(setq tex-mode-hook       (lambda ()        (enlarge-window -8)        ))
with the ocasionally important difference that it will be byte-compiled, while the version quoted with ' won’t be. If you still want to explicitly quote the lambda expression, use
#'(lambda …)
which allows byte-compilation.
posted by Aidan Kehoe at 2:08 AM on January 26, 2007

« Older Help me consolidate thousands of pictures   |   Hip me out Newer »
This thread is closed to new comments.