Skip to content

Commit

Permalink
Use elisp to replace the hassle of having to manually update
Browse files Browse the repository at this point in the history
`pdf-info-epdfinfo-program' variable after each update of `pdf-tools'
package before calling the `pdf-tools-install' function to rebuild the
`epdfinfo' binary
  • Loading branch information
kaushalmodi committed Feb 6, 2015
1 parent c2bdcd6 commit ad166ce
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions setup-files/setup-pdf.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; Time-stamp: <2015-02-06 15:41:50 kmodi>
;; Time-stamp: <2015-02-06 18:50:53 kmodi>

;; PDF

Expand All @@ -15,7 +15,41 @@
(req-package pdf-tools
:config
(progn
(pdf-tools-install)))

(defun my/get-latest-pdf-tools-dir ()
"Get the full directory path of the latest installed version of
pdf-tools package."
(interactive)
;; Get a list of directories and files in `package-user-dir'
(let ((my/package-dirs (directory-files package-user-dir)))
;; `break' implementation in elisp
;; http://ergoemacs.org/emacs/elisp_break_loop.html
(catch 'break
(dotimes (index (safe-length my/package-dirs))
(let ((dir-name (pop my/package-dirs))
full-dir-name)
;; (message "%s" dir-name) ; debug
;; Find a directory name that matches "pdf-tools-*"
(when (string-match "pdf\\-tools\\-.*" dir-name)
(setq full-dir-name (concat package-user-dir "/" dir-name))
;; To ensure that the directory is valid, ensure that it
;; contains "pdf-tools.el"
(when (locate-file "pdf-tools.el" (list full-dir-name))
;; break the `dotimes' loop on finding this directory
;; and return its full path
(throw 'break full-dir-name))))))))

(defun my/pdf-tools-install ()
(interactive)
;; Update the `pdf-info-epdfinfo-program' variable to point to
;; the directory containing the latest version of `pdf-tools'
(setq pdf-info-epdfinfo-program
(concat (my/get-latest-pdf-tools-dir) "/epdfinfo"))
;; Call the original `pdf-tools-install' function after updating the
;; `pdf-info-epdfinfo-program' variable
(pdf-tools-install))

(my/pdf-tools-install)))


(provide 'setup-pdf)

0 comments on commit ad166ce

Please sign in to comment.