ob-keys.el 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ;;; ob-keys.el --- Key Bindings for Babel -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
  3. ;; Author: Eric Schulte
  4. ;; Keywords: literate programming, reproducible research
  5. ;; Homepage: http://orgmode.org
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs 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 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs 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 <https://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; Add Org Babel keybindings to the Org mode keymap for exposing
  19. ;; Org Babel functions. These will all share a common prefix. See
  20. ;; the value of `org-babel-key-bindings' for a list of interactive
  21. ;; functions and their associated keys.
  22. ;;; Code:
  23. (require 'ob-core)
  24. (defvar org-babel-key-prefix "\C-c\C-v"
  25. "The key prefix for Babel interactive key-bindings.
  26. See `org-babel-key-bindings' for the list of interactive babel
  27. functions which are assigned key bindings, and see
  28. `org-babel-map' for the actual babel keymap.")
  29. (defvar org-babel-map (make-sparse-keymap)
  30. "The keymap for interactive Babel functions.")
  31. ;;;###autoload
  32. (defun org-babel-describe-bindings ()
  33. "Describe all keybindings behind `org-babel-key-prefix'."
  34. (interactive)
  35. (describe-bindings org-babel-key-prefix))
  36. (defvar org-babel-key-bindings
  37. '(("p" . org-babel-previous-src-block)
  38. ("\C-p" . org-babel-previous-src-block)
  39. ("n" . org-babel-next-src-block)
  40. ("\C-n" . org-babel-next-src-block)
  41. ("e" . org-babel-execute-maybe)
  42. ("\C-e" . org-babel-execute-maybe)
  43. ("o" . org-babel-open-src-block-result)
  44. ("\C-o" . org-babel-open-src-block-result)
  45. ("\C-v" . org-babel-expand-src-block)
  46. ("v" . org-babel-expand-src-block)
  47. ("u" . org-babel-goto-src-block-head)
  48. ("\C-u" . org-babel-goto-src-block-head)
  49. ("g" . org-babel-goto-named-src-block)
  50. ("r" . org-babel-goto-named-result)
  51. ("\C-r" . org-babel-goto-named-result)
  52. ("\C-b" . org-babel-execute-buffer)
  53. ("b" . org-babel-execute-buffer)
  54. ("\C-s" . org-babel-execute-subtree)
  55. ("s" . org-babel-execute-subtree)
  56. ("\C-d" . org-babel-demarcate-block)
  57. ("d" . org-babel-demarcate-block)
  58. ("\C-t" . org-babel-tangle)
  59. ("t" . org-babel-tangle)
  60. ("\C-f" . org-babel-tangle-file)
  61. ("f" . org-babel-tangle-file)
  62. ("\C-c" . org-babel-check-src-block)
  63. ("c" . org-babel-check-src-block)
  64. ("\C-j" . org-babel-insert-header-arg)
  65. ("j" . org-babel-insert-header-arg)
  66. ("\C-l" . org-babel-load-in-session)
  67. ("l" . org-babel-load-in-session)
  68. ("\C-i" . org-babel-lob-ingest)
  69. ("i" . org-babel-lob-ingest)
  70. ("\C-I" . org-babel-view-src-block-info)
  71. ("I" . org-babel-view-src-block-info)
  72. ("\C-z" . org-babel-switch-to-session)
  73. ("z" . org-babel-switch-to-session-with-code)
  74. ("\C-a" . org-babel-sha1-hash)
  75. ("a" . org-babel-sha1-hash)
  76. ("h" . org-babel-describe-bindings)
  77. ("\C-x" . org-babel-do-key-sequence-in-edit-buffer)
  78. ("x" . org-babel-do-key-sequence-in-edit-buffer)
  79. ("k" . org-babel-remove-result-one-or-many)
  80. ("\C-\M-h" . org-babel-mark-block))
  81. "Alist of key bindings and interactive Babel functions.
  82. This list associates interactive Babel functions
  83. with keys. Each element of this list will add an entry to the
  84. `org-babel-map' using the letter key which is the `car' of the
  85. a-list placed behind the generic `org-babel-key-prefix'.")
  86. (provide 'ob-keys)
  87. ;; Local variables:
  88. ;; generated-autoload-file: "org-loaddefs.el"
  89. ;; End:
  90. ;;; ob-keys.el ends here