Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents

From: Daniel Martín <[email-masked]>
Date: Thu, 29 Sep 2022 00:00:54 +0200

Jose A Ortega Ruiz <[email-masked]> writes:

> Tags: patch
>
>
> Hi,
>
> The patch below provides a quite simple implemetation of an imenu for
> doc-view, using mutool.  That means of course that is limited to systems
> where it's installed, and doesn't try to be too smart, but it's been
> working quite well for me.  It needs a slight tweak to imenu.el to add a
> knob inhibiting it to push all entries with submenus to the top, which
> doesn't make sense when those entries represent sections of a TOC.
>
> If this is acceptable (with any needed modification, of course), i guess
> we could also add a bit of further customization, like perhaps a "flat
> mode", or whether or not the section titles include page numbers, but
> i'm not sure if that's desired (in my usage, i never want either).

Thanks for working on this! I've given it a try, and I get the following
error when the PDF does not have an outline (starting from emacs -Q):

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("\\`%PDF-1\\'" nil)
  imenu-find-default("%PDF-1" (("*Rescan*" . -99) (nil)))
  imenu--completion-buffer((("*Rescan*" . -99) nil) nil)
  imenu-choose-buffer-index()
  byte-code("\300 C\207" [imenu-choose-buffer-index] 1)
  call-interactively(imenu record nil)
  command-execute(imenu record)
  execute-extended-command(nil "imenu" "imenu")
  funcall-interactively(execute-extended-command nil "imenu" "imenu")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Can you reproduce the same issue as well?  I'm using mutool version
1.19.0.

In GNU Emacs 29.0.50 (build 8, aarch64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.6 (Build 21G115)) of 2022-09-28 built on
 Daniels-MacBook-Pro.local
Repository revision: b6a163ba7cdf57eff5542b4cb6956780ebb2880f
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.6

Configured using:
 'configure CPPFLAGS=-I/opt/homebrew/opt/openjdk@11/include'

Configured features:
ACL DBUS GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER
PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS WEBP XIM ZLIB