From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#73638: 31.0.50; doc-view: imenu index cannot be made for LaTeX PDFs Date: Mon, 07 Oct 2024 09:02:31 +0200 Message-ID: <87y130z988.fsf@gnu.org> References: <87ploebyhc.fsf@gmail.com> <87ed4upbmf.fsf@gnu.org> <86plodvlcm.fsf@gnu.org> <87ttdphhir.fsf@gmail.com> <87jzel3aus.fsf@gnu.org> <87plodh68g.fsf@gmail.com> <87plod8ob3.fsf@gnu.org> <8734l9h0nj.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29095"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.12.6; emacs 31.0.50 Cc: Eli Zaretskii , 73638@debbugs.gnu.org To: Visuwesh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 07 09:06:13 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sxhor-0007TI-6r for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Oct 2024 09:06:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxhob-00050n-RA; Mon, 07 Oct 2024 03:05:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxhoZ-00050e-CI for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2024 03:05:55 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sxhoZ-0002zQ-3M for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2024 03:05:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=kQJrHADLQAtE3FkUlassbZs6ahCBJ1q0ZG6tcxCfmRg=; b=dmkn03Dv2kYo+ReIYWKifO7Y6Zm9v04fjoLGo7D7g2sC/7sHLOyTEjmSdXsJgTGuX0cXqCAsv31jSNgIrqUnstcOoXAil9JA1ka4QgfthBG74sWtWiFN7RNCRxFUkTo0WcZqMxl6kdcfF9XYb9X4f+4s6vgrxD0hFfLoiYHvyy9zVJ0tklt5M6BxASiexVFR/dx96oQ72TQRx/KUhDws4TEcY0UAmJzbAtzEc4ThtPOyAN6PQCpXPkgdx61m+RHLEykLj8XCMa3bmCbP/++2PeEAgLjxFtrFvRpgUbbnREZtql39TcfhEg5bt8ymcnKR1YhyqYJIsEqIgwMEJ9DhWw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sxhof-0000Z6-P5 for bug-gnu-emacs@gnu.org; Mon, 07 Oct 2024 03:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Oct 2024 07:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73638 X-GNU-PR-Package: emacs Original-Received: via spool by 73638-submit@debbugs.gnu.org id=B73638.17282847111664 (code B ref 73638); Mon, 07 Oct 2024 07:06:01 +0000 Original-Received: (at 73638) by debbugs.gnu.org; 7 Oct 2024 07:05:11 +0000 Original-Received: from localhost ([127.0.0.1]:44373 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxhnr-0000QC-D9 for submit@debbugs.gnu.org; Mon, 07 Oct 2024 03:05:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sxhno-0000PR-Rr for 73638@debbugs.gnu.org; Mon, 07 Oct 2024 03:05:10 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sxhlW-0002RK-Dj; Mon, 07 Oct 2024 03:02:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=kQJrHADLQAtE3FkUlassbZs6ahCBJ1q0ZG6tcxCfmRg=; b=eG2SEPlcoSVar3Xs7Ldk YYHezlQcOj9rlEec6CD2WIvt0NibqvJGc4Y6x+g5bW874wa30poIbmu+452ByVDVxGzdAkFRwz2xC HXltPOwNmGpuT/7RKzvyadM0Akm2ZOOK8Aphlh6cT0a6cpE3L8RCR2mQS+i31MI9WXSJIsOSZ+CEh mPc4j/KpvdPKtRq+JXIAo6GypGUmGKId8WNV1aw7BDwCGkJuP/zqGmVo6f5U2ItvJ9G/Uqt/PasC6 ZYDllDfB8XL22k75aK8XuUqFNT9JWx3mFBuVHbrlW/7tDcyFqhAaOaAETvLvMYF4zYuGgk2RSkipt WYcl5o4Pkr/RxQ==; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddvkedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhgffffkgggtsehttdertddtredt necuhfhrohhmpefvrghsshhilhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqne cuggftrfgrthhtvghrnhepleduvdegfeduvdejkeefteelgeetgfevhefhueffueffgeeh gfeufefgvdffgedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepthhhohhrnhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeei jeefkeejkeegqdeifeehvdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrih hlrdhfmhdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthht ohepjeefieefkeesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopegvlhhiii esghhnuhdrohhrghdprhgtphhtthhopehvihhsuhifvghshhhmsehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail In-Reply-To: <8734l9h0nj.fsf@gmail.com> (Visuwesh's message of "Sun, 06 Oct 2024 18:02:48 +0530") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293103 Archived-At: Visuwesh writes: Hi! >> I don't do that very frequently. I think it would be simpler if we >> skip the sentinel and instead use some :buffer " *mutool-run-result*" >> with make-process and just read from there after the >> accept-process-output loop. > > That was a serious brainfart, indeed. I've went with your approach in > the attached, please review. > > @@ -1986,21 +1998,25 @@ doc-view--pdf-outline > structure is extracted by `doc-view--imenu-subtree'." > (let ((fn (or file-name (buffer-file-name)))) > (when fn > - (let ((outline nil) > - (fn (expand-file-name fn))) > - (with-temp-buffer > - (unless (eql 0 (call-process doc-view-pdfdraw-program nil > - (current-buffer) nil "show" fn "outline")) > + (with-temp-buffer > + (let ((proc (make-process > + :name "doc-view-pdf-outline" > + :command (list "mutool" "run") > + :buffer (current-buffer)))) > + (process-send-string proc (format doc-view--mutool-pdf-outline-script > + (expand-file-name fn))) > + ;; Need to send this twice for some reason... > + (process-send-eof) > + (process-send-eof) > + (while (accept-process-output proc)) > + (unless (eq (process-status proc) 'exit) > (setq doc-view--outline 'unavailable) > (imenu-unavailable-error "Unable to create imenu index using `mutool'")) > (goto-char (point-min)) > - (while (re-search-forward doc-view--outline-rx nil t) > - (push `((level . ,(length (match-string 1))) > - (title . ,(replace-regexp-in-string "\\\\[rt]" " " > - (match-string 2))) > - (page . ,(string-to-number (match-string 3)))) > - outline))) > - (nreverse outline))))) > + (search-forward "BEGIN") If the script fails for some reason, there will be no BEGIN and we let a search-failed error bubble up. So I'd put it in the condition-case and handle it like the end-of-file error. Or simply provide the NOERROR search-forward arg. > + (condition-case nil > + (read (current-buffer)) > + (end-of-file nil))))))) Maybe it would also a good idea to use a :stderr buffer with make-process and put its contents into the imenu-unavailable-error. That way, chances are better we get the reason for failure delivered in bug reports. Otherwise, it all looks good to me. :-) Thanks, Tassilo