I'd like to define a Hydra for PDFView mode and bind a key for it in pdf-view-mode-map. However, it seems that if I try to bind any keys for pdf-view-mode-map using :bind and :map of use-package, AUCTeX ceases to use PDFView mode when calling C-c C-v (TeX-View); it instead uses DocView mode.

This is a minimal init.el file that reproduces the issue. If the commented lines are uncommented, then AUCTeX will use DocView mode. If the lines are left commented, then AUCTeX uses PDFView mode as intended.

Is there anything I can do to fix this issue and still use use-package to define the keybindings for PDFView mode?

(require 'package)
(unless (package-installed-p 'use-package)
  (message "** bootstrapping the installation of use-package")
  (package-install 'use-package)
  (message "** successfully installed use-package"))
(use-package hydra
  :ensure t)
(use-package use-package-hydra
  :ensure t)
(use-package tex
  :ensure auctex
  :mode ("\\.tex\\'" . TeX-latex-mode)
  (setq TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
  (setq TeX-view-program-selection '((output-pdf "PDF Tools")))
  (setq TeX-source-correlate-start-server t)
  (add-hook 'TeX-after-compilation-finished-functions
(use-package pdf-tools
  :ensure t
  :after hydra
  (setq pdf-info-epdfinfo-program "/usr/local/bin/epdfinfo")
;;   :bind
;;   (:map pdf-view-mode-map
;;         ("\\" . hydra-pdftools/body)
;;         ("<s-spc>" .  pdf-view-scroll-down-or-next-page)
;;         ("g"  . pdf-view-first-page)
;;         ("G"  . pdf-view-last-page)
;;         ("l"  . image-forward-hscroll)
;;         ("h"  . image-backward-hscroll)
;;         ("j"  . pdf-view-next-page)
;;         ("k"  . pdf-view-previous-page)
;;         ("e"  . pdf-view-goto-page)
;;         ("u"  . pdf-view-revert-buffer)
;;         ("al" . pdf-annot-list-annotations)
;;         ("ad" . pdf-annot-delete)
;;         ("aa" . pdf-annot-attachment-dired)
;;         ("am" . pdf-annot-add-markup-annotation)
;;         ("at" . pdf-annot-add-text-annotation)
;;         ("y"  . pdf-view-kill-ring-save)
;;         ("i"  . pdf-misc-display-metadata)
;;         ("s"  . pdf-occur)
;;         ("b"  . pdf-view-set-slice-from-bounding-box)
;;         ("r"  . pdf-view-reset-slice))
     (setq which-key-inhibit t)
     (setq which-key-inhibit nil)
     :color blue
     :hint nil)
     Move  History   Scale/Fit     Annotations  Search/Link    Do   │ PDF Tools │
       ^^_g_^^      _B_    ^↧^    _+_    ^ ^     [_al_] list    [_s_] search    [_u_] revert buffer
       ^^^↑^^^      ^↑^    _H_    ^↑^  ↦ _W_ ↤   [_am_] markup  [_o_] outline   [_i_] info
       ^^_p_^^      ^ ^    ^↥^    _0_    ^ ^     [_at_] text    [_F_] link      [_d_] dark mode
       ^^^↑^^^      ^↓^  ╭─^─^─┐  ^↓^  ╭─^ ^─┐   [_ad_] delete  [_f_] search link
  _h_ ←pag_e_→ _l_  _N_  │ _P_ │  _-_    _b_     [_aa_] dired
       ^^^↓^^^      ^ ^  ╰─^─^─╯  ^ ^  ╰─^ ^─╯   [_y_]  yank
       ^^_n_^^      ^ ^  _r_eset slice box
    ("\\" hydra-master/body "back")
    ("<ESC>" nil "quit")
    ("al" pdf-annot-list-annotations)
    ("ad" pdf-annot-delete)
    ("aa" pdf-annot-attachment-dired)
    ("am" pdf-annot-add-markup-annotation)
    ("at" pdf-annot-add-text-annotation)
    ("y"  pdf-view-kill-ring-save)
    ("+" pdf-view-enlarge :color red)
    ("-" pdf-view-shrink :color red)
    ("0" pdf-view-scale-reset)
    ("H" pdf-view-fit-height-to-window)
    ("W" pdf-view-fit-width-to-window)
    ("P" pdf-view-fit-page-to-window)
    ("n" pdf-view-next-page-command :color red)
    ("p" pdf-view-previous-page-command :color red)
    ("d" pdf-view-dark-minor-mode)
    ("b" pdf-view-set-slice-from-bounding-box)
    ("r" pdf-view-reset-slice)
    ("g" pdf-view-first-page)
    ("G" pdf-view-last-page)
    ("e" pdf-view-goto-page)
    ("o" pdf-outline)
    ("s" pdf-occur)
    ("i" pdf-misc-display-metadata)
    ("u" pdf-view-revert-buffer)
    ("F" pdf-links-action-perfom)
    ("f" pdf-links-isearch-link)
    ("B" pdf-history-backward :color red)
    ("N" pdf-history-forward :color red)
    ("l" image-forward-hscroll :color red)
    ("h" image-backward-hscroll :color red)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.