unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How do I display pdfs to the right and not below the current window?
@ 2015-12-31 14:26 Marcin Borkowski
  2016-01-02  1:37 ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2015-12-31 14:26 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

Hi list,

this is what I've come up with:

--8<---------------cut here---------------start------------->8---
(add-to-list 'display-buffer-alist '("\\.pdf$" . (display-buffer-pop-up-window-split-horizontally)))
(defun display-buffer-pop-up-window-split-horizontally (buffer alist)
  "Call `display-buffer-pop-up-window', setting
`split-height-threshold' and `split-width-threshold' so that
the split is always horizontal."
  (let ((split-height-threshold nil)
	(split-width-threshold 0))
    (display-buffer-pop-up-window buffer alist)))
--8<---------------cut here---------------end--------------->8---

And here are my questions:

1. Do I use the right variable?  There are quite a few places I could
stick my `display-buffer-pop-up-window-split-horizontally', I'm not sure
this is the best one.

2. Is my way of ensuring that the split will be horizontal a good one?

3. I'd also like to be able to make the newly created window a bit
narrower than half the width of the original one (or rather, ensure that
the original window is at least 80 columns wide).  How do I achieve
that?

4. Do you agree that something like this should be (at least as an
option, but preferably as the default) in Emacs core?  Stock Emacs can
display pdfs with doc-view (I use pdf-tools).  Nowadays most people have
rather wide screens, and displaying a (portrait, not landscape) pdf in
a wide but short (in a sense of height) window does not make a lot of
sense.

Of course, when items 1-3 are resolved, I'll be happy to submit
a patch.

WDYT?

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How do I display pdfs to the right and not below the current window?
  2015-12-31 14:26 How do I display pdfs to the right and not below the current window? Marcin Borkowski
@ 2016-01-02  1:37 ` Michael Heerdegen
  2016-01-02  6:39   ` Marcin Borkowski
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2016-01-02  1:37 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@mbork.pl> writes:


> (add-to-list 'display-buffer-alist '("\\.pdf$" . (display-buffer-pop-up-window-split-horizontally)))
> (defun display-buffer-pop-up-window-split-horizontally (buffer alist)
>   "Call `display-buffer-pop-up-window', setting
> `split-height-threshold' and `split-width-threshold' so that
> the split is always horizontal."
>   (let ((split-height-threshold nil)
> 	(split-width-threshold 0))
>     (display-buffer-pop-up-window buffer alist)))
>
> And here are my questions:


> 1. Do I use the right variable?

> 2. Is my way of ensuring that the split will be horizontal a good one?

I think so.


> 3. I'd also like to be able to make the newly created window a bit
> narrower than half the width of the original one (or rather, ensure that
> the original window is at least 80 columns wide).  How do I achieve
> that?

I think you would have to bind `split-window-preferred-function',
calculate the preferred size yourself and pass it directly to
`split-window-below' etc.


Michael.



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

* Re: How do I display pdfs to the right and not below the current window?
  2016-01-02  1:37 ` Michael Heerdegen
@ 2016-01-02  6:39   ` Marcin Borkowski
  2016-01-03  0:43     ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2016-01-02  6:39 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Help Gnu Emacs mailing list



On 2016-01-02, at 02:37, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>
>> (add-to-list 'display-buffer-alist '("\\.pdf$" . (display-buffer-pop-up-window-split-horizontally)))
>> (defun display-buffer-pop-up-window-split-horizontally (buffer alist)
>>   "Call `display-buffer-pop-up-window', setting
>> `split-height-threshold' and `split-width-threshold' so that
>> the split is always horizontal."
>>   (let ((split-height-threshold nil)
>> 	(split-width-threshold 0))
>>     (display-buffer-pop-up-window buffer alist)))
>>
>> And here are my questions:
>
>
>> 1. Do I use the right variable?
>
>> 2. Is my way of ensuring that the split will be horizontal a good one?
>
> I think so.
>
>> 3. I'd also like to be able to make the newly created window a bit
>> narrower than half the width of the original one (or rather, ensure that
>> the original window is at least 80 columns wide).  How do I achieve
>> that?
>
> I think you would have to bind `split-window-preferred-function',
> calculate the preferred size yourself and pass it directly to
> `split-window-below' etc.

Thanks for your answer, it works (I'll share my code soon).

Now I have another problem.  This code

(split-window-right (round (* 0.5 (window-width window))))

will split the window into "unequal halves".  I understand the reason,
but is there a simple way to override this behavior?  IOW, how to define
`calculate-columns' so that (split-window-right (calculate-columns col))
makes it so that subsequent (window-width) returns exactly col?

> Michael.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How do I display pdfs to the right and not below the current window?
  2016-01-02  6:39   ` Marcin Borkowski
@ 2016-01-03  0:43     ` Michael Heerdegen
  2016-01-03  7:18       ` Marcin Borkowski
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2016-01-03  0:43 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> Now I have another problem.  This code
>
> (split-window-right (round (* 0.5 (window-width window))))
>
> will split the window into "unequal halves".  I understand the reason,

What is the reason?

> but is there a simple way to override this behavior?

Dunno.  I'm no expert, but after reading the doc ("Optional argument
SIZE a positive number means make WINDOW SIZE lines or columns tall.") I
would expect that `window-width' of the new window would return that
value (contrary to `window-text-width', this is a different thing).


Michael.



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

* Re: How do I display pdfs to the right and not below the current window?
  2016-01-03  0:43     ` Michael Heerdegen
@ 2016-01-03  7:18       ` Marcin Borkowski
  2016-01-04  3:18         ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2016-01-03  7:18 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Help Gnu Emacs mailing list



On 2016-01-03, at 01:43, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Now I have another problem.  This code
>>
>> (split-window-right (round (* 0.5 (window-width window))))
>>
>> will split the window into "unequal halves".  I understand the reason,
>
> What is the reason?

Fringes, scroll bars are taken into account by split-window-right, but
not by window-width.

>> but is there a simple way to override this behavior?
>
> Dunno.  I'm no expert, but after reading the doc ("Optional argument
> SIZE a positive number means make WINDOW SIZE lines or columns tall.") I
> would expect that `window-width' of the new window would return that
> value (contrary to `window-text-width', this is a different thing).

OK, I found about `window-total-width'.  I should have done
M-x apropos ^window-.*-width$
first, sorry.

The question that remains is whether `split-window-right' should set
`window-size' or `window-total-size' or something else yet.  (My opinion
is `window-size', but I may be wrong.)  Eventually, it seems to rely on
`split-window', which is too scary for me to look into now (235 lines,
excluding the docstring;-)).

> Michael.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: How do I display pdfs to the right and not below the current window?
  2016-01-03  7:18       ` Marcin Borkowski
@ 2016-01-04  3:18         ` Michael Heerdegen
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2016-01-04  3:18 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list

Marcin Borkowski <mbork@mbork.pl> writes:

> The question that remains is whether `split-window-right' should set
> `window-size' or `window-total-size' or something else yet.  (My opinion
> is `window-size', but I may be wrong.)  Eventually, it seems to rely on
> `split-window', which is too scary for me to look into now (235 lines,
> excluding the docstring;-)).

Seems this resizes the windows after creating them, using, at the end,
`set-window-new-normal'.  The rest are preliminaries, condition checking
and calculations.

It's probably easier for the primitives to not take scroll bars
etc. into count, dunno.  My guess is that it would be very hard to
change the behavior, and it is relatively easy to calculate a size
according to what you expect yourself, so I would do the latter.


Regards,

Michael.



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

end of thread, other threads:[~2016-01-04  3:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-31 14:26 How do I display pdfs to the right and not below the current window? Marcin Borkowski
2016-01-02  1:37 ` Michael Heerdegen
2016-01-02  6:39   ` Marcin Borkowski
2016-01-03  0:43     ` Michael Heerdegen
2016-01-03  7:18       ` Marcin Borkowski
2016-01-04  3:18         ` Michael Heerdegen

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