emacs: Fix backspace to not scroll more than the previous message
[notmuch] / notmuch.el
index cd4d9963fb98c44a7b017faaf85391b24b293649..c611dcc2cc72ebde11568b3e42f2fa6bb0f70f1c 100644 (file)
@@ -647,7 +647,13 @@ any effects from previous calls to
          (condition-case nil
              (scroll-down nil)
            ((beginning-of-buffer) nil))
-         (goto-char (window-start)))
+         (goto-char (window-start))
+         ; Because count-lines counts invivisible lines, we may have
+         ; scrolled to far. If so., notice this and fix it up.
+         (if (< (point) previous)
+             (progn
+               (goto-char previous)
+               (recenter 0))))
       (notmuch-show-previous-message))))
 
 (defun notmuch-show-advance-and-archive ()