branch: externals/doc-toc
commit c86a72abda454a998d999b0da22435d2a78e6752
Author: Daniel Nicolai <[email protected]>
Commit: Daniel Nicolai <[email protected]>
Implement replace original or ad toc to copy of pdf
---
README.org | 9 ++++++---
toc-mode.el | 20 ++++++++++++++++----
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index 413f316a51..598540dabf 100644
--- a/README.org
+++ b/README.org
@@ -72,7 +72,7 @@ contain a structure like
1 Chapter 1 1
Section 1 2
#+END_SRC
-Here the indentation can be set with ~M-x replace-regexp~ ~^[^0-9]~ -> ~\&~
(where
+Here the indentation can be set with =M-x replace-regexp= ~^[^0-9]~ -> ~\&~
(where
there is a space character before the ~\&~).
Type =C-c C-c= when finished
@@ -96,5 +96,8 @@ 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=.
-For pdf the a file =pdfwithtoc.pdf= is created in the same folder as the
original
-pdf. For djvu, the TOC is simply added to the original djvu file.
+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
+directory or an absolute path can be given.
diff --git a/toc-mode.el b/toc-mode.el
index 3dc2dba2a2..09947d9e2e 100644
--- a/toc-mode.el
+++ b/toc-mode.el
@@ -24,10 +24,19 @@
;;; Code:
+(defgroup toc-mode nil
+ "Setting for the toc-mode package")
+(defcustom toc-replace-original-file t
+ "For PDF include TOC and replace old PDF file.
+For DJVU the old DJVU file is replaced by default"
+ :type 'boolean
+ :group 'toc-mode)
-(provide 'document-outliner)
-;;; document-outliner.el ends here
+(defcustom toc-destination-file-name "pdfwithtoc.pdf"
+ "Filename for new PDF if toc-replace-original-file is nil"
+ :type 'file
+ :group 'toc-mode)
;;;; toc-extract and cleanup
@@ -385,7 +394,9 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
(call-process "pdfoutline" nil "*pdfoutline*" nil
(concat (file-name-sans-extension (buffer-name)) ".pdf")
(buffer-name)
- "pdfwithtoc.pdf"))
+ (if toc-replace-original-file
+ (concat (file-name-sans-extension (buffer-name)) ".pdf")
+ toc-destination-file-name)))
(defun toc-add-to-djvu ()
"combine with add-toc-to-djvu in add-toc-to-document when ready"
@@ -447,5 +458,6 @@ Use with the universal argument (C-u) omits cleanup to get
the unprocessed text.
;; (print (mapcar #'(lambda (region) (pdf-info-gettext page region))
(pdf-info-line-regions regions)))))
;; (mapcar '(lambda (region) (pdf-info-gettext page region)) regions)))
-
+(provide 'toc-mode)
+;;; document-outliner.el ends here