[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
My contribution code for doc-view.el
From: |
Andy Stewart |
Subject: |
My contribution code for doc-view.el |
Date: |
Fri, 28 Nov 2008 21:54:40 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Hi, everyone!
Below is my contribution code for doc-view.el
------------------------------> code start <------------------------------
(defadvice scroll-other-window (around doc-view-scroll-up-or-next-page activate)
"When next buffer is `doc-view-mode', do `doc-view-scroll-up-or-next-page'."
(other-window +1)
(if (eq major-mode 'doc-view-mode)
(let ((arg (ad-get-arg 0)))
(if (null arg)
(doc-view-scroll-up-or-next-page)
(doc-view-next-line-or-next-page arg))
(other-window -1))
(other-window -1)
ad-do-it))
(defadvice scroll-other-window-down (around
doc-view-scroll-down-or-previous-page activate)
"When next buffer is `doc-view-mode', do
`doc-view-scroll-down-or-previous-page'."
(other-window +1)
(if (eq major-mode 'doc-view-mode)
(let ((arg (ad-get-arg 0)))
(if (null arg)
(doc-view-scroll-down-or-previous-page)
(doc-view-previous-line-or-previous-page arg))
(other-window -1))
(other-window -1)
ad-do-it))
(defun doc-view-next-line-or-next-page (arg)
"Next line if possible, else goto next page."
(interactive "P")
(when (= (window-vscroll) (image-next-line (or arg 1)))
(let ((cur-page (doc-view-current-page)))
(doc-view-next-page)
(when (/= cur-page (doc-view-current-page))
(image-bob)
(image-bol 1)))))
(defun doc-view-previous-line-or-previous-page (arg)
"Previous line if possible, else goto previous page."
(interactive "P")
(when (= (window-vscroll) (image-previous-line (or arg 1)))
(let ((cur-page (doc-view-current-page)))
(doc-view-previous-page)
(when (/= cur-page (doc-view-current-page))
(image-eob)
(image-bol 1)))))
(defun doc-view-page-reach-top-p ()
"Return t if current page have reach top edge, otherwise return nil."
(equal (window-vscroll) 0))
(defun doc-view-page-reach-bottom-p ()
"Return t if current page have reach bottom edge, otherwise return nil."
(let* ((image (image-get-display-property))
(edges (window-inside-edges))
(win-height (- (nth 3 edges) (nth 1 edges)))
(img-height (ceiling (cdr (image-size image)))))
(equal img-height (+ win-height (window-vscroll)))))
------------------------------> code end <------------------------------
Enjoy!
-- Andy.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- My contribution code for doc-view.el,
Andy Stewart <=