all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#64516: [PATCH] docview: Only enable imenu when supported
@ 2023-07-07 15:24 Morgan Smith
  2023-07-07 15:40 ` Morgan Smith
  2023-07-08  9:14 ` Eli Zaretskii
  0 siblings, 2 replies; 20+ messages in thread
From: Morgan Smith @ 2023-07-07 15:24 UTC (permalink / raw)
  To: 64516

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]

Hello,

More info is in the commit message.

To re-create the error open up an EPUB file (or possibly any non-PDF
file in doc-view) and press 'M-g i' to run 'imenu'.  Doing that I get
the following error:

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-docview-Only-enable-imenu-when-supported.patch --]
[-- Type: text/x-patch, Size: 1939 bytes --]

From cd73281f324a5b21c304789ca7b828295e8718d9 Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Fri, 7 Jul 2023 11:17:15 -0400
Subject: [PATCH] docview: Only enable imenu when supported

While 'mutool' supports many filetypes, 'mutool show' only supports
PDF files.  This would lead to cryptic imenu errors when opening other
file types (like EPUB) since we would parse the error output.  During
my testing this caused 'imenu--index-alist' to have a value of '(nil).

* lisp/doc-view.el (doc-view--pdf-outline): Error when 'mutool' returns
an error.
(doc-view-imenu-setup): Don't check for 'mutool' as that is already
done by 'doc-view-imenu-enabled'.  Only enable imenu for PDF
documents.
---
 lisp/doc-view.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index b14655fb274..d9c12fc49c0 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -1912,7 +1912,8 @@ doc-view--pdf-outline
       (let ((outline nil)
             (fn (shell-quote-argument (expand-file-name fn))))
         (with-temp-buffer
-          (insert (shell-command-to-string (format "mutool show %s outline" fn)))
+          (unless (= 0 (call-process "mutool" nil (current-buffer) nil "show" fn "outline"))
+            (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)))
@@ -1961,7 +1962,7 @@ doc-view-imenu-index
 
 (defun doc-view-imenu-setup ()
   "Set up local state in the current buffer for imenu, if needed."
-  (when (and doc-view-imenu-enabled (executable-find "mutool"))
+  (when (and doc-view-imenu-enabled (eq 'pdf doc-view-doc-type))
     (setq-local imenu-create-index-function #'doc-view-imenu-index
                 imenu-submenus-on-top nil
                 imenu-sort-function nil
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-07-28 11:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-07 15:24 bug#64516: [PATCH] docview: Only enable imenu when supported Morgan Smith
2023-07-07 15:40 ` Morgan Smith
2023-07-07 16:05   ` Morgan Smith
2023-07-08  9:14 ` Eli Zaretskii
2023-07-09  8:13   ` Tassilo Horn
2023-07-11 17:49     ` Morgan Smith
2023-07-11 18:22       ` Morgan Smith
2023-07-15  8:05         ` Eli Zaretskii
2023-07-15 18:39           ` Tassilo Horn
2023-07-15 23:50             ` Morgan Smith
2023-07-16  4:39               ` Tassilo Horn
2023-07-16 15:03                 ` Morgan Smith
2023-07-16 15:24                   ` Tassilo Horn
2023-07-18 18:40                     ` Morgan Smith
2023-07-18 19:14                       ` Tassilo Horn
2023-07-20 16:05                         ` Eli Zaretskii
2023-07-28 10:14                         ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-28 10:19                           ` Tassilo Horn
2023-07-28 11:22                             ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-11 18:28       ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.