unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Visuwesh <visuweshm@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 73638@debbugs.gnu.org
Subject: bug#73638: 31.0.50; doc-view: imenu index cannot be made for LaTeX PDFs
Date: Sun, 06 Oct 2024 10:16:11 +0200	[thread overview]
Message-ID: <87jzel3aus.fsf@gnu.org> (raw)
In-Reply-To: <87ttdphhir.fsf@gmail.com> (Visuwesh's message of "Sun, 06 Oct 2024 11:58:28 +0530")

Visuwesh <visuweshm@gmail.com> writes:

> When "mutool run" is called without any script argument, it opens a
> REPL.  We would need to `process-send-string' to the REPL but the REPL
> reports syntax error when I try to do so.  This is after trying to
> "minify" the JS script.  Maybe I am doing something wrong.  I've
> attached my test lisp at the end.

I've tried doing the same and also get syntax errors.  Same if I just
copy&paste the script with injected filename in the REPL on a terminal.
Both for the original script as well as for a minified version.  First
I've thought that function definitions won't work at all but that's not
the case, e.g., I can enter this funcion at the REPL and it'll work:

--8<---------------cut here---------------start------------->8---
> function bar(i){if(i==0) print("done"); else {print(i);bar(i-1);}}
> bar(10)
10
9
8
7
6
5
4
3
2
1
done
--8<---------------cut here---------------end--------------->8---

Ok, after experimenting a bit more and minimizing by hand, this version
of the script can be copy&pasted into the REPL and should probably also
work with process-send-string.

--8<---------------cut here---------------start------------->8---
var document = new Document.openDocument("/home/horn/sample.pdf", "application/pdf");
var outline = document.loadOutline();
if(!outline) quit();
function pp(outl, level){print("((level . " + level + ")");print("(title . " + repr(outl.title) + ")");print("(page . " + document.resolveLink(outl.uri) + "))");if(outl.down){for(var i=0; i<outl.down.length; i++){pp(outl.down[i], level+1);}}};
function run(){print("(");for(var i=0; i<outline.length; i++){pp(outline[i], 1);}print(")");};
run();
--8<---------------cut here---------------end--------------->8---

It looks like the REPL wants function definitions on one single but
separate line.  Sadly, that's not documented so I'm not sure how
reliable that formatting works across mutool versions or why the REPL
doesn't accept all valid JS.  The only thing I can find in the man page
is that the = character at the beginning of a line has the special
meaning of "print the result of the following expression".

Bye,
  Tassilo





  parent reply	other threads:[~2024-10-06  8:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-05 11:06 bug#73638: 31.0.50; doc-view: imenu index cannot be made for LaTeX PDFs Visuwesh
2024-10-05 19:56 ` Tassilo Horn
2024-10-06  5:42   ` Eli Zaretskii
2024-10-06  6:28     ` Visuwesh
2024-10-06  6:39       ` Eli Zaretskii
2024-10-06  8:16       ` Tassilo Horn [this message]
2024-10-06 10:32         ` Visuwesh
2024-10-06 11:26           ` Tassilo Horn
2024-10-06 12:32             ` Visuwesh
2024-10-07  7:02               ` Tassilo Horn
2024-10-07  9:26                 ` Visuwesh
2024-10-07  9:55                   ` Visuwesh
2024-10-07 11:03                     ` Tassilo Horn
2024-10-07 12:53                       ` Visuwesh
2024-10-07 15:04                         ` Tassilo Horn
2024-10-08  9:44                           ` Visuwesh
2024-10-08 15:43                             ` Tassilo Horn
2024-10-06  6:39     ` 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=87jzel3aus.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=73638@debbugs.gnu.org \
    --cc=eliz@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).