all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: dalanicolai <dalanicolai@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: [ELPA] New package: toc-mode
Date: Tue, 20 Sep 2022 18:03:34 -0400	[thread overview]
Message-ID: <jwvk05xra82.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CACJP=3k2hqPhbs4ssYQzkDp=a=qsjJFmi_Oq=cGJjTpVwSwy2w@mail.gmail.com> (dalanicolai@gmail.com's message of "Tue, 20 Sep 2022 14:33:26 +0200")

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: toc-mode.patch --]
[-- Type: text/x-diff, Size: 4581 bytes --]

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)))

[-- Attachment #3: toc-mode.warnings --]
[-- Type: text/plain, Size: 1004 bytes --]

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.

  parent reply	other threads:[~2022-09-20 22:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 12:33 [ELPA] New package: toc-mode dalanicolai
2022-09-20 15:57 ` Jean Louis
2022-09-20 20:51   ` Emanuel Berg
2022-09-20 17:37 ` Philip Kaludercic
2022-09-21  6:57   ` dalanicolai
2022-09-21  7:09     ` Emanuel Berg
2022-09-21 16:55       ` dalanicolai
2022-09-21 16:58       ` dalanicolai
2022-09-21  7:46     ` Philip Kaludercic
2022-09-20 18:04 ` Stefan Kangas
2022-09-20 21:30 ` Jose A Ortega Ruiz
2022-09-21  7:12   ` dalanicolai
2022-09-22  8:02     ` Jean Louis
2022-09-22 15:27     ` Jose A Ortega Ruiz
2022-09-20 22:03 ` Stefan Monnier [this message]
2022-09-21  7:18   ` dalanicolai
2022-09-21  7:19     ` dalanicolai
2022-09-25 11:44 ` Visuwesh
2022-09-25 16:47   ` dalanicolai
2022-09-25 16:57     ` dalanicolai
2022-09-25 17:13     ` Yuri Khan
2022-09-25 21:18       ` dalanicolai
2022-09-25 21:37         ` Philip Kaludercic
2022-09-26  4:55           ` dalanicolai
2022-09-26 16:09     ` Visuwesh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk05xra82.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dalanicolai@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.