12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- (require 'org)
- (declare-function doc-view-goto-page "doc-view" (page))
- (declare-function doc-view-current-page "doc-view" (&optional win))
- (org-add-link-type "docview" 'org-docview-open)
- (add-hook 'org-store-link-functions 'org-docview-store-link)
- (defun org-docview-open (link)
- (when (string-match "\\(.*\\)::\\([0-9]+\\)$" link)
- (let* ((path (match-string 1 link))
- (page (string-to-number (match-string 2 link))))
- (org-open-file path 1)
-
- (doc-view-goto-page page)
- )))
- (defun org-docview-store-link ()
- "Store a link to a docview buffer"
- (when (eq major-mode 'doc-view-mode)
-
- (let* ((path buffer-file-name)
- (page (doc-view-current-page))
- (link (concat "docview:" path "::" (number-to-string page)))
- (description ""))
- (org-store-link-props
- :type "docview"
- :link link
- :description path))))
- (defun org-docview-complete-link ()
- "Use the existing file name completion for file: links to get the file name,
- then ask the user for the page number and append it."
- (concat (replace-regexp-in-string "^file:" "docview:" (org-file-complete-link))
- "::"
- (read-from-minibuffer "Page:" "1")))
- (provide 'org-docview)
|