GNU bug report logs - #58103
[PATCH] docview: imenu access to table of contents

Previous Next

Package: emacs;

Reported by: Jose A Ortega Ruiz <jao <at> gnu.org>

Date: Tue, 27 Sep 2022 05:42:01 UTC

Severity: normal

Tags: patch

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58103 in the body.
You can then email your comments to 58103 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Tue, 27 Sep 2022 05:42:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jose A Ortega Ruiz <jao <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 27 Sep 2022 05:42:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jose A Ortega Ruiz <jao <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] docview: imenu access to table of contents
Date: Tue, 27 Sep 2022 06:41:14 +0100
[Message part 1 (text/plain, inline)]
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).

Cheers,
jao


In GNU Emacs 29.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.16.0) of 2022-09-26 built on rivendell
Repository revision: adcdea5d159540aa09892f410bd3a5163eebecf2
Repository branch: master
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure -C --prefix=/usr/local/stow/pemacs --with-pgtk
 --with-imagemagick'

[0001-docview-imenu-access-to-table-of-contents.patch (text/patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Give a man a fish and you feed him for a day. Write a program to fish for him
and you maintain it for a lifetime. - Tim Hopper

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Tue, 27 Sep 2022 11:54:02 GMT) Full text and rfc822 format available.

Message #8 received at 58103 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jose A Ortega Ruiz <jao <at> gnu.org>
Cc: 58103 <at> debbugs.gnu.org
Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents
Date: Tue, 27 Sep 2022 13:53:30 +0200
Jose A Ortega Ruiz <jao <at> gnu.org> writes:

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

Looks good to me; pushed to Emacs 29.

(Using `let-alist' is pretty unusual, but I guess it's nice that
somebody does -- there only seems to be two other usages in-tree in
Emacs since this was added in 2014.  🙃)




bug marked as fixed in version 29.1, send any further explanations to 58103 <at> debbugs.gnu.org and Jose A Ortega Ruiz <jao <at> gnu.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 27 Sep 2022 11:54:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Tue, 27 Sep 2022 16:19:02 GMT) Full text and rfc822 format available.

Message #13 received at 58103 <at> debbugs.gnu.org (full text, mbox):

From: Jose A Ortega Ruiz <jao <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 58103 <at> debbugs.gnu.org
Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents
Date: Tue, 27 Sep 2022 17:18:41 +0100
On Tue, Sep 27 2022, Lars Ingebrigtsen wrote:

> Jose A Ortega Ruiz <jao <at> gnu.org> writes:
>
>> 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. 
>
> Looks good to me; pushed to Emacs 29.

excellent, thanks a lot!

> (Using `let-alist' is pretty unusual, but I guess it's nice that
> somebody does -- there only seems to be two other usages in-tree in
> Emacs since this was added in 2014.  🙃)

i find it handy when the let body is small, otherwise it can make things
harder to read.  but i'm not specially attached to it if we prefer more
idiomatic ways.

cheers,
jao




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Wed, 28 Sep 2022 22:02:01 GMT) Full text and rfc822 format available.

Message #16 received at 58103 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Martín <mardani29 <at> yahoo.es>
To: Jose A Ortega Ruiz <jao <at> gnu.org>
Cc: 58103 <at> debbugs.gnu.org
Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents
Date: Thu, 29 Sep 2022 00:00:54 +0200
Jose A Ortega Ruiz <jao <at> gnu.org> 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 <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Wed, 28 Sep 2022 22:54:02 GMT) Full text and rfc822 format available.

Message #19 received at 58103 <at> debbugs.gnu.org (full text, mbox):

From: Jose A Ortega Ruiz <jao <at> gnu.org>
To: Daniel Martín <mardani29 <at> yahoo.es>
Cc: 58103 <at> debbugs.gnu.org
Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents
Date: Wed, 28 Sep 2022 23:53:42 +0100
Hi Daniel,

[...]

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

Hmm, i cannot reproduce it. When i try for instance M-g i for a PDF
without outline i just get back an error message telling me that there
is no imenu.

I have mutool 1.20, so maybe that's the difference.  What's the output
of this command in a terminal for you:

     mutool show file.pdf outline    

with file.pdf one of those without an outline?  Do you have any
imenu-related variable customized to a non-default value?

Thanks for your help,
jao
-- 
The mind commands the body and the body obeys. The mind commands itself and
finds resistance.
 -St. Augustine (354-430)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58103; Package emacs. (Thu, 29 Sep 2022 12:50:01 GMT) Full text and rfc822 format available.

Message #22 received at 58103 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Martín <mardani29 <at> yahoo.es>
To: Jose A Ortega Ruiz <jao <at> gnu.org>
Cc: 58103 <at> debbugs.gnu.org
Subject: Re: bug#58103: [PATCH] docview: imenu access to table of contents
Date: Thu, 29 Sep 2022 14:48:57 +0200
Jose A Ortega Ruiz <jao <at> gnu.org> writes:

> I have mutool 1.20, so maybe that's the difference.  What's the output
> of this command in a terminal for you:
>
>      mutool show file.pdf outline    
>
> with file.pdf one of those without an outline?  Do you have any
> imenu-related variable customized to a non-default value?

The above command does not print any output if the PDF does not have an
outline.  And I haven't configured any imenu variable, I tested with
plain emacs -Q.

Thanks.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 28 Oct 2022 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 178 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.