diff options
author | Po Lu <luangruo@yahoo.com> | 2023-07-21 07:58:30 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-07-21 07:58:30 +0800 |
commit | 0ff70f12a5e29a0e90637bd063e1725f0e4e4ab2 (patch) | |
tree | baa2271c1a50b38983456bd1d9250a1e3cc0a1a1 /lisp/doc-view.el | |
parent | 916ef5748992216710f01d91c330e52042b279f1 (diff) | |
parent | c55e67081e9873a32b6e665e44f3e5a9c301255f (diff) | |
download | emacs-0ff70f12a5e29a0e90637bd063e1725f0e4e4ab2.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'lisp/doc-view.el')
-rw-r--r-- | lisp/doc-view.el | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index c381d5d34a0..b7f7a862af8 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -147,6 +147,8 @@ (require 'filenotify) (eval-when-compile (require 'subr-x)) +(autoload 'imenu-unavailable-error "imenu") + ;;;; Customization Options (defgroup doc-view nil @@ -214,7 +216,7 @@ are available (see Info node `(emacs)Document View')." :type 'boolean :version "30.1") -(defcustom doc-view-imenu-enabled (and (executable-find "mutool") t) +(defcustom doc-view-imenu-enabled (executable-find "mutool") "Whether to generate an imenu outline when \"mutool\" is available." :type 'boolean :version "29.1") @@ -1958,9 +1960,10 @@ structure is extracted by `doc-view--imenu-subtree'." (let ((fn (or file-name (buffer-file-name)))) (when fn (let ((outline nil) - (fn (shell-quote-argument (expand-file-name fn)))) + (fn (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")) + (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))) @@ -2009,7 +2012,7 @@ GOTO-PAGE-FN other than `doc-view-goto-page'." (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 doc-view-imenu-enabled (setq-local imenu-create-index-function #'doc-view-imenu-index imenu-submenus-on-top nil imenu-sort-function nil @@ -2284,7 +2287,10 @@ toggle between displaying the document or editing it as text. (setq mode-name "DocView" buffer-read-only t major-mode 'doc-view-mode) - (doc-view-imenu-setup) + (condition-case imenu-error + (doc-view-imenu-setup) + (imenu-unavailable (message "imenu support unavailable: %s" + (cadr imenu-error)))) (doc-view-initiate-display) ;; Replace the tool bar map with `doc-view-tool-bar-map'. (setq-local tool-bar-map doc-view-tool-bar-map) |