Skip to content

Commit

Permalink
Added VPDF feature.
Browse files Browse the repository at this point in the history
* lisp/pdf-virtual.el: New file handling virtual PDF documents.

* test/pdf-test.el: Tests for that feature.

* lisp/pdf-misc.el: Extend the menu appropriately.

* lisp/pdf-view.el: Make pdf-view-mode play nicer with it's derived
  mode pdf-virtual-view-mode.

* lisp/pdf-tools.el: Integrate pdf-virtual.

* NEWS: Added item.

* README.org: Mention it.
  • Loading branch information
Andreas Politz committed Jun 12, 2015
1 parent 2482dff commit dc2d99f
Show file tree
Hide file tree
Showing 7 changed files with 1,232 additions and 12 deletions.
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
The return value of many pdf-info-* functions was changed in order
to prefer alists over other data-structures (indexed lists,
trees).

** Virtual PDF
A virtual PDF is a collection of pages (or parts thereof) of
arbitrary documents, which appear to the rest of pdf-tools as one
big PDF, though they are always read-only.

* Version 0.60
** Regexp support
You may now search for perl-compatible regular expressions (PCRE)
Expand Down
3 changes: 3 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@
*** SyncTeX
Jump from a position on a page directly to the TeX source and
vice-versa.
*** Virtual PDF
Use a collection of documents as if it where one, big single PDF.

*** Misc
+ Display PDF's metadata.
+ Mark a region and kill the text from the PDF.
+ Keep track of visited pages via a history.
+ Apply a color filter for reading in low light conditions.

** Installation
The package may be installed via melpa and it will try to build the
server part when it is actiated the first time, though next section
Expand Down
20 changes: 16 additions & 4 deletions lisp/pdf-misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@
["Go Forward" pdf-history-forward
:visible (bound-and-true-p pdf-history-minor-mode)
:active (not (pdf-history-end-of-history-p))]
["--" nil
:visible (derived-mode-p 'pdf-virtual-view-mode)]
["Next file" pdf-virtual-buffer-forward-file
:visible (derived-mode-p 'pdf-virtual-view-mode)
:active (pdf-virtual-document-next-file
(pdf-view-current-page))]
["Previous file" pdf-virtual-buffer-backward-file
:visible (derived-mode-p 'pdf-virtual-view-mode)
:active (not (eq 1 (pdf-view-current-page)))]
["--" nil
:visible (bound-and-true-p pdf-history-minor-mode)]
["Add text annotation" pdf-annot-mouse-add-text-annotation
Expand Down Expand Up @@ -145,9 +154,14 @@
["--" nil :visible (and (featurep 'pdf-sync)
(equal last-command-event
last-nonmenu-event))]
["Print" pdf-misc-print-document]
["Print" pdf-misc-print-document
:active (and (pdf-view-buffer-file-name)
(file-readable-p (pdf-view-buffer-file-name)))]
["Create image" pdf-view-extract-region-image
:help "Create an image of the page or the selected region(s)."]
["Create virtual PDF" pdf-virtual-buffer-create
:help "Create a PDF containing all documents in this directory."
:visible (bound-and-true-p pdf-virtual-global-minor-mode)]
"--"
["Revert buffer" pdf-view-revert-buffer
:visible (pdf-info-writable-annotations-p)]
Expand Down Expand Up @@ -246,9 +260,7 @@ It is called with one argument, the PDF file."
(defun pdf-misc-print-document (filename &optional interactive-p)
(interactive
(list (pdf-view-buffer-file-name) t))
(unless (file-readable-p filename)
(signal 'wrong-type-argument
(list 'file-readable-p filename)))
(cl-check-type filename (and string file-readable))
(let ((programm (pdf-misc-print-programm interactive-p)))
(unless programm
(error "No print programm available"))
Expand Down
12 changes: 10 additions & 2 deletions lisp/pdf-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ In order to customize dark and light colors use
pdf-misc-context-menu-minor-mode
pdf-cache-prefetch-minor-mode
pdf-view-auto-slice-minor-mode
pdf-occur-global-minor-mode))
pdf-occur-global-minor-mode
pdf-virtual-global-minor-mode))

(defcustom pdf-tools-enabled-modes
'(pdf-history-minor-mode
Expand All @@ -137,7 +138,9 @@ In order to customize dark and light colors use
pdf-sync-minor-mode
pdf-misc-context-menu-minor-mode
pdf-cache-prefetch-minor-mode
pdf-occur-global-minor-mode)
pdf-occur-global-minor-mode
;; pdf-virtual-global-minor-mode
)
"A list of automatically enabled minor-modes.
PDF Tools is build as a series of minor-modes. This variable and
Expand Down Expand Up @@ -332,6 +335,7 @@ MODES defaults to `pdf-tools-enabled-modes'."
(pdf-tools-set-modes-enabled nil modes))

(declare-function pdf-occur-global-minor-mode "pdf-occur.el")
(declare-function pdf-virtual-global-minor-mode "pdf-virtual.el")

;;;###autoload
(defun pdf-tools-install (&optional force-compile-p skip-dependencies-p no-error)
Expand Down Expand Up @@ -360,6 +364,9 @@ See `pdf-view-mode' and `pdf-tools-enabled-modes'."
(when (memq 'pdf-occur-global-minor-mode
pdf-tools-enabled-modes)
(pdf-occur-global-minor-mode 1))
(when (memq 'pdf-virtual-global-minor-mode
pdf-tools-enabled-modes)
(pdf-virtual-global-minor-mode 1))
(add-hook 'pdf-view-mode-hook 'pdf-tools-enable-minor-modes)
(dolist (buf (buffer-list))
(with-current-buffer buf
Expand All @@ -375,6 +382,7 @@ See `pdf-view-mode' and `pdf-tools-enabled-modes'."
(setq-default auto-mode-alist
(remove pdf-tools-auto-mode-alist-entry auto-mode-alist))
(pdf-occur-global-minor-mode -1)
(pdf-virtual-global-minor-mode -1)
(remove-hook 'pdf-view-mode-hook 'pdf-tools-enable-minor-modes)
(dolist (buf (buffer-list))
(with-current-buffer buf
Expand Down
12 changes: 7 additions & 5 deletions lisp/pdf-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ PNG images in Emacs buffers."
:abbrev-table nil
:syntax-table nil
;; Setup a local copy for remote files.
(when (or jka-compr-really-do-compress
(let ((file-name-handler-alist nil))
(not (and buffer-file-name
(file-readable-p buffer-file-name)))))
(when (and (or jka-compr-really-do-compress
(let ((file-name-handler-alist nil))
(not (and buffer-file-name
(file-readable-p buffer-file-name)))))
(pdf-tools-pdf-buffer-p))
(let ((tempfile (pdf-util-make-temp-file
(concat (if buffer-file-name
(file-name-nondirectory
Expand Down Expand Up @@ -317,7 +318,8 @@ PNG images in Emacs buffers."
;; No auto-save at the moment.
(setq-local buffer-auto-save-file-name nil)
;; No undo at the moment.
(buffer-disable-undo)
(unless buffer-undo-list
(buffer-disable-undo))
;; Enable transient-mark-mode, so region deactivation when quitting
;; will work.
(setq-local transient-mark-mode t)
Expand Down
Loading

0 comments on commit dc2d99f

Please sign in to comment.