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-link-set-parameters "ebib"
  22. :follow #'org-ebib-open
  23. :store #'org-ebib-store-link)
  24. (defun org-ebib-open (key)
  25. "Open Ebib and jump to KEY."
  26. (ebib nil key))
  27. (defun org-ebib-store-link ()
  28. "Store a key to an Ebib entry."
  29. (when (memq major-mode '(ebib-index-mode ebib-entry-mode))
  30. ;; This is an Ebib entry
  31. (let* ((key (ebib-cur-entry-key))
  32. (link (concat "ebib:" key))
  33. (description (ignore-errors (ebib-db-get-field-value 'title key ebib-cur-db))))
  34. (org-store-link-props
  35. :type "ebib"
  36. :link link
  37. :description description))))
  38. (provide 'org-ebib)
  39. ;;; org-ebib.el ends here