branch: externals/doc-toc commit 97c0ce5c40c90aa481239b565abbd0e8987cdfc6 Author: Daniel Nicolai <dalanico...@gmail.com> Commit: Daniel Nicolai <dalanico...@gmail.com>
Implement from tabular jump to/scroll page for djvu --- README.org | 3 +-- toc-mode.el | 35 +++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/README.org b/README.org index c5e3658548..0d17d4ba6e 100644 --- a/README.org +++ b/README.org @@ -87,9 +87,8 @@ buffer can be navigated with the arrow =up/down= keys. The =left= and =right= ar keys will shift =down/up= all the page numbers from the current line and below (combine with =SHIFT= for setting individual pagenumbers). -**** Currently only for pdf's The =TAB= key jumps to the pagenumber of the current line. =S-up/S-donw= in the -tablist window will scroll page up/down in the document window while =C-up/C-down= +tablist window will scroll page up/down in the document window while, only for pdf, =C-up/C-down= will scroll smoothly in that window. For type =C-c C-c= when done. diff --git a/toc-mode.el b/toc-mode.el index f5f2289d87..a1201ab731 100644 --- a/toc-mode.el +++ b/toc-mode.el @@ -169,8 +169,17 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text. (text "") (buffer (file-name-sans-extension (buffer-name)))) (while (<= startpage (+ endpage)) - (let ((file (cond ((string= ".pdf" ext) (make-temp-file "pageimage" nil (number-to-string startpage) (pdf-cache-get-image startpage 600))) - ((string= ".djvu" ext) (djvu-goto-page startpage) (make-temp-file "pageimage" nil (number-to-string startpage) (image-property djvu-doc-image :data)))))) + (let ((file (cond ((string= ".pdf" ext) + (make-temp-file "pageimage" + nil + (number-to-string startpage) + (pdf-cache-get-image startpage 600))) + ((string= ".djvu" ext) + (djvu-goto-page startpage) + (make-temp-file "pageimage" + nil + (number-to-string startpage) + (image-property djvu-doc-image :data)))))) (call-process "tesseract" nil (list buffer nil) nil file "stdout" "--psm" "6") (setq startpage (1+ startpage)))) (switch-to-buffer buffer) @@ -291,21 +300,27 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text. (defun toc-tablist-follow () (interactive) - (let ((page (string-to-number (aref (tabulated-list-get-entry) 2)))) + (let ((ext (url-file-extension (buffer-file-name doc-buffer))) + (page (string-to-number (aref (tabulated-list-get-entry) 2)))) (pop-to-buffer doc-buffer) - (pdf-view-goto-page page) + (cond ((string= ".pdf" ext) (pdf-view-goto-page page)) + ((string= ".djvu" ext) (djvu-goto-page page))) (other-window 1))) -(defun toc-scroll-pdf-other-window-page-up () +(defun toc-scroll-other-window-page-up () (interactive) (other-window 1) - (pdf-view-next-page 1) + (let ((ext (url-file-extension (buffer-file-name (current-buffer))))) + (cond ((string= ".pdf" ext) (pdf-view-next-page 1)) + ((string= ".djvu" ext) (djvu-next-page 1)))) (other-window 1)) -(defun toc-scroll-pdf-other-window-page-down () +(defun toc-scroll-other-window-page-down () (interactive) (other-window 1) - (pdf-view-previous-page 1) + (let ((ext (url-file-extension (buffer-file-name (current-buffer))))) + (cond ((string= ".pdf" ext) (pdf-view-previous-page 1)) + ((string= ".djvu" ext) (djvu-prev-page 1)))) (other-window 1)) (defun toc-scroll-pdf-other-window-down () @@ -327,8 +342,8 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text. (define-key map [S-right] 'toc-increase) (define-key map [S-left] 'toc-decrease) (define-key map [tab] 'toc-tablist-follow) - (define-key map [S-down] 'toc-scroll-pdf-other-window-page-up) - (define-key map [S-up] 'toc-scroll-pdf-other-window-page-down) + (define-key map [S-down] 'toc-scroll-other-window-page-up) + (define-key map [S-up] 'toc-scroll-other-window-page-down) (define-key map [C-down] 'toc-scroll-pdf-other-window-up) (define-key map [C-up] 'toc-scroll-pdf-other-window-down) (define-key map "\C-c\C-c" 'toc-tablist-to-toc-source)