From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73530: [PATCH] Add imenu index function for Djvu files in doc-view Date: Sat, 28 Sep 2024 18:42:49 +0300 Message-ID: <86msjr6ayu.fsf@gnu.org> References: <8734ljg6f5.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3804"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73530@debbugs.gnu.org To: Visuwesh , Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 28 18:10:59 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sua26-0000pU-Ic for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 28 Sep 2024 18:10:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sua1m-0004KJ-3R; Sat, 28 Sep 2024 12:10:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sua1f-0004K2-TX for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 12:10:32 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sua1f-0004U4-KY for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 12:10:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=6eQ0stYTqfqHZ7sVw8EI7AJIaBKYCsAlTGkKcXTzNJ0=; b=HFwNqWUfsn6CwI8Fz9SZa/cOqNolz/qPzB2k1Ke9557oIRKjZ7soj/stiJPOIGBxYv+04PNoWgZwxaJDc4lOXzpoEhGxhJai2Cg7DpBnr5cNUp9k0XqhuGBBzOP8amhU2ZLMbFUSBf/d56iAK8pdGYWKcRqpQuBcbor7wtp+Kd4OByBBJ9kQ68zqFjVAEaS+C4HzhBtVA5oS48CupVJjgFw0PQlKBa1KAjrCVOhtJeVxDt0bwbrT+0hMBUc1MMzS6GdtjLuJdh+dzShWJ1RgL0iV3BtkylwfymkY2K22hFbhqc4NRPA5vYpNCT2vxiW5ZZwD3P3e9MeBYCtyEe6t3w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sua29-000248-Mf for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2024 12:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2024 16:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73530 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73530-submit@debbugs.gnu.org id=B73530.17275398147273 (code B ref 73530); Sat, 28 Sep 2024 16:11:01 +0000 Original-Received: (at 73530) by debbugs.gnu.org; 28 Sep 2024 16:10:14 +0000 Original-Received: from localhost ([127.0.0.1]:37901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sua1O-0001tD-2X for submit@debbugs.gnu.org; Sat, 28 Sep 2024 12:10:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suZdb-0008La-S0 for 73530@debbugs.gnu.org; Sat, 28 Sep 2024 11:45:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1suZaw-0001SG-Tm; Sat, 28 Sep 2024 11:42:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6eQ0stYTqfqHZ7sVw8EI7AJIaBKYCsAlTGkKcXTzNJ0=; b=OknNtoL+CsxE Pusxbv4egCKZ+ZvoihHTXx2g5VPvDJl5fc0ctMW5/qnGW3Vg2pGKk9sZ/w1RWltuKQt9oVxWFQBKj EOrmg+uFAqGunYC9Jtb3bAi5D8x9ZuLhLObOXbwJGXsfTAbS+dSduehJFI3VPuHkUUNE7rH/EX+cL jckuO2UBxsflGjhDaGhyXvt/fLzV7LBwqptBS/+M3ZZOAZaRWVGtAjpjVkxCbiLryB5gSBXbSQs1b R6gen6TlMh+kOqLRq+zCDkYapjDTtjRCg/FWFJk2M2VkLz99mTlrTK4UqXtk7NJVKPAX16HiOurjG mWbKKcelrUeuFRxHRE/Krw==; In-Reply-To: <8734ljg6f5.fsf@gmail.com> (message from Visuwesh on Sat, 28 Sep 2024 20:40:54 +0530) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292584 Archived-At: > From: Visuwesh > Date: Sat, 28 Sep 2024 20:40:54 +0530 > > > Attached patch adds a function to create imenu index for Djvu files > using djvused. If you do not have a Djvu file available, I can point to > a file from libgen that can be used as a test file. Thanks, but can we please not hard-code names of programs, and instead use variables that can be adjusted by users? I know that "mutool" was hard-coded, but adding more hard-coded programs sounds too much. Adding Tassilo to the discussion. > + When the @command{mutool} or the @command{djvused} program is > +available, DocView will use it to generate entries for an outline menu, > +making it accessible via the @code{imenu} facility (@pxref{Imenu}). To > +disable this functionality even when the required program can be found > +on your system, customize the variable @code{doc-view-imenu-enabled} to > +the @code{nil} value. You can further customize how @code{imenu} items > +are formatted and displayed using the variables > +@code{doc-view-imenu-format} and @code{doc-view-imenu-flatten}. This is misleading, I think: it leaves the impression that the two tools are interchangeable, where in reality each one supports different format of files. The text should say explicitly that one is for PDF, the other for Djvu. > -(defcustom doc-view-imenu-enabled (and (executable-find "mutool") t) > - "Whether to generate an imenu outline when \"mutool\" is available." > +(defcustom doc-view-imenu-enabled (and (or (executable-find "mutool") > + (executable-find "djvused")) > + t) > + "Whether to generate an imenu outline when available. "When available" sounds awkward. "When possible", perhaps? Also, "generate imenu outline" is too general. Don't forget that the first line of a doc string is shown by apropos commands, and so should speak for itself. I would say Whether to generate imenu outline for PDF and DJVU files. The "when available" part is unnecessary, because Emacs checks for availability, and the user can override that. > +Optional argument LEVEL is the current heading level. If nil, then 1 is > +used." Optional argument LEVEL is the current heading level, which defaults to 1. > +(defun doc-view--outline (&optional file-name) > + "Return the outline for the file FILE-NAME. > +If FILE-NAME is nil, use the current file instead." Since FILE-NAME can be omitted, it is better to use our usual style: If FILE-NAME is nil or omitted, it defaults to the current buffer's file name. > + (unless file-name (setq file-name (buffer-file-name))) > + (pcase doc-view-doc-type > + ('djvu > + (when (executable-find "djvused") > + (doc-view--djvu-outline file-name))) > + (_ > + (when (executable-find "mutool") > + (doc-view--pdf-outline file-name))))) We already tested that the relevant tool is available, so why test that here again? Thanks.