vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
638 stars 90 forks source link

How to deactivate display-line-numbers-mode for pdf-view-mode? #252

Open malikwirin opened 10 months ago

malikwirin commented 10 months ago

Describe the bug When I open a PDF-File from an Org File the PDF gets opened in a new Buffer. But the Buffer with the Org-File gets replaced by the following warning: Warning (pdf-view): These modes are incompatible with `pdf-view-mode', please deactivate them (or customize pdf-view-incompatible-modes): display-line-numbers-mode

Steps to Reproduce the behaviour See "Describe the bug" and "Your pdf-tools install".

What is the expected behaviour? The Buffer with the Org File does not get replaced by the warning.

Desktop

Your pdf-tools install

(use-package org-noter-pdftools :after org-noter :config ;; Add a function to ensure precise note is inserted (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) (interactive "P") (org-noter--with-valid-session (let ((org-noter-insert-note-no-questions (if toggle-no-questions (not org-noter-insert-note-no-questions) org-noter-insert-note-no-questions)) (org-pdftools-use-isearch-link t) (org-pdftools-use-freepointer-annot t)) (org-noter-insert-note (org-noter--get-precise-info)))))

;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf (defun org-noter-set-start-location (&optional arg) "When opening a session with this document, go to the current location. With a prefix ARG, remove start location." (interactive "P") (org-noter--with-valid-session (let ((inhibit-read-only t) (ast (org-noter--parse-root)) (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) (with-current-buffer (org-noter--session-notes-buffer session) (org-with-wide-buffer (goto-char (org-element-property :begin ast)) (if arg (org-entry-delete nil org-noter-property-note-location) (org-entry-put nil org-noter-property-note-location (org-noter--pretty-print-location location)))))))) (with-eval-after-load 'pdf-annot (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

malikwirin commented 10 months ago

Still have the same problem and no solution since switching to Arch Linux and upgrading Emacs to version 30.0.50.

suzumenobu2 commented 7 months ago

Finally found workaround here. I had (setq-default display-line-numbers-mode 1) in my config, which was the main problem.

Then I found this post about setting up displaying line numbers, and that helped. Now my config looks like this:

base:

(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'org-mode-hook 'display-line-numbers-mode)
(dolist (mode '(pdf-view-mode-hook
                term-mode-hook
                eshell-mode-hook
                vterm-mode-hook
                imenu-list-minor-mode-hook
                imenu-list-major-mode-hook))
  (add-hook mode (lambda () (display-line-numbers-mode -1))))
(setq-default display-line-numbers-type 'relative)

pdf-tools:

(defun suzu/pdf-setup-hook ()
  (setq blink-cursor-mode nil))

(use-package pdf-tools
  :config
  (pdf-tools-install))

(add-hook 'pdf-view-mode-hook 'suzu/pdf-setup-hook)