branch: externals/doc-toc commit 34d16c6c06aa3c31421fdc3ade60c5b1dd8ed631 Author: Daniel Nicolai <dalanico...@gmail.com> Commit: Daniel Nicolai <dalanico...@gmail.com>
implement pdf navigation from TOC-tabular-mode --- README.org | 11 ++++++++--- toc-mode.el | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index 05470ad73e..13bd922066 100644 --- a/README.org +++ b/README.org @@ -70,9 +70,14 @@ Type =C-c C-c= when finished ** 3 TOC-tabular (adjust pagenumbers) This mode provides the functionality for easy adjustment of pagenmumbers. The -buffer can be navigated with the arrow =up/down= keys. The =left= and =right= -arrow keys will shift =down/up= all the page numbers from the current line and -below (combine with =SHIFT= for setting individual pagenumbers). +buffer can be navigated with the arrow =up/down= keys. The =left= and =right= arrow +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= +will scroll smoothly in that window. Type =C-c C-c= when done diff --git a/toc-mode.el b/toc-mode.el index ffdc2a817e..979e3fef19 100644 --- a/toc-mode.el +++ b/toc-mode.el @@ -51,6 +51,8 @@ (defun toc-cleanup-lines-roman-string (&optional arg) (interactive) (beginning-of-buffer) + ;; (re-search-forward "^ *[ivx0-9\\.]+ *$" nil t) + ;; (replace-match "") (while (not (eobp)) (re-search-forward "^ *[ivx0-9\\.]* *$") (replace-match "") @@ -75,9 +77,9 @@ (replace-match (format "Contents %s" startpage))) (toc-cleanup-lines-contents-string) (toc-cleanup-dots) - (toc-cleanup-lines-roman-string) + ;; (toc-cleanup-lines-roman-string) (toc-cleanup-blank-lines) - (toc-join-unnumbered-lines) + (toc-join-next-unnumbered-lines) ) (defun get-index-levels (seperator) @@ -125,9 +127,10 @@ (shell-quote-argument buffer-file-name)))) (buffer (get-buffer-create (file-name-sans-extension (buffer-name))))) (switch-to-buffer buffer) + (toc-cleanup-mode) ;; required before setting local variable (setq-local doc-buffer source-buffer) (insert text) - (kill-whole-line) + ;; (kill-whole-line) )) @@ -136,7 +139,6 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text." (interactive "nEnter start-pagenumber for extraction: \nnEnter end-pagenumber for extraction: \nP") (document-extract-pages-text startpage endpage) - (toc-cleanup-mode) (unless arg (toc-cleanup startpage))) @@ -157,11 +159,15 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text. (setq-local doc-buffer source-buffer) (insert text))) +(defun toc-create-tablist-buffer () + (interactive) + (toc-list doc-buffer)) + ;;;; toc major modes (defvar toc-cleanup-mode-map (let ((map (make-sparse-keymap))) - (define-key map "\C-c\C-c" 'toc-list) + (define-key map "\C-c\C-c" 'toc-create-tablist-buffer) (define-key map "\C-c\C-j" 'toc-join-next-unnumbered-lines) map)) @@ -249,7 +255,7 @@ 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)))) - (pop-to-buffer pdf-buffer) + (pop-to-buffer doc-buffer) (pdf-view-goto-page page) (other-window 1))) @@ -297,11 +303,13 @@ Use with the universal argument (C-u) omits cleanup to get the unprocessed text. (setq-local tabulated-list-format [("level" 10 nil) ("name" 80 nil) ("page" 1 nil)]) (tabulated-list-init-header)) -(defun toc-list () +(defun toc-list (buffer) (interactive) - (let ((toc-tablist (toc-convert-to-tabulated-list))) + (let ((source-buffer buffer) + (toc-tablist (toc-convert-to-tabulated-list))) (switch-to-buffer (concat (buffer-name) ".list")) (toc-tabular-mode) + (setq-local doc-buffer source-buffer) (setq-local tabulated-list-entries toc-tablist) (tabulated-list-print)))