org-babel-keys.el 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ;;; org-babel-keys.el --- key bindings for org-babel
  2. ;; Copyright (C) 2009 Eric Schulte
  3. ;; Author: Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; Version: 0.01
  7. ;;; License:
  8. ;; This program is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 3, or (at your option)
  11. ;; any later version.
  12. ;;
  13. ;; This program is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;;
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  20. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. ;; Boston, MA 02110-1301, USA.
  22. ;;; Commentary:
  23. ;; Add some org-babel keybindings to the org-mode keymap for exposing
  24. ;; org-babel functions. These will all share the common C-c M-b
  25. ;; prefix. See the value of `org-babel-key-bindings' for a list of
  26. ;; interactive functions and their associated keys.
  27. ;;; Code:
  28. (require 'org-babel)
  29. (defvar org-babel-key-prefix "\C-c\C-v"
  30. "The `org-babel-key-prefix' variable holds the key prefix
  31. behind which all org-babel interactive key-binding are placed.
  32. See `org-babel-key-bindings' for the list of interactive babel
  33. functions which are assigned key bindings, and see
  34. `org-babel-map' for the actual babel keymap.")
  35. (defvar org-babel-map (make-sparse-keymap)
  36. "The keymap holding key bindings for interactive org-babel
  37. functions.")
  38. (define-key org-mode-map org-babel-key-prefix org-babel-map)
  39. (defun org-babel-describe-bindings ()
  40. "Describe all key binding placed behind the
  41. `org-babel-key-prefix' prefix."
  42. (interactive)
  43. (describe-bindings org-babel-key-prefix))
  44. (defvar org-babel-key-bindings
  45. '(("\C-p" . org-babel-expand-src-block)
  46. ("p" . org-babel-expand-src-block)
  47. ("\C-g" . org-babel-goto-named-source-block)
  48. ("g" . org-babel-goto-named-source-block)
  49. ("\C-b" . org-babel-execute-buffer)
  50. ("b" . org-babel-execute-buffer)
  51. ("\C-s" . org-babel-execute-subtree)
  52. ("s" . org-babel-execute-subtree)
  53. ("\C-t" . org-babel-tangle)
  54. ("t" . org-babel-tangle)
  55. ("\C-f" . org-babel-tangle-file)
  56. ("f" . org-babel-tangle-file)
  57. ("\C-l" . org-babel-lob-ingest)
  58. ("l" . org-babel-lob-ingest)
  59. ("\C-z" . org-babel-switch-to-session)
  60. ("z" . org-babel-switch-to-session)
  61. ("\C-a" . org-babel-sha1-hash)
  62. ("a" . org-babel-sha1-hash)
  63. ("h" . org-babel-describe-bindings))
  64. "Alist associating key bindings with interactive Org-babel
  65. functions. This list associates interactive org-babel functions
  66. with keys. Each element of this list will add an entry to the
  67. `org-babel-map' using the letter key which is the `car' of the
  68. a-list placed behind the generic `org-babel-key-prefix'.")
  69. (mapc (lambda (pair)
  70. (define-key org-babel-map (car pair) (cdr pair)))
  71. org-babel-key-bindings)
  72. (provide 'org-babel-keys)
  73. ;;; org-babel-keys.el ends here