[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELPA] New package: toc-mode
From: |
Stefan Monnier |
Subject: |
Re: [ELPA] New package: toc-mode |
Date: |
Tue, 20 Sep 2022 18:03:34 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> This package has been for a while on MELPA now, but it would be nice if it
> could be moved to ELPA. The source can be found at
> https://github.com/dalanicolai/toc-mode.
>
> I would like to mention that the PDF functionalities largely depend on
> pdf-tools, which is not on ELPA of course (doc-view unfortunately does
> not provide the right features). I am not sure if that somehow is
> a problem.
Since pdf-tools is in NonGNU ELPA, this is not a problem, no.
> The package description is:
>
> Create, cleanup, add and manage Table Of Contents (TOC) of pdf and djvu
> documents with Emacs
Sounds handy, thanks. FWIW, I tend to agree with Jean that the name
suggests its purpose is more general (more like a kind of speedbar/imenu
maybe). Furthermore the "-mode" part of the name suggests it's a major
mode to edit some standard "toc" files rather than an actual tool to
extract things for non-toc files and then edit those files.
So I'd support a renaming (in case you're out of ideas, maybe
"toc-edit/edit-doc-toc", tho maybe "create-doc-toc" is more precise
since it doesn't seem to care very much about editing an existing toc),
but I don't have a strong opinion about it.
Once you've made up your mind about the package name, let me know so
I can add it to `elpa.git`.
> ready for ELPA (although I guess it is already ready for publishing on
> ELPA).
Indeed, except for the copyright line which needs to be adjusted.
The patch below does that along with the obligatory cosmetic tweaks.
I also include the remaining compilation warnings.
Stefan
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 <dalanicolai@gmail.com>
;; 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)))
Byte compiling packages/toc-mode/toc-mode.el
In toc--cleanup-lines-roman-string:
packages/toc-mode/toc-mode.el:370:2: Warning: docstring wider than 80 characters
In toc--create-tablist-buffer:
packages/toc-mode/toc-mode.el:624:2: Warning: docstring wider than 80 characters
In toc--increase-remaining-and-follow:
packages/toc-mode/toc-mode.el:742:2: Warning: docstring wider than 80 characters
In toc--decrease-remaining-and-follow:
packages/toc-mode/toc-mode.el:748:2: Warning: docstring wider than 80 characters
In toc--add-to-pdf:
packages/toc-mode/toc-mode.el:973:2: Warning: docstring wider than 80 characters
In toc--add-to-djvu:
packages/toc-mode/toc-mode.el:984:2: Warning: docstring wider than 80 characters
In end of data:
packages/toc-mode/toc-mode.el:281:42: Warning: the function
‘pdf-view-active-region-text’ might not be defined at runtime.
packages/toc-mode/toc-mode.el: Warning: the function ‘image-mode-window-get’
might not be defined at runtime.
- Re: [ELPA] New package: toc-mode, (continued)
Re: [ELPA] New package: toc-mode, Stefan Kangas, 2022/09/20
Re: [ELPA] New package: toc-mode, Jose A Ortega Ruiz, 2022/09/20
Re: [ELPA] New package: toc-mode,
Stefan Monnier <=
Re: [ELPA] New package: toc-mode, Visuwesh, 2022/09/25
- Re: [ELPA] New package: toc-mode, dalanicolai, 2022/09/25
- Re: [ELPA] New package: toc-mode, dalanicolai, 2022/09/25
- Re: [ELPA] New package: toc-mode, Yuri Khan, 2022/09/25
- Re: [ELPA] New package: toc-mode, dalanicolai, 2022/09/25
- Re: [ELPA] New package: toc-mode, Philip Kaludercic, 2022/09/25
- Re: [ELPA] New package: toc-mode, dalanicolai, 2022/09/26
Re: [ELPA] New package: toc-mode, Visuwesh, 2022/09/26