vedang / pdf-tools

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

Fails to start with error `Lisp error: (error "epdfinfo: Expected 0 or 1:2")` #194

Closed emacsomancer closed 1 year ago

emacsomancer commented 1 year ago

Describe the bug Fails to start with error Lisp error: (error "epdfinfo: Expected 0 or 1:2"). This is on a Void Linux machine running EXWM. The same init.el works fine on other machines (not using EXWM or Void).

Steps to Reproduce the behaviour

  1. open a pdf with pdf-tools set-up to handle pdfs in Emacs
  2. fails with Lisp error: (error "epdfinfo: Expected 0 or 1:2")

What is the expected behaviour? Open PDFs and enable midnite mode.

Desktop Please complete the following information:

Your pdf-tools install Please complete the following information:

Additional context

Debugger entered--Lisp error: (error "epdfinfo: Expected 0 or 1:2")
  error("epdfinfo: %s" "Expected 0 or 1:2")
  (cond ((null status) response) ((eq status 'error) (error "epdfinfo: %s" response)) ((eq status 'interrupted) (error "epdfinfo: Command was interrupted")) (t (error "Internal error: invalid response status")))
  (if pdf-info-asynchronous nil (while (and (not done) (eq (process-status (pdf-info-process)) 'run)) (accept-process-output (pdf-info-process) 0.01)) (if (and (not done) (not (eq (process-status (pdf-info-process)) 'run)) (not (eq cmd 'quit))) (progn (error "The epdfinfo server quit unexpectedly"))) (cond ((null status) response) ((eq status 'error) (error "epdfinfo: %s" response)) ((eq status 'interrupted) (error "epdfinfo: Command was interrupted")) (t (error "Internal error: invalid response status"))))
  (let* ((query (concat (mapconcat #'pdf-info-query--escape (cons cmd args) ":") "\n")) (callback #'(lambda (closure response) (let* ((result ...) (status ...)) (progn (pdf-info-query--log response) (let* ... ...))))) response status done (closure (or pdf-info-asynchronous #'(lambda (s r) (setq status s response r done t))))) (pdf-info-query--log query t) (tq-enqueue pdf-info--queue query "^\\.\n" closure callback) (if pdf-info-asynchronous nil (while (and (not done) (eq (process-status (pdf-info-process)) 'run)) (accept-process-output (pdf-info-process) 0.01)) (if (and (not done) (not (eq (process-status (pdf-info-process)) 'run)) (not (eq cmd 'quit))) (progn (error "The epdfinfo server quit unexpectedly"))) (cond ((null status) response) ((eq status 'error) (error "epdfinfo: %s" response)) ((eq status 'interrupted) (error "epdfinfo: Command was interrupted")) (t (error "Internal error: invalid response status")))))
  pdf-info-query(setoptions "/tmp/061e36d2-ad15-11ed-9ecf-0454530c1766.pdf" :render/usecolors 2 :render/background "#0e1b25" :render/foreground "#ffa64d")
  apply(pdf-info-query setoptions "/tmp/061e36d2-ad15-11ed-9ecf-0454530c1766.pdf" (:render/usecolors 2 :render/background "#0e1b25" :render/foreground "#ffa64d"))
  pdf-info-setoptions(:render/foreground "#ffa64d" :render/background "#0e1b25" :render/usecolors 2)
  (closure ((last-message) (arg) t) nil (pdf-info-setoptions :render/foreground (or (car pdf-view-midnight-colors) "black") :render/background (or (cdr pdf-view-midnight-colors) "white") :render/usecolors (if pdf-view-midnight-invert 2 1)))()
  funcall((closure ((last-message) (arg) t) nil (pdf-info-setoptions :render/foreground (or (car pdf-view-midnight-colors) "black") :render/background (or (cdr pdf-view-midnight-colors) "white") :render/usecolors (if pdf-view-midnight-invert 2 1))))
  (cond (pdf-view-midnight-minor-mode (add-hook 'after-save-hook enable nil t) (add-hook 'after-revert-hook enable nil t) (funcall enable)) (t (remove-hook 'after-save-hook enable t) (remove-hook 'after-revert-hook enable t) (pdf-info-setoptions :render/usecolors 0)))
  (let ((enable #'(lambda nil (pdf-info-setoptions :render/foreground (or (car pdf-view-midnight-colors) "black") :render/background (or (cdr pdf-view-midnight-colors) "white") :render/usecolors (if pdf-view-midnight-invert 2 1))))) (cond (pdf-view-midnight-minor-mode (add-hook 'after-save-hook enable nil t) (add-hook 'after-revert-hook enable nil t) (funcall enable)) (t (remove-hook 'after-save-hook enable t) (remove-hook 'after-revert-hook enable t) (pdf-info-setoptions :render/usecolors 0))))
  (let ((last-message (current-message))) (setq pdf-view-midnight-minor-mode (cond ((eq arg 'toggle) (not pdf-view-midnight-minor-mode)) ((and (numberp arg) (< arg 1)) nil) (t t))) (if (boundp 'local-minor-modes) (progn (setq local-minor-modes (delq 'pdf-view-midnight-minor-mode local-minor-modes)) (if pdf-view-midnight-minor-mode (progn (setq local-minor-modes (cons 'pdf-view-midnight-minor-mode local-minor-modes)))))) (pdf-util-assert-pdf-buffer) (let ((enable #'(lambda nil (pdf-info-setoptions :render/foreground (or ... "black") :render/background (or ... "white") :render/usecolors (if pdf-view-midnight-invert 2 1))))) (cond (pdf-view-midnight-minor-mode (add-hook 'after-save-hook enable nil t) (add-hook 'after-revert-hook enable nil t) (funcall enable)) (t (remove-hook 'after-save-hook enable t) (remove-hook 'after-revert-hook enable t) (pdf-info-setoptions :render/usecolors 0)))) (pdf-cache-clear-images) (pdf-view-redisplay t) (run-hooks 'pdf-view-midnight-minor-mode-hook (if pdf-view-midnight-minor-mode 'pdf-view-midnight-minor-mode-on-hook 'pdf-view-midnight-minor-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local " in current buffer")) (message "Pdf-View-Midnight minor mode %sabled%s" (if pdf-view-midnight-minor-mode "en" "dis") local))))))
  pdf-view-midnight-minor-mode()
  bms/pdf-midnite-oklab-color-space()
  run-hooks(change-major-mode-after-body-hook special-mode-hook pdf-view-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook special-mode-hook pdf-view-mode-hook))
  run-mode-hooks(pdf-view-mode-hook)
  pdf-view-mode()
  set-auto-mode-0(pdf-view-mode nil)
  #<subr set-auto-mode>()
  apply(#<subr set-auto-mode> nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer 061e36d2-ad15-11ed-9ecf-0454530c1766.pdf> "/tmp/061e36d2-ad15-11ed-9ecf-0454530c1766.pdf" nil nil "/tmp/061e36d2-ad15-11ed-9ecf-0454530c1766.pdf" (1583 39))
  find-file-noselect("/tmp/061e36d2-ad15-11ed-9ecf-0454530c1766.pdf" nil nil)
  ido-file-internal(selected-window)
  ido-find-file()
  funcall-interactively(ido-find-file)
  command-execute(ido-find-file)
Atreyagaurav commented 1 year ago

The new update changed this configuration: (setq pdf-view-midnight-invert t) the variable pdf-view-midnight-invert now takes values 0, 1 or 2, instead of boolean like before.

Refer to: https://github.com/vedang/pdf-tools/pull/69#discussion_r805407080

You can use either 1 or 2 for midnight mode enable, one of them is grayscale and another inverts the colors based on the lightness. The pull request you linked was accepted, and then the customization variable was changed.