org-ebib.el 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ;;; org-ebib.el - Support for links to Ebib's entries in Org
  2. ;;
  3. ;; Author: Grégoire Jadi <daimrod@gmail.com>
  4. ;;
  5. ;; This file is not yet part of GNU Emacs.
  6. ;;
  7. ;; This program is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation; either version 3, or (at your option)
  10. ;; any later version.
  11. ;; This program is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18. ;;
  19. ;;; Commentary:
  20. (require 'org)
  21. (org-add-link-type "ebib" 'org-ebib-open)
  22. (add-hook 'org-store-link-functions 'org-ebib-store-link)
  23. (defun org-ebib-open (key)
  24. "Open Ebib and jump to KEY."
  25. (ebib nil key))
  26. (defun org-ebib-store-link ()
  27. "Store a key to an Ebib entry."
  28. (when (memq major-mode '(ebib-index-mode ebib-entry-mode))
  29. ;; This is an Ebib entry
  30. (let* ((key (ebib-cur-entry-key))
  31. (link (concat "ebib:" key))
  32. (description (ignore-errors (ebib-db-get-field-value 'title key ebib-cur-db))))
  33. (org-store-link-props
  34. :type "ebib"
  35. :link link
  36. :description description))))
  37. (provide 'org-ebib)
  38. ;;; org-ebib.el ends here