* My contribution code for doc-view.el
@ 2008-11-28 13:54 Andy Stewart
0 siblings, 0 replies; only message in thread
From: Andy Stewart @ 2008-11-28 13:54 UTC (permalink / raw)
To: emacs-devel
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-28 13:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-28 13:54 My contribution code for doc-view.el Andy Stewart
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).