Closed dit7ya closed 3 years ago
Is there a reason why the pdf-view-goto-label
command (bound to M-g l
) falls short for you? If so, please describe the expected behavior and please attach a test PDF where I can reproduce the problem to the ticket
Thanks, Vedang
Ummm, pdf-view-goto-label
just lets me jump to any of the pages by number, while something like Okular
shows a nice clickable table of contents in the sidebar. A test pdf would be - https://github.com/sarabander/sicp-pocket/blob/master/sicp-pocket.pdf
Okay, thanks for the explanation.
I am thinking that the best way to provide this experience would be to provide a tablist of places to jump into the PDF, building off of the TOC.
I will track this in my list of features to build. In the meantime, I will happily accept a PR implementing this feature. If anyone is interested, they can checkout the implementation of listing annotations and the implementation of searching across links to get an idea of how this could be done.
How about `pdf-outline'? It produces a buffer that is similar to okular's TOC.
More about the buffer itself:
It derives from outline-mode so you get the niceties that comes with outline itself like cycling visibility of headings. Each heading is clickable and goes to the relevant page when clicked on. Perhaps, a command like {M-g l} but with the headings as candidates would be handy to have?
That sounds good to me @vizs :)
An initial draft:
(defun pdf-outline-goto-label ()
(interactive)
(let* ((outline (pdf-info-outline))
(titles (mapcar (lambda (x) (alist-get 'title x)) outline))
(title (cons 'title
(completing-read "Select outline: "
(lambda (string pred action)
(if (eq action 'metadata)
'(metadata (display-sort-function . identity))
(complete-with-action action titles string pred)))
nil 'require-match))))
(pdf-links-action-perform (seq-some (lambda (x) (and (seq-contains x title) x)) outline))))
`pdf-outline-insert' serves as a good reference. `pdf-outline-insert' also picks out only a certain type of links. And I'm not sure what's the best to make completing-read ignore the display-sort-function. Maybe there's a cleaner way to do it other than using a lambda as the collection? seq-some+seq-contains is probably not the cleanest solution either but this serves a good starting point I guess.
@vizs Did you try calling imenu
?
5 Aug 2021, 15:35 by @.***:
@vizs https://github.com/vizs> Did you try call > imenu> ?
— You are receiving this because you were mentioned. Reply to this email directly, > view it on GitHub https://github.com/vedang/pdf-tools/issues/36#issuecomment-893332468> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AJAO2BWOID4MO4JSOGQXOTLT3JO5PANCNFSM5AXHDCKQ> . Triage notifications on the go with GitHub Mobile for > iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or > Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email> .
I did not realise imenu was setup for pdf-tools buffers. Thanks for pointing it out.
I didn't realize this as well, even though it is in the README. I'm closing this issue. As a side-note, I am building a Wiki / documentation site for pdf-tools that will hopefully make discovery simpler.
Do you mean to say the Github wiki when you say wiki? Personally, I think it is better to ship an info manual along with the package. This way, you can also view the documentation offline.
I mean an Info manual + website
On Mon, Aug 9, 2021, 12:17 PM viz @.***> wrote:
Do you mean to say the Github wiki when you say wiki? Personally, I think it is better to ship an info manual along with the package. This way, you can also view the documentation offline.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/vedang/pdf-tools/issues/36#issuecomment-894991846, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAUUHVQN7WCRZYHPNR5WPLT352X7ANCNFSM5AXHDCKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
@vedang With imenu or outline, I can only see the top-level headings and I need to select the proper "superheading" to get to the subheading I want:
See https://www.amd.com/system/files/TechDocs/40332.pdf
M-x
imenu
shows only this:
If I need to get to "Primary Opcode Map" I need to go to "Volume 3..." > "Appendix A" > "Opcode Maps" > "Primary Opcode Map"
Contrast this to sioyek which shows all matches when I search the TOC:
This is needed as I may not know the superheading containing my heading
@p00f : The headings are being generated correctly by pdf-tools
. You can get the behaviour you want by pressing the keybinding o
in the PDFView buffer. (or by running M-x pdf-outline
). More key-bindings here: https://pdftools.wiki/01864499
Re: imenu
, the behaviour you are seeing is standard imenu
behaviour and does not have anything to do with pdf-tools
itself. If you start typing out what you want (for example Opcode in your screenshot above), imenu
will filter out the candidates and show you what you want.
Or you can use the imenu
integration provided by your favourite completion framework for a better UX. For example, I use helm-imenu
which presents all the candidates generated by imenu
in a search interface.
Thanks, consult-imenu
shows all the results 👍🏽
Re outline, outline also shows only the top-level headings at first and I need to press tab to expand it
Would it be possible to implement a
jump-to-toc
command in pdf-tools?