[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/doc-toc 3acf45b0f7 18/84: Implement C-c C-c functionali
From: |
ELPA Syncer |
Subject: |
[elpa] externals/doc-toc 3acf45b0f7 18/84: Implement C-c C-c functionality also for djvu |
Date: |
Mon, 26 Sep 2022 13:58:35 -0400 (EDT) |
branch: externals/doc-toc
commit 3acf45b0f781b745f078307f004a83d91defa37e
Author: Daniel Nicolai <dalanicolai@gmail.com>
Commit: Daniel Nicolai <dalanicolai@gmail.com>
Implement C-c C-c functionality also for djvu
---
README.org | 10 +++++-----
toc-mode.el | 30 +++++++++++++++++++++---------
2 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/README.org b/README.org
index f4c9a0c20e..c5e3658548 100644
--- a/README.org
+++ b/README.org
@@ -92,16 +92,16 @@ 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.
-For pdf type =C-c C-c= when done. For djvu type =M-x toc-tablist-to-djvused=.
+For type =C-c C-c= when done.
** 4. TOC-mode (add outline to document)
The text of this buffer should have the right structure for adding the contents
to (for pdf's a copy of) the original document. Final adjusments can be done
but
-should not be necessary. For pdf just type =C-c C-c= for adding the contents
to the
-document. For djvu type =M-x toc-add-to-djvu=.
+should not be necessary. Type =C-c C-c= for adding the contents to the
+document.
By default, the TOC is simply added to the original file. ONLY FOR PDF's, if
the
(customizable) variable ~toc-replace-original-file~ is ~nil~, then the TOC is
added
-to a copy of the original pdf file with path as defined by the variable
-~toc-destination-file-name~, where either a relative path to the original file
+to a copy of the original pdf file with the path as defined by the variable
+~toc-destination-file-name~. Either a relative path to the original file
directory or an absolute path can be given.
diff --git a/toc-mode.el b/toc-mode.el
index 4d17187e0a..f5f2289d87 100644
--- a/toc-mode.el
+++ b/toc-mode.el
@@ -1,4 +1,4 @@
-;;; document-outliner.el --- Manage outlines of pdf and djvu document -*-
lexical-binding: t; -*-
+;; document-outliner.el --- Manage outlines of pdf and djvu document -*-
lexical-binding: t; -*-
;; Copyright (C) 2020 Daniel Laurens Nicolai
@@ -331,7 +331,7 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(define-key map [S-up] 'toc-scroll-pdf-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-pdfoutline)
+ (define-key map "\C-c\C-c" 'toc-tablist-to-toc-source)
map))
(define-derived-mode toc-tabular-mode
@@ -354,7 +354,7 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(defvar toc-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map "\C-c\C-c" 'toc-add-to-pdf)
+ (define-key map "\C-c\C-c" 'toc-add-to-doc)
map))
(define-derived-mode toc-mode
@@ -367,7 +367,8 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(defun toc-tablist-to-pdfoutline ()
(interactive)
(beginning-of-buffer)
- (let (text)
+ (let ((source-buffer doc-buffer)
+ text)
(while (not (eobp))
(let ((v (tabulated-list-get-entry)))
(setq text (concat text (format "%s %s %s\n" (aref v 0) (aref v 2)
(aref v 1) )))
@@ -375,6 +376,7 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(switch-to-buffer (find-file (concat (file-name-sans-extension
(buffer-name)) ".txt")))
(erase-buffer)
(toc-mode)
+ (setq-local doc-buffer source-buffer)
(insert text)))
;;;; djvu parse tablist to outline
@@ -403,15 +405,20 @@ Use with the universal argument (C-u) omits cleanup to
get the unprocessed text.
(outline (append bookmarks (toc-parse-djvused 0))))
(while (not (eobp))
(setq outline (append outline (toc-parse-djvused 0))))
- (let ((text (format "%S" outline)))
+ (let ((source-buffer doc-buffer)
+ (text (format "%S" outline)))
(switch-to-buffer (find-file (concat (file-name-sans-extension
(buffer-name)) ".txt")))
(erase-buffer)
+ (toc-mode)
+ (setq-local doc-buffer source-buffer)
(insert text))))
-;; (defun toc-tablist-to-toc-source ()
-;; (cond ((string= ".pdf" ext) "pdftotext -f %s -l %s -layout %s -")
-;; ((string= ".djvu" ext) "djvutxt --page=%s-%s %s")
-;; (t (error "Buffer-filename does not have pdf or djvu extension"))))
+(defun toc-tablist-to-toc-source ()
+ (interactive)
+ (let ((ext (url-file-extension (buffer-file-name doc-buffer))))
+ (cond ((string= ".pdf" ext) (toc-tablist-to-pdfoutline))
+ ((string= ".djvu" ext) (print "this is DJVU")
(toc-tablist-to-djvused))
+ (t (error "Buffer-source-file does not have pdf or djvu
extension")))))
;;;; add outline to document
@@ -438,6 +445,11 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(concat (file-name-sans-extension (buffer-name))
".djvu"))))))
+(defun toc-add-to-doc ()
+ (interactive)
+ (let ((ext (url-file-extension (buffer-file-name doc-buffer))))
+ (cond ((string= ".pdf" ext) (toc-add-to-pdf))
+ ((string= ".djvu" ext) (toc-add-to-djvu)))))
;;;; PDF-Tools functions (PDF-tools does not yet produce best layout, e.g. try
pdf-extract-page-lines)
(defun pdf-extract-page-text (&optional arg)
- [elpa] externals/doc-toc e84c00c923 45/84: Fix/remove ask for path before add TOC djvu, (continued)
- [elpa] externals/doc-toc e84c00c923 45/84: Fix/remove ask for path before add TOC djvu, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc eb8c6a0c00 56/84: Fix seq and cl compiler warnings, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 05b6d034aa 59/84: Fix djvu/pdf hard dependency (github issue #3), ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 8d4817a543 62/84: Fix org-noter conflict (github #4), ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc a14dbb4c25 67/84: Fix beginning-of-buffer compilation warning, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 102e14199c 65/84: pdf.tocgen replace original pdf, and show message on fail, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 4c9ce0f54d 76/84: Fix: eval-when-compile pdf-tools, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 2ec9515f0d 81/84: Apply patch S. Monnier, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc ca80abf2f8 83/84: Update name to doc-toc (i.e. make doc-tools extension), ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 3d286633a9 11/84: Update README, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 3acf45b0f7 18/84: Implement C-c C-c functionality also for djvu,
ELPA Syncer <=
- [elpa] externals/doc-toc 74c68f0cda 24/84: Update README.org, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc f8fbca0c41 23/84: README add features and keybindings, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc f643745b06 32/84: Set windows encoding for djvu, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc c521029525 36/84: Change (beginning-og-buffer) to (goto-char (point-min)) for MELPA, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc a1d26eceb5 37/84: Add defvar and declare-function to avoid warning MELPA, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 05cd1287f1 42/84: Fix toc--add-to-djvu. Don't ask save location., ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc f430243a88 43/84: Add version: 0 header, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 59f4471e6a 50/84: Update README.org, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 2d95c466a3 48/84: Add MELPA and GPL3 badges, ELPA Syncer, 2022/09/26
- [elpa] externals/doc-toc 734043bdc7 47/84: Improve documentation in toc-mode.el, ELPA Syncer, 2022/09/26