Skip to content

Instantly share code, notes, and snippets.

@jorgenschaefer
Created January 7, 2013 08:42
Show Gist options
  • Select an option

  • Save jorgenschaefer/4473389 to your computer and use it in GitHub Desktop.

Select an option

Save jorgenschaefer/4473389 to your computer and use it in GitHub Desktop.
(defun window-bottom--is-past-buffer/lines ()
"Return a true value iff we scrolled past the buffer end."
(save-excursion
(goto-char (window-start))
(let ((lines 0)
(max-lines (window-height)))
(while (and (< lines max-lines)
(re-search-forward "[\n\C-m]" nil t))
(setq lines (+ 1 lines)))
(goto-char (point-max))
(when (bolp)
(setq lines (+ lines 1)))
(< lines max-lines))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment