GNU bug report logs -
#37436
27.0.50; Function proposal doc-view-open-file
Previous Next
Reported by: Jean Louis <bugs <at> gnu.support>
Date: Tue, 17 Sep 2019 06:32:02 UTC
Severity: wishlist
Tags: moreinfo
Found in version 27.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 37436 <at> debbugs.gnu.org (full text, mbox):
I have made this function now for me. But such could be improved for
GNU Emacs so that PDF, DJVU and other doc view file could be opened
straight from Emacs Lisp and at the specific page number for specific
query, even query number could be implemented.
(defun doc-view-open-file (file &optional page-number query match)
"Opens PDF file in GNU Emacs at specific page number or at
specific match"
(let* ((allowed-extensions '("pdf" "djvu" "dvi"))
(file-ext (file-name-extension file))
(match (if match match 0)))
(when (and (file-exists-p file)
(seq-contains allowed-extensions file-ext 'equalp))
(setq doc-view--current-search-matches nil)
(let ((created (create-file-buffer file))
(buffer (get-file-buffer file)))
(switch-to-buffer created)
(set-visited-file-name file )
(insert file)
(doc-view-mode)
(when page-number
(doc-view-goto-page page-number))
(when query
(let ((txt (expand-file-name "doc.txt"
(doc-view--current-cache-dir))))
(if (file-readable-p txt)
(progn
(setq doc-view--current-search-matches
(doc-view-search-internal query txt))
(doc-view-search-next-match match)))))))))
This bug report was last modified 4 years and 83 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.