diff --git a/setup-files/setup-pdf.el b/setup-files/setup-pdf.el index ad316425..d1371f7c 100644 --- a/setup-files/setup-pdf.el +++ b/setup-files/setup-pdf.el @@ -1,4 +1,4 @@ -;; Time-stamp: <2015-02-06 15:41:50 kmodi> +;; Time-stamp: <2015-02-06 18:50:53 kmodi> ;; PDF @@ -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)