Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
malikwirin opened this issue Jan 11, 2024 · 2 comments
Open

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

malikwirin opened this issue Jan 11, 2024 · 2 comments

Comments

@malikwirin
Copy link

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: a9c9a12]
  • 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 malikwirin changed the title How to deactivate display-line-numbers-mode for pdf-view-mode How to deactivate display-line-numbers-mode for pdf-view-mode? Jan 11, 2024
@malikwirin
Copy link
Author

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

@suzumenobu2
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants