![]() (display-buffer-pop-up-window buffer alist))) (split-window-preferred-function #'pdf-split-window-sensibly)) (split-width-threshold pdf-split-width-threshold) "Call `display-buffer-pop-up-window', using `pdf-split-window-sensibly' (defun display-buffer-pop-up-window-pdf-split-horizontally (buffer alist) minibuffer window, try to split it vertically disregarding If WINDOW is the only window on its frame and is not the (and (eq window (frame-root-window (window-frame window))) (round (* pdf-minimal-width (window-width window))))))) (width (- (if (integerp pdf-minimal-width) (let ((window (or window (selected-window))) It prefers splitting horizontally, and takes `pdf-minimal-width' "A version of `split-window-sensibly' for pdfs. (defun pdf-split-window-sensibly (&optional window) "Minimum width a window should have to split it horizontally "Minimal width of a window displaying a pdf. Pretty rare, I’d argue, but it actually happened to me, and it was not obvious at first what was going on! (defvar pdf-minimal-width 72 If you want different settings, just play around with the two variables introduced below.įinally, notice that my previous version of the regex for buffers displayed on the right, which was just "\\.pdf$", does not work if there are two pdfs with the same name, but different directories displayed at the same time, since by default Emacs appends a string of the form to the end of the buffer name then. It is not very elegant in that I just copy-pasted the split-window-sensibly function and made the changes I needed, but I don’t see how I could achieve my goal in a more elegant way with, say, advice, so who cares. In this case, however, it’s not a big problem: I can find out the correct value of the argument for split-window-right by trial and error, and this is exactly what I did.Īll in all, let the code speak for itself. It turns out that making Emacs split windows in the desired proportion is not a trivial task (see here and here for some pointers). (Those strange Americans who use those strange paper sizes might want to adjust for that, although even they are not strange enough to use square paper for most of their documents.) This means that by dividing the window in the middle, I waste a lot of screen real estate. OTOH, I use almost exclusively the A4 paper size, whose aspect ratio is √2:1. The aspect ratio of my screen is 16:9, which means that a horizontal split divides the main window into two almost square halves. However, while we’re at it, there is one more thing to take care of: I don’t want the window containing the pdf to be half the screen wide. Of course, the solution is known already: display-buffer-alist. (And I’m totally not accustomed to such a behavior.) I use a laptop with a 14” screen, which is just a tad too small for that to be comfortable. OTOH, I would not want everything to pop up to the right. Since most of my documents are in “portrait” mode, this doesn’t make sense at all – I’d very much prefer if the window with the pdf was shown to the right of the current one. ![]() One thing I found really annoying (though it’s not related to PDF Tools – again, doc-view has the same problem): when I pressed C-cĬ-v ( TeX-view), the pdf was shown in a window below the current one. Another one is that sometimes, when I zoom in a bit and do something, my carefully found place in the pdf is gone, and some other place is shown. (Emacs’ doc-view has the same problem, and it seems that it’s not trivial to change, at least not without advice). The biggest one is that C-M-v ( scroll-other-window) won’t switch to next page of the pdf. (I did once experience some problems with said annotations, though.) I was a bit afraid about the efficiency – but man, it’s really fast! A great piece of work indeed. ![]() Especially if you do a lot of LaTeX work in AUCTeX (like I do) and/or if you need to read or create PDF annotations (highlighting and/or notes) – it’s really great. If you are an Emacs user on GNU+Linux, I strongly advice you to try PDF Tools out. (Well, almost never – Evince does have one or two options not present in PDF Tools, but I hardly ever use them). Some time ago I decided that I’ll give PDF tools a shot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |