diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..26152f633d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.elc +/toc-mode-autoloads.el +/toc-mode-pkg.el diff --git a/toc-mode.el b/toc-mode.el index 11a70566fd..7817c5d842 100644 --- a/toc-mode.el +++ b/toc-mode.el @@ -1,5 +1,5 @@ ;;; toc-mode.el --- Manage outlines/table of contents of pdf and djvu documents -*- lexical-binding: t; -*- -;; Copyright (C) 2020 Daniel Laurens Nicolai +;; Copyright (C) 2020-2022 Free Software Foundation, Inc. ;; Author: Daniel Laurens Nicolai ;; Version: 0 @@ -235,13 +235,11 @@ (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) + :type 'boolean) (defcustom toc-destination-file-name "pdfwithtoc.pdf" "Filename for new PDF if `toc-replace-original-file' is nil." - :type 'file - :group 'toc) + :type 'file) (defcustom toc-ocr-languages nil "Languages used for extraction with ocr. @@ -249,21 +247,18 @@ Should be one or multiple language codes as recognized by tesseract -l flag, e.g. eng or eng+nld. Use \\[execute-extended-command] `toc-list-languages' to list the available languages." - :type 'string - :group 'toc) + :type 'string) (defcustom toc-handyoutliner-path nil "Path to handyoutliner executable. String (i.e. surround with double quotes). See URL`http://handyoutlinerfo.sourceforge.net/'." - :type 'file - :group 'toc) + :type 'file) (defcustom toc-file-browser-command nil "Command to open file browser. String (i.e. surround with double quotes)." - :type 'file - :group 'toc) + :type 'file) ;;;; pdf.tocgen ;;;###autoload @@ -276,7 +271,7 @@ document's directory. You will be prompted to enter the LEVEL number. The highest level should have number 1, the next leve number 2 etc." (interactive "nWhich level you are setting (number): ") - (let* ((page (eval (pdf-view-current-page))) + (let* ((page (pdf-view-current-page)) (filename (url-filename (url-generic-parse-url buffer-file-name))) (pdfxmeta-result (shell-command (format "pdfxmeta --auto %s --page %s '%s' \"%s\" >> recipe.toml" @@ -417,7 +412,7 @@ Prefix with numeric ARG prefix to apply to the next ARG lines." "Cleanup extracted Table Of Contents by running a series of cleanup functions. It executes the following steps: 1. insert a Contents entry with pagenumber CONTENTS-PAGE -2. delete subsequent lines containing the string 'contents' +2. delete subsequent lines containing the string \"contents\" 3. tries to delete redundant dots 4. deletes lines that containi only roman numerals and linefeed characters 5. deletes @@ -560,7 +555,7 @@ unprocessed text." ;; nil ;; (number-to-string page) ;; (image-property djvu-doc-image :data)))))) - (apply 'call-process + (apply #'call-process (append (list "tesseract" nil (list buffer nil) nil file) args)) (setq page (1+ page)))) @@ -620,7 +615,7 @@ Prompt for startpage and endpage and print OCR output to new buffer." nil (number-to-string page) (image-property djvu-doc-image :data)))))) - (apply 'call-process + (apply #'call-process (append (list "tesseract" nil (list buffer nil) nil file) args)) (setq page (1+ page)))) @@ -634,12 +629,12 @@ Prompt for startpage and endpage and print OCR output to new buffer." ;;;; toc major modes (when (require 'pdf-tools nil t) - (define-key pdf-view-mode-map (kbd "C-c C-e") 'toc-extract-pages) - (define-key pdf-view-mode-map (kbd "C-c e") 'toc-extract-pages-ocr)) + (define-key pdf-view-mode-map (kbd "C-c C-e") #'toc-extract-pages) + (define-key pdf-view-mode-map (kbd "C-c e") #'toc-extract-pages-ocr)) (when (require 'djvu nil t) - (define-key djvu-read-mode-map (kbd "C-c C-e") 'toc-extract-pages) - (define-key djvu-read-mode-map (kbd "C-c e") 'toc-extract-pages-ocr)) + (define-key djvu-read-mode-map (kbd "C-c C-e") #'toc-extract-pages) + (define-key djvu-read-mode-map (kbd "C-c e") #'toc-extract-pages-ocr)) (defvar toc-cleanup-mode-map (let ((map (make-sparse-keymap)))