From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [ELPA] New package: toc-mode Date: Tue, 20 Sep 2022 18:03:34 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26447"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Emacs Devel To: dalanicolai Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 21 01:57:28 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oan7H-0006ij-Ml for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Sep 2022 01:57:28 +0200 Original-Received: from localhost ([::1]:37202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oan7G-0005DP-Lm for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Sep 2022 19:57:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oalLE-0006rV-Ak for emacs-devel@gnu.org; Tue, 20 Sep 2022 18:03:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oalLA-0002kk-HT for emacs-devel@gnu.org; Tue, 20 Sep 2022 18:03:42 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 110F080758; Tue, 20 Sep 2022 18:03:38 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C48FE80576; Tue, 20 Sep 2022 18:03:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1663711415; bh=H3rB5wZb2lzGAqpUxcX7XtUWfLW6w4IT0PuRtLp3mr0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=W9RuGy338tR215qt1rmbATI8D40gIE04CqWm8/1QoyN11OC/8PsEN2pLJwY+/I+Qx shM7JdVXRIRnmjGtGHtrDA0IluHetQX0mR32wees9MGY7wQrcjCKTIjZi8yNwze0Rg CioF77aHh3Uy8nbc6kmwKXPNbSqCxddsi9EWS000uotF29qPWzqEBnGVfQ6+xIM1MJ 9/qoQiGStnW6fjoBOiGx8B4hDl5PaTio3jfyX+zX+x4utbJbD7fj4TnkdI88dvQ9Jy SSnhEtycl9iunAo3w5PFw1NX9U2FtjgkQgfcRPvhweQ1wce9oeyUDg8Ayfm7iSet2R Im2eXL2p06kIg== Original-Received: from pastel (unknown [157.52.9.190]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9424C12023A; Tue, 20 Sep 2022 18:03:35 -0400 (EDT) In-Reply-To: (dalanicolai@gmail.com's message of "Tue, 20 Sep 2022 14:33:26 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295844 Archived-At: --=-=-= Content-Type: text/plain > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=toc-mode.patch 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))) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename=toc-mode.warnings Content-Transfer-Encoding: quoted-printable 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 chara= cters In toc--create-tablist-buffer: packages/toc-mode/toc-mode.el:624:2: Warning: docstring wider than 80 chara= cters In toc--increase-remaining-and-follow: packages/toc-mode/toc-mode.el:742:2: Warning: docstring wider than 80 chara= cters In toc--decrease-remaining-and-follow: packages/toc-mode/toc-mode.el:748:2: Warning: docstring wider than 80 chara= cters In toc--add-to-pdf: packages/toc-mode/toc-mode.el:973:2: Warning: docstring wider than 80 chara= cters In toc--add-to-djvu: packages/toc-mode/toc-mode.el:984:2: Warning: docstring wider than 80 chara= cters In end of data: packages/toc-mode/toc-mode.el:281:42: Warning: the function =E2=80=98pdf-vi= ew-active-region-text=E2=80=99 might not be defined at runtime. packages/toc-mode/toc-mode.el: Warning: the function =E2=80=98image-mode-wi= ndow-get=E2=80=99 might not be defined at runtime. --=-=-=--