ob-redis.el 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ;;; ob-redis.el --- Execute Redis queries within org-mode blocks.
  2. ;; Copyright 2016 stardiviner
  3. ;; Author: stardiviner <numbchild@gmail.com>
  4. ;; Maintainer: stardiviner <numbchild@gmail.com>
  5. ;; Keywords: org babel redis
  6. ;; URL: https://github.com/stardiviner/ob-redis
  7. ;; Created: 28th Feb 2016
  8. ;; Version: 0.0.1
  9. ;; Package-Requires: ((org "8"))
  10. ;;; Commentary:
  11. ;;
  12. ;; Execute Redis queries within org-mode blocks.
  13. ;;; Code:
  14. (require 'org)
  15. (require 'ob)
  16. (defgroup ob-redis nil
  17. "org-mode blocks for Redis."
  18. :group 'org)
  19. (defcustom ob-redis:default-db "127.0.0.1:6379"
  20. "Default Redis database."
  21. :group 'ob-redis
  22. :type 'string)
  23. ;;;###autoload
  24. (defun org-babel-execute:redis (body params)
  25. "org-babel redis hook."
  26. (let* ((db (or (cdr (assoc :db params))
  27. ob-redis:default-db))
  28. (cmd (mapconcat 'identity (list "redis-cli") " ")))
  29. (org-babel-eval cmd body)
  30. ))
  31. ;;;###autoload
  32. (eval-after-load "org"
  33. '(add-to-list 'org-src-lang-modes '("redis" . redis)))
  34. (provide 'ob-redis)
  35. ;;; ob-redis.el ends here