Rudy’s OBTF Rudolf Adamkovič

Home / Emacs / PDF Tools


Configure!

Install the package.

(with-eval-after-load 'package
  (add-to-list 'package-selected-packages 'pdf-tools))
(add-hook 'after-init-hook
          (lambda ()
            (when (package-installed-p 'pdf-tools)
              (pdf-loader-install 'no-query))))

Make the g key typed in a pdf-occur buffer search again with a new query. The pdf-tools package provides this functionality by default, albeit under the less practical C-u g key binding.

(with-eval-after-load 'pdf-occur
  (defun pdf-occur-search-again+ ()
    (interactive)
    (pdf-occur-assert-occur-buffer-p)
    (setq-local pdf-occur-search-string (pdf-occur-read-string))
    (pdf-occur-revert-buffer))
  (keymap-set pdf-occur-buffer-mode-map "g" #'pdf-occur-search-again+))

Make M-RET in the PDF Outline not just follow the link but also hide the outline, and do the same for the mouse-1 click. Retain the old behavior under M-RET, effectively swapping RET and M-RET.

(with-eval-after-load 'pdf-outline
  (keymap-set pdf-outline-buffer-mode-map
              "RET"
              #'pdf-outline-follow-link-and-quit)
  (keymap-set pdf-outline-buffer-mode-map
              "<mouse-1>"
              #'pdf-outline-follow-link-and-quit)
  (keymap-set pdf-outline-buffer-mode-map
              "M-RET"
              #'pdf-outline-follow-link))

Map C-s to incremental search forward (isearch-forward).

(with-eval-after-load 'pdf-view
  (keymap-set pdf-view-mode-map "C-s" #'isearch-forward))

Fake the missing auto-load for dired search.

(autoload #'pdf-occur-dired-do-search "pdf-occur" nil '(dired-mode))

Search PDF files in the Citar library.

A better way: Search the outlines.

(defun pdf-occur-search-citar-library-files+ ()
  "Search PDF files in the Citar library."
  (interactive)
  (require 'pdf-occur)
  (require 'citar)
  (let ((query (pdf-occur-read-string))
        (documents (mapcan (lambda (path)
                             (directory-files path t "\\.pdf$"))
                           citar-library-paths)))
    (pdf-occur-search documents query)))


© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.