orgtre / pdf-tools Goto Github PK
View Code? Open in Web Editor NEWThis project forked from vedang/pdf-tools
Emacs support library for PDF files.
License: GNU General Public License v3.0
This project forked from vedang/pdf-tools
Emacs support library for PDF files.
License: GNU General Public License v3.0
Bit of a noob at this so apologies in advance for any mistakes. Firstly, thank you for your work here!
I seem to be having a (small) issue. When I set:
(setq pdf-annot-activate-created-annotations t)
And I want to proceed by highlighting and annotating a sentence in a PDF, I am still able to do so, but I get error message "nth: Wrong type argument: numberp, nil"
. Any idea how to fix this/circumvent this message?
My configuration for pdf-tools using straight
is below:
(use-package pdf-tools
:straight '(pdf-tools :type git :host github
:repo "vedang/pdf-tools"
:fork (:host github
:repo "orgtre/pdf-tools"))
:defer t
:bind (:map pdf-view-mode-map
("j" . pdf-view-next-line-or-next-page)
("k" . pdf-view-previous-line-or-previous-page)
("h" . image-backward-hscroll)
("l" . image-forward-hscroll)
("d" . pdf-view-midnight-minor-mode)
("i" . consult-imenu)
("C-c C-r M" . pdf-view-remove-margins-mode))
:mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode)
:magic ("%PDF" . pdf-view-mode)
:custom
(pdf-view-display-size 'fit-page)
(pdf-view-resize-factor 1.1)
(pdf-view-use-unicode-ligther nil)
;; LaTeX
(TeX-view-program-selection '((output-pdf "PDF Tools")))
(TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
(TeX-source-correlate-start-server t)
;; pdf-annot
(pdf-annot-minor-mode-map-prefix "a")
(pdf-annot-list-format '((page . 3) (type . 7) (contents . 200)))
(pdf-annot-activate-created-annotations t)
;; pdf-outline
(pdf-outline-imenu-use-flat-menus t)
;; pdf-keynav
(pdf-keynav-copy-region-blink-delay 2)
(pdf-keynav-transient-mark-mode t)
:init
;; Dealing with retina issues on MacOs
(when *sys/mac*
(setq pdf-view-use-scaling t)
(setq pdf-view-use-imagemagick nil))
(pdf-tools-install :no-query)
:config
(define-pdf-cache-function pagelabels)
(add-to-list 'pdf-tools-enabled-modes 'pdf-virtual-global-minor-mode)
(add-to-list 'pdf-tools-enabled-modes 'pdf-keynav-minor-mode)
;;; Define functions
(defun pdf-outline-indent (fn link &optional labels)
(let ((item (funcall fn link labels))
(indent pdf-outline-buffer-indent))
(cons (concat (make-string (* indent (1- (alist-get 'depth link))) ?\s)
(car item))
(cdr item))))
(advice-add 'pdf-outline-imenu-create-item :around #'pdf-outline-indent)
(defun pdf-view-midnight-colors-theme ()
(cons (frame-parameter nil 'foreground-color)
(color-darken-name
(frame-parameter nil 'background-color) 5)))
(defun ctb/pdf-tools-backdrop ()
(face-remap-add-relative
'default
`(:background ,(modus-themes-color 'bg-alt))))
(defun ctb/pdf-tools-midnight-mode-toggle ()
(when (derived-mode-p 'pdf-view-mode)
(if (eq (car custom-enabled-themes) 'modus-vivendi)
(pdf-view-midnight-minor-mode 1)
(pdf-view-midnight-minor-mode -1))
(ctb/pdf-tools-backdrop)))
;; Other customizations: modeline and removing margins
(defun mode-line-extra-pdf-view-mode ()
(let ((cur (number-to-string (pdf-view-current-page)))
(tot (or (ignore-errors (number-to-string (pdf-cache-number-of-pages)))
"???")))
(format "(%s/%s)" cur tot)))
(define-minor-mode pdf-view-remove-margins-mode
"Minor mode for removing margins from every pdf page."
:lighter " pdf-margins"
(if (not (eq major-mode 'pdf-view-mode))
(user-error "Not in a pdf-view-mode buffer")
(if pdf-view-remove-margins-mode
(progn
(pdf-view-set-slice-from-bounding-box)
(add-hook 'pdf-view-after-change-page-hook #'pdf-view-set-slice-from-bounding-box))
(progn
(pdf-view-reset-slice)
(remove-hook
'pdf-view-after-change-page-hook #'pdf-view-set-slice-from-bounding-box)))))
:hook (
;; (pdf-view-mode-hook . (lambda() (linum-mode -1)))
;; (pdf-view-mode-hook . (lambda () (display-line-numbers-mode -1)))
(pdf-view-mode-hook . pdf-tools-enable-minor-modes)
(modus-themes-after-load-theme-hook . ctb/pdf-tools-midnight-mode-toggle)
(pdf-view-mode-hook . ctb/pdf-tools-midnight-mode-toggle)
(pdf-view-midnight-mode-hook . pdf-view-midnight-colors-theme)
(TeX-after-compilation-finished-functions . TeX-revert-document-buffer)))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.