pdf-tools icon indicating copy to clipboard operation
pdf-tools copied to clipboard

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

Open malikwirin opened this issue 2 years ago • 2 comments

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

  • OS: [Artix Linux x86_64]
  • Emacs Version: [29.1]
  • Poppler Version: [I dont know where and if Poppler is present on my System (its not in the path for my shell)]

Your pdf-tools install

  • I used elpaca for installation
  • pdf-tools Version: [Version: 1.1.0 Commit: a9c9a12c3ecf2005fa641059368ac8284f507620]
  • pdf-tools customization / configuration that you use; I'll put all pdf related code from my config.org here:
(use-package pdf-tools
  :init (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 avatar Jan 11 '24 10:01 malikwirin

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

malikwirin avatar Jan 16 '24 11:01 malikwirin

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)

suzumenobu2 avatar Mar 24 '24 20:03 suzumenobu2