Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.2 KiB

4 years ago
  1. ;;; biblio-download.el --- Lookup bibliographic information and open access records from Dissemin -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2016 Clément Pit-Claudel
  3. ;; Author: Clément Pit-Claudel <clement.pitclaudel@live.com>
  4. ;; URL: http://github.com/cpitclaudel/biblio.el
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;;
  10. ;; This program is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;;
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;;
  19. ;; Download scientific papers directly from Emacs.
  20. ;;
  21. ;; This package plugs into `biblio-selection-mode' by adding an entry to the
  22. ;; extended actions menu (`x').
  23. ;;; Code:
  24. (require 'biblio-core)
  25. (defcustom biblio-download-directory nil
  26. "Where to put downloaded papers."
  27. :group 'biblio
  28. :type 'directory)
  29. (defun biblio-download--action (record)
  30. "Retrieve a RECORD from Dissemin, and display it.
  31. RECORD is a formatted record as expected by `biblio-insert-result'."
  32. (let-alist record
  33. (if .direct-url
  34. (let* ((fname (concat .identifier ".pdf"))
  35. (target (read-file-name "Save as (see also biblio-download-directory): "
  36. biblio-download-directory fname nil fname)))
  37. (url-copy-file .direct-url (expand-file-name target biblio-download-directory)))
  38. (user-error "This record does not contain a direct URL (try arXiv or HAL)"))))
  39. ;;;###autoload
  40. (defun biblio-download--register-action ()
  41. "Add download to list of `biblio-selection-mode' actions."
  42. (add-to-list 'biblio-selection-mode-actions-alist
  43. '("Download this article" . biblio-download--action)))
  44. ;;;###autoload
  45. (add-hook 'biblio-selection-mode-hook #'biblio-download--register-action)
  46. (provide 'biblio-download)
  47. ;;; biblio-download.el ends here