From: Eli Zaretskii <eliz@gnu.org>
To: Visuwesh <visuweshm@gmail.com>, Tassilo Horn <tsdh@gnu.org>
Cc: 73530@debbugs.gnu.org
Subject: bug#73530: [PATCH] Add imenu index function for Djvu files in doc-view
Date: Sat, 28 Sep 2024 18:42:49 +0300 [thread overview]
Message-ID: <86msjr6ayu.fsf@gnu.org> (raw)
In-Reply-To: <8734ljg6f5.fsf@gmail.com> (message from Visuwesh on Sat, 28 Sep 2024 20:40:54 +0530)
> From: Visuwesh <visuweshm@gmail.com>
> 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.
next prev parent reply other threads:[~2024-09-28 15:42 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 15:10 bug#73530: [PATCH] Add imenu index function for Djvu files in doc-view Visuwesh
2024-09-28 15:42 ` Eli Zaretskii [this message]
2024-09-28 17:02 ` Tassilo Horn
2024-09-28 17:35 ` Visuwesh
2024-09-28 17:53 ` Eli Zaretskii
2024-09-28 18:11 ` Tassilo Horn
2024-09-28 19:03 ` jao
2024-09-28 19:15 ` Tassilo Horn
2024-09-28 19:50 ` Jose A. Ortega Ruiz
2024-09-29 14:03 ` Tassilo Horn
2024-09-29 14:34 ` Visuwesh
2024-09-29 16:20 ` Tassilo Horn
2024-09-29 16:38 ` Visuwesh
2024-09-29 17:15 ` Tassilo Horn
2024-09-30 17:29 ` Visuwesh
2024-10-02 6:42 ` Tassilo Horn
2024-10-02 8:19 ` Visuwesh
2024-10-02 14:53 ` Tassilo Horn
2024-10-03 8:03 ` Tassilo Horn
2024-10-03 11:10 ` Visuwesh
2024-10-03 12:11 ` Tassilo Horn
2024-10-03 14:51 ` Visuwesh
2024-10-04 5:31 ` Tassilo Horn
2024-10-04 7:31 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86msjr6ayu.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=73530@debbugs.gnu.org \
--cc=tsdh@gnu.org \
--cc=visuweshm@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).