1

I'd like to test, please, whether the lines of text in a no-file visiting buffer are greater than the window height -- if not, then

(set-window-scroll-bars (get-buffer-window "*Org Agenda*" (selected-frame)) 0 nil)
lawlist
  • 13,099
  • 3
  • 49
  • 158

2 Answers2

3

Comparing count-lines with window-height works in some cases but doesn't account for line-wrapping, images, and variable-sized fonts. Another approch is to check if window-end is before point-max.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • Thank you for the alternative approach, which is ideal for situations where there is at least one character beyond the visible window -- i.e., `(> (point-max) (window-end))` will not return `t` if there are no characters beyond the visible window even if the buffer contains multiple pages of text. – lawlist Jan 04 '14 at 20:30
  • Right, I assumed that `window-start` is at `point-min`. If you can't assume it, then you can check it. – Stefan Jan 04 '14 at 20:54
2

You can test with this:

(> (count-lines (point-min)
                (point-max))
   (window-height))
abo-abo
  • 20,038
  • 3
  • 50
  • 71