I am using a slightly modified version of doc-view mode and would like to maintain focus in a different window, while hovering with the mouse over the doc-view window and scroll the image page-up or page-down -- without actually selecting the window. When not selecting the window and attempting to scroll with the mouse, I get the following error message.

In case it makes a difference, my operating system is OSX 10.6.8 (Snow Leopard).

Debugger entered--Lisp error: (wrong-type-argument listp t)
  image-mode-window-get(page nil)
  (+ (image-mode-window-get (quote page) nil) (or arg 1))
  (dv-goto-page (+ (image-mode-window-get (quote page) nil) (or arg 1)))
  funcall-interactively(dv-next-page 1)
  call-interactively(dv-next-page nil nil)

EDIT (November 28, 2014):  The following is the debugger readout for the stock version of doc-view-mode using the following mouse wheel assignments that I added:

Key assignments:

(define-key doc-view-mode-map (kbd "<wheel-down>") 'doc-view-next-page)

(define-key doc-view-mode-map (kbd "<wheel-up>") 'doc-view-previous-page)

Emacs version: GNU Emacs (x86_64-apple-darwin10.8.0, NS appkit-1038.36 Version 10.6.8 (Build 10K549)) of 2014-10-01 on MP.local

Debugger readout:

Debugger entered--Lisp error: (wrong-type-argument listp t)
  image-mode-window-get(page nil)
  funcall-interactively(doc-view-next-page 1)
  call-interactively(doc-view-next-page nil nil)
  • Do you get the same behavior with the original version of doc-view? If not, post your modifications. What version of Emacs are you running? Commented Nov 28, 2014 at 18:59
  • @Gilles -- thanks for helping me troubleshoot the issue. I just added the two key assignments for the stock version of doc-view mode and had a similar message (which I've added to the question as an edit). Perhaps there is a better keymap assignment that will help ensure the needed value is not nil?
    – lawlist
    Commented Nov 28, 2014 at 19:19
  • @Gilles -- I tried using wheel-down and wheel-up for doc-view-next-page and doc-view-previous-page because I wanted to scroll one page at a time, without any partial page movement before scrolling to the next page. Setting the variable doc-view-continuous to t lets me eventually scroll to the next page, but there is some movement of the current page and additional scrolling that is needed to finally turn the page. It would be nice to achieve the same movement as doc-view-next-page and doc-view-previous-page with the mouse when focus is in another window.
    – lawlist
    Commented Nov 28, 2014 at 19:37

1 Answer 1


When doc-view-mode is enabled, mwheel-scroll-up-function is set locally to be doc-view-scroll-up-or-next-page; and, mwheel-scroll-down-function is set locally to be doc-view-scroll-down-or-previous-page. The preferred behavior sought by the original poster in the question above is that the mouse-wheel activate doc-view-next-page and doc-view-previous-page when focus is in another unrelated buffer window, and the mouse is hovering over the doc-view-mode buffer window. The code set out below resolves that issue. Although the original poster tried binding doc-view-next-page to wheel-down and doc-view-previous-page to wheel-up, that is not correct and this is why the original poster received the error message that was cited above.

The behavior of doc-view-scroll-up-or-next-page and doc-view-scroll-down-or-previous-page is slightly different than doc-view-next-page and doc-view-previous-page. Ultimately, this is a matter of personal preference and the issue was simply how to implement that preference.

(defun doc-view-mouse-turn-page ()
  (when (boundp 'mwheel-scroll-up-function)
    (setq-local mwheel-scroll-up-function #'doc-view-next-page))
  (when (boundp 'mwheel-scroll-down-function)
    (setq-local mwheel-scroll-down-function #'doc-view-previous-page)))

(add-hook 'doc-view-mode-hook 'doc-view-mouse-turn-page)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.