Function: doc-view--pdf-outline

doc-view--pdf-outline is a byte-compiled function defined in doc-view.el.gz.

Signature

(doc-view--pdf-outline &optional FILE-NAME)

Documentation

Return a list describing the outline of FILE-NAME.

Return a list describing the current file if FILE-NAME is nil.

Each element in the returned list contains information about a section's title, nesting level and page number. The list is flat: its tree structure is extracted by doc-view--imenu-subtree.

Source Code

;; Defined in /usr/src/emacs/lisp/doc-view.el.gz
(defun doc-view--pdf-outline (&optional file-name)
  "Return a list describing the outline of FILE-NAME.
Return a list describing the current file if FILE-NAME is nil.

Each element in the returned list contains information about a section's
title, nesting level and page number.  The list is flat: its tree
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))))
        (with-temp-buffer
          (insert (shell-command-to-string (format "mutool show %s outline" fn)))
          (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)))))