config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

org-keys.el (42544B)


      1 ;;; org-keys.el --- Key bindings for Org mode        -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2018-2024 Free Software Foundation, Inc.
      4 
      5 ;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
      6 
      7 ;; This file is part of GNU Emacs.
      8 
      9 ;; GNU Emacs is free software; you can redistribute it and/or modify
     10 ;; it under the terms of the GNU General Public License as published by
     11 ;; the Free Software Foundation, either version 3 of the License, or
     12 ;; (at your option) any later version.
     13 
     14 ;; GNU Emacs is distributed in the hope that it will be useful,
     15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 ;; GNU General Public License for more details.
     18 
     19 ;; You should have received a copy of the GNU General Public License
     20 ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
     21 
     22 ;;; Commentary:
     23 
     24 ;; This library adds bindings for Org mode buffers.  It also
     25 ;; implements both Speed keys and Babel speed keys.  See manual for
     26 ;; details.
     27 
     28 ;;; Code:
     29 
     30 (require 'org-macs)
     31 (org-assert-version)
     32 
     33 (require 'cl-lib)
     34 
     35 (defvar org-outline-regexp)
     36 
     37 (require 'oc)
     38 
     39 (declare-function org-add-note "org" ())
     40 (declare-function org-agenda "org" (&optional arg org-keys restriction))
     41 (declare-function org-agenda-file-to-front "org" (&optional to-end))
     42 (declare-function org-agenda-remove-restriction-lock "org" (&optional noupdate))
     43 (declare-function org-agenda-set-restriction-lock "org" (&optional type))
     44 (declare-function org-archive-subtree "org" (&optional find-done))
     45 (declare-function org-archive-subtree-default "org" ())
     46 (declare-function org-archive-subtree-default-with-confirmation "org" ())
     47 (declare-function org-archive-to-archive-sibling "org" ())
     48 (declare-function org-at-heading-p "org" (&optional ignored))
     49 (declare-function org-attach "org" ())
     50 (declare-function org-backward-element "org" ())
     51 (declare-function org-backward-heading-same-level "org" (arg &optional invisible-ok))
     52 (declare-function org-backward-paragraph "org" ())
     53 (declare-function org-backward-sentence "org" (&optional arg))
     54 (declare-function org-beginning-of-line "org" (&optional n))
     55 (declare-function org-clock-cancel "org" ())
     56 (declare-function org-clock-display "org" (&optional arg))
     57 (declare-function org-clock-goto "org" (&optional select))
     58 (declare-function org-clock-in "org" (&optional select start-time))
     59 (declare-function org-clock-in-last "org" (&optional arg))
     60 (declare-function org-clock-out "org" (&optional switch-to-state fail-quietly at-time))
     61 (declare-function org-clone-subtree-with-time-shift "org" (n &optional shift))
     62 (declare-function org-columns "org" (&optional global columns-fmt-string))
     63 (declare-function org-comment-dwim "org" (arg))
     64 (declare-function org-copy-special "org" ())
     65 (declare-function org-copy-visible "org" (beg end))
     66 (declare-function org-ctrl-c-ctrl-c "org" (&optional arg))
     67 (declare-function org-ctrl-c-minus "org" ())
     68 (declare-function org-ctrl-c-ret "org" ())
     69 (declare-function org-ctrl-c-star "org" ())
     70 (declare-function org-ctrl-c-tab "org" (&optional arg))
     71 (declare-function org-cut-special "org" ())
     72 (declare-function org-cut-subtree "org" (&optional n))
     73 (declare-function org-cycle "org-cycle" (&optional arg))
     74 (declare-function org-cycle-agenda-files "org-cycle" ())
     75 (declare-function org-date-from-calendar "org" ())
     76 (declare-function org-dynamic-block-insert-dblock "org" (&optional arg))
     77 (declare-function org-dblock-update "org" (&optional arg))
     78 (declare-function org-deadline "org" (arg1 &optional time))
     79 (declare-function org-decrease-number-at-point "org" (&optional inc))
     80 (declare-function org-delete-backward-char "org" (n))
     81 (declare-function org-delete-char "org" (n))
     82 (declare-function org-delete-indentation "org" (&optional arg))
     83 (declare-function org-demote-subtree "org" ())
     84 (declare-function org-display-outline-path "org" (&optional file current separator just-return-string))
     85 (declare-function org-down-element "org" ())
     86 (declare-function org-edit-special "org" (&optional arg))
     87 (declare-function org-element-at-point "org-element" (&optional pom cached-only))
     88 (declare-function org-element-type-p "org-element-ast" (node types))
     89 (declare-function org-emphasize "org" (&optional char))
     90 (declare-function org-end-of-line "org" (&optional n))
     91 (declare-function org-entry-put "org" (pom property value))
     92 (declare-function org-eval-in-calendar "org" (form &optional keepdate))
     93 (declare-function org-calendar-goto-today-or-insert-dot "org" ())
     94 (declare-function org-calendar-goto-today "org" ())
     95 (declare-function org-calendar-backward-month "org" ())
     96 (declare-function org-calendar-forward-month "org" ())
     97 (declare-function org-calendar-backward-year "org" ())
     98 (declare-function org-calendar-forward-year "org" ())
     99 (declare-function org-calendar-backward-week "org" ())
    100 (declare-function org-calendar-forward-week "org" ())
    101 (declare-function org-calendar-backward-day "org" ())
    102 (declare-function org-calendar-forward-day "org" ())
    103 (declare-function org-calendar-view-entries "org" ())
    104 (declare-function org-calendar-scroll-month-left "org" ())
    105 (declare-function org-calendar-scroll-month-right "org" ())
    106 (declare-function org-calendar-scroll-three-months-left "org" ())
    107 (declare-function org-calendar-scroll-three-months-right "org" ())
    108 (declare-function org-evaluate-time-range "org" (&optional to-buffer))
    109 (declare-function org-export-dispatch "org" (&optional arg))
    110 (declare-function org-feed-goto-inbox "org" (feed))
    111 (declare-function org-feed-update-all "org" ())
    112 (declare-function org-fill-paragraph "org" (&optional justify region))
    113 (declare-function org-find-file-at-mouse "org" (ev))
    114 (declare-function org-footnote-action "org" (&optional special))
    115 (declare-function org-cycle-force-archived "org-cycle" ())
    116 (declare-function org-force-self-insert "org" (n))
    117 (declare-function org-forward-element "org" ())
    118 (declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok))
    119 (declare-function org-forward-paragraph "org" ())
    120 (declare-function org-forward-sentence "org" (&optional arg))
    121 (declare-function org-goto "org" (&optional alternative-interface))
    122 (declare-function org-goto-calendar "org" (&optional arg))
    123 (declare-function org-inc-effort "org" ())
    124 (declare-function org-increase-number-at-point "org" (&optional inc))
    125 (declare-function org-info-find-node "org" (&optional nodename))
    126 (declare-function org-insert-all-links "org" (arg &optional pre post))
    127 (declare-function org-insert-drawer "org" (&optional arg drawer))
    128 (declare-function org-insert-heading-respect-content "org" (&optional invisible-ok))
    129 (declare-function org-insert-last-stored-link "org" (arg))
    130 (declare-function org-insert-link "org" (&optional complete-file link-location default-description))
    131 (declare-function org-insert-structure-template "org" (type))
    132 (declare-function org-insert-todo-heading "org" (arg &optional force-heading))
    133 (declare-function org-insert-todo-heading-respect-content "org" (&optional force-state))
    134 (declare-function org-kill-line "org" (&optional arg))
    135 (declare-function org-kill-note-or-show-branches "org" ())
    136 (declare-function org-list-make-subtree "org" ())
    137 (declare-function org-mark-element "org" ())
    138 (declare-function org-mark-ring-goto "org" (&optional n))
    139 (declare-function org-mark-ring-push "org" (&optional pos buffer))
    140 (declare-function org-mark-subtree "org" (&optional up))
    141 (declare-function org-match-sparse-tree "org" (&optional todo-only match))
    142 (declare-function org-meta-return "org" (&optional arg))
    143 (declare-function org-metadown "org" (&optional _arg))
    144 (declare-function org-metaleft "org" (&optional _))
    145 (declare-function org-metaright "org" (&optional _arg))
    146 (declare-function org-metaup "org" (&optional _arg))
    147 (declare-function org-narrow-to-block "org" ())
    148 (declare-function org-narrow-to-element "org" ())
    149 (declare-function org-narrow-to-subtree "org" (&optional element))
    150 (declare-function org-next-block "org" (arg &optional backward block-regexp))
    151 (declare-function org-next-link "org" (&optional search-backward))
    152 (declare-function org-next-visible-heading "org" (arg))
    153 (declare-function org-open-at-mouse "org" (ev))
    154 (declare-function org-open-at-point "org" (&optional arg reference-buffer))
    155 (declare-function org-open-line "org" (n))
    156 (declare-function org-paste-special "org" (arg))
    157 (declare-function org-plot/gnuplot "org-plot" (&optional params))
    158 (declare-function org-previous-block "org" (arg &optional block-regexp))
    159 (declare-function org-previous-link "org" ())
    160 (declare-function org-previous-visible-heading "org" (arg))
    161 (declare-function org-priority "org" (&optional action show))
    162 (declare-function org-promote-subtree "org" ())
    163 (declare-function org-redisplay-inline-images "org" ())
    164 (declare-function org-refile "org-refile" (&optional arg1 default-buffer rfloc msg))
    165 (declare-function org-refile-copy "org-refile" ())
    166 (declare-function org-refile-reverse "org-refile" (&optional arg default-buffer rfloc msg))
    167 (declare-function org-reftex-citation "org" ())
    168 (declare-function org-reload "org" (&optional arg1))
    169 (declare-function org-remove-file "org" (&optional file))
    170 (declare-function org-resolve-clocks "org" (&optional only-dangling-p prompt-fn last-valid))
    171 (declare-function org-return "org" (&optional indent))
    172 (declare-function org-return-and-maybe-indent "org" ())
    173 (declare-function org-fold-reveal "org-fold" (&optional siblings))
    174 (declare-function org-schedule "org" (arg &optional time))
    175 (declare-function org-self-insert-command "org" (N))
    176 (declare-function org-set-effort "org" (&optional increment value))
    177 (declare-function org-set-property "org" (property value))
    178 (declare-function org-set-property-and-value "org" (use-last))
    179 (declare-function org-set-tags-command "org" (&optional arg))
    180 (declare-function org-shiftcontroldown "org" (&optional n))
    181 (declare-function org-shiftcontrolleft "org" ())
    182 (declare-function org-shiftcontrolright "org" ())
    183 (declare-function org-shiftcontrolup "org" (&optional n))
    184 (declare-function org-shiftdown "org" (&optional arg))
    185 (declare-function org-shiftleft "org" (&optional arg))
    186 (declare-function org-shiftmetadown "org" (&optional _arg))
    187 (declare-function org-shiftmetaleft "org" ())
    188 (declare-function org-shiftmetaright "org" ())
    189 (declare-function org-shiftmetaup "org" (&optional arg))
    190 (declare-function org-shiftright "org" (&optional arg))
    191 (declare-function org-shifttab "org" (&optional arg))
    192 (declare-function org-shiftup "org" (&optional arg))
    193 (declare-function org-fold-show-all "org-fold" (&optional types))
    194 (declare-function org-fold-show-children "org-fold" (&optional level))
    195 (declare-function org-fold-show-subtree "org-fold" ())
    196 (declare-function org-sort "org" (&optional with-case))
    197 (declare-function org-sparse-tree "org" (&optional arg type))
    198 (declare-function org-table-copy-down "org" (n))
    199 (declare-function org-table-create-or-convert-from-region "org" (arg))
    200 (declare-function org-table-create-with-table\.el "org-table" ())
    201 (declare-function org-table-edit-field "org" (arg))
    202 (declare-function org-table-eval-formula "org" (&optional arg equation suppress-align suppress-const suppress-store suppress-analysis))
    203 (declare-function org-table-field-info "org" (arg))
    204 (declare-function org-table-rotate-recalc-marks "org" (&optional newchar))
    205 (declare-function org-table-sum "org" (&optional beg end nlast))
    206 (declare-function org-table-toggle-coordinate-overlays "org" ())
    207 (declare-function org-table-toggle-formula-debugger "org" ())
    208 (declare-function org-timestamp "org" (arg &optional inactive))
    209 (declare-function org-timestamp-inactive "org" (&optional arg))
    210 (declare-function org-timer "org" (&optional restart no-insert))
    211 (declare-function org-timer-item "org" (&optional arg))
    212 (declare-function org-timer-pause-or-continue "org" (&optional stop))
    213 (declare-function org-timer-set-timer "org" (&optional opt))
    214 (declare-function org-timer-start "org" (&optional offset))
    215 (declare-function org-timer-stop "org" ())
    216 (declare-function org-todo "org" (&optional arg1))
    217 (declare-function org-toggle-archive-tag "org" (&optional find-done))
    218 (declare-function org-toggle-checkbox "org" (&optional toggle-presence))
    219 (declare-function org-toggle-radio-button "org" (&optional arg))
    220 (declare-function org-toggle-comment "org" ())
    221 (declare-function org-toggle-fixed-width "org" ())
    222 (declare-function org-toggle-inline-images "org" (&optional include-linked beg end))
    223 (declare-function org-latex-preview "org" (&optional arg))
    224 (declare-function org-toggle-narrow-to-subtree "org" ())
    225 (declare-function org-toggle-ordered-property "org" ())
    226 (declare-function org-toggle-pretty-entities "org" ())
    227 (declare-function org-toggle-tags-groups "org" ())
    228 (declare-function org-toggle-timestamp-overlays "org" ())
    229 (declare-function org-transpose-element "org" ())
    230 (declare-function org-transpose-words "org" ())
    231 (declare-function org-tree-to-indirect-buffer "org" (&optional arg))
    232 (declare-function org-up-element "org" ())
    233 (declare-function org-update-statistics-cookies "org" (all))
    234 (declare-function org-yank "org" (&optional arg))
    235 (declare-function orgtbl-ascii-plot "org-table" (&optional ask))
    236 
    237 
    238 
    239 ;;; Variables
    240 
    241 (defvar org-mode-map (make-sparse-keymap)
    242   "Keymap for Org mode.")
    243 
    244 (defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)
    245 
    246 (defcustom org-replace-disputed-keys nil
    247   "Non-nil means use alternative key bindings for some keys.
    248 
    249 Org mode uses S-<cursor> keys for changing timestamps and priorities.
    250 These keys are also used by other packages like Shift Select mode,
    251 CUA mode or Windmove.  If you want to use Org mode together with
    252 one of these other modes, or more generally if you would like to
    253 move some Org mode commands to other keys, set this variable and
    254 configure the keys with the variable `org-disputed-keys'.
    255 
    256 This option is only relevant at load-time of Org mode, and must be set
    257 *before* org.el is loaded.  Changing it requires a restart of Emacs to
    258 become effective."
    259   :group 'org-startup
    260   :type 'boolean
    261   :safe #'booleanp)
    262 
    263 (defcustom org-use-extra-keys nil
    264   "Non-nil means use extra key sequence definitions for certain commands.
    265 This happens automatically if `display-graphic-p' returns nil.  This
    266 variable lets you do the same manually.  You must set it before
    267 loading Org."
    268   :group 'org-startup
    269   :type 'boolean
    270   :safe #'booleanp)
    271 
    272 (defcustom org-disputed-keys
    273   '(([(shift up)]		. [(meta p)])
    274     ([(shift down)]		. [(meta n)])
    275     ([(shift left)]		. [(meta -)])
    276     ([(shift right)]		. [(meta +)])
    277     ([(control shift right)]    . [(meta shift +)])
    278     ([(control shift left)]	. [(meta shift -)]))
    279   "Keys for which Org mode and other modes compete.
    280 This is an alist, cars are the default keys, second element specifies
    281 the alternative to use when `org-replace-disputed-keys' is t.
    282 
    283 Keys can be specified in any syntax supported by `define-key'.
    284 The value of this option takes effect only at Org mode startup,
    285 therefore you'll have to restart Emacs to apply it after changing."
    286   :group 'org-startup
    287   :type 'alist)
    288 
    289 (defcustom org-mouse-1-follows-link
    290   (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t)
    291   "Non-nil means Mouse-1 on a link will follow the link.
    292 A longer mouse click will still set point.  Needs to be set
    293 before org.el is loaded."
    294   :group 'org-link-follow
    295   :version "26.1"
    296   :package-version '(Org . "8.3")
    297   :type '(choice
    298 	  (const :tag "A double click follows the link" double)
    299 	  (const :tag "Unconditionally follow the link with mouse-1" t)
    300 	  (integer :tag "mouse-1 click does not follow the link if longer than N ms" 450)))
    301 
    302 (defcustom org-tab-follows-link nil
    303   "Non-nil means on links TAB will follow the link.
    304 Needs to be set before Org is loaded.
    305 This really should not be used, it does not make sense, and the
    306 implementation is bad."
    307   :group 'org-link-follow
    308   :type 'boolean)
    309 
    310 (defcustom org-follow-link-hook nil
    311   "Hook that is run after a link has been followed."
    312   :group 'org-link-follow
    313   :type 'hook)
    314 
    315 (defcustom org-return-follows-link nil
    316   "Non-nil means on links RET will open links, timestamps, and citations.
    317 In tables, the special behavior of RET has precedence."
    318   :group 'org-link-follow
    319   :type 'boolean
    320   :safe #'booleanp)
    321 
    322 
    323 ;;; Functions
    324 
    325 ;;;; Base functions
    326 (defun org-key (key)
    327   "Select KEY according to `org-replace-disputed-keys' and `org-disputed-keys'.
    328 Or return the original if not disputed."
    329   (when org-replace-disputed-keys
    330     (let* ((nkey (key-description key))
    331 	   (x (cl-find-if (lambda (x) (equal (key-description (car x)) nkey))
    332 			  org-disputed-keys)))
    333       (setq key (if x (cdr x) key))))
    334   key)
    335 
    336 (defun org-defkey (keymap key def)
    337   "Define KEY, possibly translated, as returned by `org-key' in KEYMAP to DEF."
    338   (define-key keymap (org-key key) def))
    339 
    340 (defun org-remap (map &rest commands)
    341   "In MAP, remap the functions given in COMMANDS.
    342 COMMANDS is a list of alternating OLDDEF NEWDEF command names."
    343   (let (new old)
    344     (while commands
    345       (setq old (pop commands) new (pop commands))
    346       (org-defkey map (vector 'remap old) new))))
    347 
    348 
    349 ;;; Mouse map
    350 
    351 (defvar org-mouse-map (make-sparse-keymap))
    352 (org-defkey org-mouse-map [mouse-2] 'org-open-at-mouse)
    353 (org-defkey org-mouse-map [mouse-3] 'org-find-file-at-mouse)
    354 
    355 (when org-mouse-1-follows-link
    356   (org-defkey org-mouse-map [follow-link] 'mouse-face))
    357 
    358 (when org-tab-follows-link
    359   (org-defkey org-mouse-map (kbd "TAB") #'org-open-at-point))
    360 
    361 
    362 ;;; Read date map
    363 
    364 (defvar org-read-date-minibuffer-local-map
    365   (let* ((map (make-sparse-keymap)))
    366     (set-keymap-parent map minibuffer-local-map)
    367     (org-defkey map (kbd ".") #'org-calendar-goto-today-or-insert-dot)
    368     (org-defkey map (kbd "C-.") #'org-calendar-goto-today)
    369     (org-defkey map (kbd "M-S-<left>") #'org-calendar-backward-month)
    370     (org-defkey map (kbd "ESC S-<left>") #'org-calendar-backward-month)
    371     (org-defkey map (kbd "M-S-<right>") #'org-calendar-forward-month)
    372     (org-defkey map (kbd "ESC S-<right>") #'org-calendar-forward-month)
    373     (org-defkey map (kbd "M-S-<up>") #'org-calendar-backward-year)
    374     (org-defkey map (kbd "ESC S-<up>") #'org-calendar-backward-year)
    375     (org-defkey map (kbd "M-S-<down>") #'org-calendar-forward-year)
    376     (org-defkey map (kbd "ESC S-<down>") #'org-calendar-forward-year)
    377     (org-defkey map (kbd "S-<up>") #'org-calendar-backward-week)
    378     (org-defkey map (kbd "S-<down>") #'org-calendar-forward-week)
    379     (org-defkey map (kbd "S-<left>") #'org-calendar-backward-day)
    380     (org-defkey map (kbd "S-<right>") #'org-calendar-forward-day)
    381     (org-defkey map (kbd "!") #'org-calendar-view-entries)
    382     (org-defkey map (kbd ">") #'org-calendar-scroll-month-left)
    383     (org-defkey map (kbd "<") #'org-calendar-scroll-month-right)
    384     (org-defkey map (kbd "C-v") #'org-calendar-scroll-three-months-left)
    385     (org-defkey map (kbd "M-v") #'org-calendar-scroll-three-months-right)
    386     map)
    387   "Keymap for minibuffer commands when using `org-read-date'.")
    388 
    389 
    390 ;;; Global bindings
    391 
    392 ;;;; Outline functions
    393 (define-key org-mode-map [menu-bar headings] 'undefined)
    394 (define-key org-mode-map [menu-bar hide] 'undefined)
    395 (define-key org-mode-map [menu-bar show] 'undefined)
    396 
    397 (define-key org-mode-map [remap outline-mark-subtree] #'org-mark-subtree)
    398 (define-key org-mode-map [remap outline-show-subtree] #'org-fold-show-subtree)
    399 (define-key org-mode-map [remap outline-forward-same-level]
    400   #'org-forward-heading-same-level)
    401 (define-key org-mode-map [remap outline-backward-same-level]
    402   #'org-backward-heading-same-level)
    403 (define-key org-mode-map [remap outline-show-branches]
    404   #'org-kill-note-or-show-branches)
    405 (define-key org-mode-map [remap outline-promote] #'org-promote-subtree)
    406 (define-key org-mode-map [remap outline-demote] #'org-demote-subtree)
    407 (define-key org-mode-map [remap outline-insert-heading] #'org-ctrl-c-ret)
    408 (define-key org-mode-map [remap outline-next-visible-heading]
    409   #'org-next-visible-heading)
    410 (define-key org-mode-map [remap outline-previous-visible-heading]
    411   #'org-previous-visible-heading)
    412 (define-key org-mode-map [remap outline-show-children] #'org-fold-show-children)
    413 
    414 ;;;; Make `C-c C-x' a prefix key
    415 (org-defkey org-mode-map (kbd "C-c C-x") (make-sparse-keymap))
    416 
    417 ;;;; TAB key with modifiers
    418 (org-defkey org-mode-map (kbd "TAB") #'org-cycle)
    419 (org-defkey org-mode-map (kbd "C-c C-<tab>") #'org-cycle-force-archived)
    420 ;; Override text-mode binding to expose `complete-symbol' for
    421 ;; pcomplete functionality.
    422 (org-defkey org-mode-map (kbd "M-TAB") nil)
    423 (org-defkey org-mode-map (kbd "ESC TAB") nil)
    424 
    425 (org-defkey org-mode-map (kbd "S-TAB") #'org-shifttab)
    426 (define-key org-mode-map (kbd "<backtab>") #'org-shifttab)
    427 
    428 ;;;; RET/<return> key with modifiers
    429 (org-defkey org-mode-map (kbd "S-<return>") #'org-table-copy-down)
    430 (org-defkey org-mode-map (kbd "S-RET") #'org-table-copy-down)
    431 (org-defkey org-mode-map (kbd "M-S-<return>") #'org-insert-todo-heading)
    432 (org-defkey org-mode-map (kbd "M-S-RET") #'org-insert-todo-heading)
    433 (org-defkey org-mode-map (kbd "M-RET") #'org-meta-return)
    434 
    435 ;;;; Cursor keys with modifiers
    436 (org-defkey org-mode-map (kbd "M-<left>") #'org-metaleft)
    437 (org-defkey org-mode-map (kbd "ESC <left>") #'org-metaleft)
    438 (org-defkey org-mode-map (kbd "M-<right>") #'org-metaright)
    439 (org-defkey org-mode-map (kbd "ESC <right>") #'org-metaright)
    440 (org-defkey org-mode-map (kbd "M-<up>") #'org-metaup)
    441 (org-defkey org-mode-map (kbd "ESC <up>") #'org-metaup)
    442 (org-defkey org-mode-map (kbd "M-<down>") #'org-metadown)
    443 (org-defkey org-mode-map (kbd "ESC <down>") #'org-metadown)
    444 
    445 (org-defkey org-mode-map (kbd "C-M-S-<right>") #'org-increase-number-at-point)
    446 (org-defkey org-mode-map (kbd "C-M-S-<left>") #'org-decrease-number-at-point)
    447 (org-defkey org-mode-map (kbd "M-S-<left>") #'org-shiftmetaleft)
    448 (org-defkey org-mode-map (kbd "ESC S-<left>") #'org-shiftmetaleft)
    449 (org-defkey org-mode-map (kbd "M-S-<right>") #'org-shiftmetaright)
    450 (org-defkey org-mode-map (kbd "ESC S-<right>") #'org-shiftmetaright)
    451 (org-defkey org-mode-map (kbd "M-S-<up>") #'org-shiftmetaup)
    452 (org-defkey org-mode-map (kbd "ESC S-<up>") #'org-shiftmetaup)
    453 (org-defkey org-mode-map (kbd "M-S-<down>") #'org-shiftmetadown)
    454 (org-defkey org-mode-map (kbd "ESC S-<down>") #'org-shiftmetadown)
    455 
    456 (org-defkey org-mode-map (kbd "S-<up>") #'org-shiftup)
    457 (org-defkey org-mode-map (kbd "S-<down>") #'org-shiftdown)
    458 (org-defkey org-mode-map (kbd "S-<left>") #'org-shiftleft)
    459 (org-defkey org-mode-map (kbd "S-<right>") #'org-shiftright)
    460 
    461 (org-defkey org-mode-map (kbd "C-S-<right>") #'org-shiftcontrolright)
    462 (org-defkey org-mode-map (kbd "C-S-<left>") #'org-shiftcontrolleft)
    463 (org-defkey org-mode-map (kbd "C-S-<up>") #'org-shiftcontrolup)
    464 (org-defkey org-mode-map (kbd "C-S-<down>") #'org-shiftcontroldown)
    465 
    466 ;;;; Extra keys for TTY access.
    467 
    468 ;;  We only set them when really needed because otherwise the
    469 ;;  menus don't show the simple keys
    470 
    471 (when (or org-use-extra-keys (not (display-graphic-p)))
    472   (org-defkey org-mode-map (kbd "C-c C-x c") #'org-table-copy-down)
    473   (org-defkey org-mode-map (kbd "C-c C-x m") #'org-meta-return)
    474   (org-defkey org-mode-map (kbd "C-c C-x M") #'org-insert-todo-heading)
    475   (org-defkey org-mode-map (kbd "C-c C-x s") #'org-insert-structure-template)
    476   (org-defkey org-mode-map (kbd "C-c C-x RET") #'org-meta-return)
    477   (org-defkey org-mode-map (kbd "ESC RET") #'org-meta-return)
    478   (org-defkey org-mode-map (kbd "ESC <left>") #'org-metaleft)
    479   (org-defkey org-mode-map (kbd "C-c C-x l") #'org-metaleft)
    480   (org-defkey org-mode-map (kbd "ESC <right>") #'org-metaright)
    481   (org-defkey org-mode-map (kbd "C-c C-x r") #'org-metaright)
    482   (org-defkey org-mode-map (kbd "C-c C-x u") #'org-metaup)
    483   (org-defkey org-mode-map (kbd "C-c C-x d") #'org-metadown)
    484   (org-defkey org-mode-map (kbd "C-c C-x L") #'org-shiftmetaleft)
    485   (org-defkey org-mode-map (kbd "C-c C-x R") #'org-shiftmetaright)
    486   (org-defkey org-mode-map (kbd "C-c C-x U") #'org-shiftmetaup)
    487   (org-defkey org-mode-map (kbd "C-c C-x D") #'org-shiftmetadown)
    488   (org-defkey org-mode-map (kbd "C-c <up>") #'org-shiftup)
    489   (org-defkey org-mode-map (kbd "C-c <down>") #'org-shiftdown)
    490   (org-defkey org-mode-map (kbd "C-c <left>") #'org-shiftleft)
    491   (org-defkey org-mode-map (kbd "C-c <right>") #'org-shiftright)
    492   (org-defkey org-mode-map (kbd "C-c C-x <right>") #'org-shiftcontrolright)
    493   (org-defkey org-mode-map (kbd "C-c C-x <left>") #'org-shiftcontrolleft))
    494 
    495 ;;;; Narrowing bindings
    496 (org-defkey org-mode-map (kbd "C-x n s") #'org-narrow-to-subtree)
    497 (org-defkey org-mode-map (kbd "C-x n b") #'org-narrow-to-block)
    498 (org-defkey org-mode-map (kbd "C-x n e") #'org-narrow-to-element)
    499 
    500 ;;;; Remap usual Emacs bindings
    501 (org-remap org-mode-map
    502 	   'self-insert-command    'org-self-insert-command
    503 	   'delete-char            'org-delete-char
    504 	   'delete-backward-char   'org-delete-backward-char
    505 	   'kill-line              'org-kill-line
    506 	   'open-line              'org-open-line
    507 	   'yank                   'org-yank
    508 	   'comment-dwim           'org-comment-dwim
    509 	   'move-beginning-of-line 'org-beginning-of-line
    510 	   'move-end-of-line       'org-end-of-line
    511 	   'forward-paragraph      'org-forward-paragraph
    512 	   'backward-paragraph     'org-backward-paragraph
    513 	   'backward-sentence      'org-backward-sentence
    514 	   'forward-sentence       'org-forward-sentence
    515 	   'fill-paragraph         'org-fill-paragraph
    516 	   'delete-indentation     'org-delete-indentation
    517 	   'transpose-words        'org-transpose-words)
    518 
    519 ;;;; All the other keys
    520 (org-defkey org-mode-map (kbd "|") #'org-force-self-insert)
    521 (org-defkey org-mode-map (kbd "C-c C-r") #'org-fold-reveal)
    522 (org-defkey org-mode-map (kbd "C-M-t") #'org-transpose-element)
    523 (org-defkey org-mode-map (kbd "M-}") #'org-forward-element)
    524 (org-defkey org-mode-map (kbd "ESC }") #'org-forward-element)
    525 (org-defkey org-mode-map (kbd "M-{") #'org-backward-element)
    526 (org-defkey org-mode-map (kbd "ESC {") #'org-backward-element)
    527 (org-defkey org-mode-map (kbd "C-c C-^") #'org-up-element)
    528 (org-defkey org-mode-map (kbd "C-c C-_") #'org-down-element)
    529 (org-defkey org-mode-map (kbd "C-c C-f") #'org-forward-heading-same-level)
    530 (org-defkey org-mode-map (kbd "C-c C-b") #'org-backward-heading-same-level)
    531 (org-defkey org-mode-map (kbd "C-c M-f") #'org-next-block)
    532 (org-defkey org-mode-map (kbd "C-c M-b") #'org-previous-block)
    533 (org-defkey org-mode-map (kbd "C-c $") #'org-archive-subtree)
    534 (org-defkey org-mode-map (kbd "C-c C-x C-s") #'org-archive-subtree)
    535 (org-defkey org-mode-map (kbd "C-c C-x C-a") #'org-archive-subtree-default)
    536 (org-defkey org-mode-map (kbd "C-c C-x d") #'org-insert-drawer)
    537 (org-defkey org-mode-map (kbd "C-c C-x a") #'org-toggle-archive-tag)
    538 (org-defkey org-mode-map (kbd "C-c C-x A") #'org-archive-to-archive-sibling)
    539 (org-defkey org-mode-map (kbd "C-c C-x b") #'org-tree-to-indirect-buffer)
    540 (org-defkey org-mode-map (kbd "C-c C-x q") #'org-toggle-tags-groups)
    541 (org-defkey org-mode-map (kbd "C-c C-j") #'org-goto)
    542 (org-defkey org-mode-map (kbd "C-c C-t") #'org-todo)
    543 (org-defkey org-mode-map (kbd "C-c C-q") #'org-set-tags-command)
    544 (org-defkey org-mode-map (kbd "C-c C-s") #'org-schedule)
    545 (org-defkey org-mode-map (kbd "C-c C-d") #'org-deadline)
    546 (org-defkey org-mode-map (kbd "C-c ;") #'org-toggle-comment)
    547 (org-defkey org-mode-map (kbd "C-c C-w") #'org-refile)
    548 (org-defkey org-mode-map (kbd "C-c M-w") #'org-refile-copy)
    549 (org-defkey org-mode-map (kbd "C-c C-M-w") #'org-refile-reverse)
    550 (org-defkey org-mode-map (kbd "C-c /") #'org-sparse-tree) ;minor-mode reserved
    551 (org-defkey org-mode-map (kbd "C-c \\") #'org-match-sparse-tree) ;minor-mode r.
    552 (org-defkey org-mode-map (kbd "C-c RET") #'org-ctrl-c-ret)
    553 (org-defkey org-mode-map (kbd "C-c C-x c") #'org-clone-subtree-with-time-shift)
    554 (org-defkey org-mode-map (kbd "C-c C-x v") #'org-copy-visible)
    555 (org-defkey org-mode-map (kbd "C-<return>") #'org-insert-heading-respect-content)
    556 (org-defkey org-mode-map (kbd "C-S-<return>") #'org-insert-todo-heading-respect-content)
    557 (org-defkey org-mode-map (kbd "C-c C-x C-n") #'org-next-link)
    558 (org-defkey org-mode-map (kbd "C-c C-x C-p") #'org-previous-link)
    559 (org-defkey org-mode-map (kbd "C-c C-l") #'org-insert-link)
    560 (org-defkey org-mode-map (kbd "C-c M-l") #'org-insert-last-stored-link)
    561 (org-defkey org-mode-map (kbd "C-c C-M-l") #'org-insert-all-links)
    562 (org-defkey org-mode-map (kbd "C-c C-o") #'org-open-at-point)
    563 (org-defkey org-mode-map (kbd "C-c %") #'org-mark-ring-push)
    564 (org-defkey org-mode-map (kbd "C-c &") #'org-mark-ring-goto)
    565 (org-defkey org-mode-map (kbd "C-c C-z") #'org-add-note) ;alternative binding
    566 (org-defkey org-mode-map (kbd "C-c .") #'org-timestamp) ;minor-mode reserved
    567 (org-defkey org-mode-map (kbd "C-c !") #'org-timestamp-inactive) ;minor-mode r.
    568 (org-defkey org-mode-map (kbd "C-c ,") #'org-priority) ;minor-mode reserved
    569 (org-defkey org-mode-map (kbd "C-c C-y") #'org-evaluate-time-range)
    570 (org-defkey org-mode-map (kbd "C-c >") #'org-goto-calendar)
    571 (org-defkey org-mode-map (kbd "C-c <") #'org-date-from-calendar)
    572 (org-defkey org-mode-map (kbd "C-,") #'org-cycle-agenda-files)
    573 (org-defkey org-mode-map (kbd "C-'") #'org-cycle-agenda-files)
    574 (org-defkey org-mode-map (kbd "C-c [") #'org-agenda-file-to-front)
    575 (org-defkey org-mode-map (kbd "C-c ]") #'org-remove-file)
    576 (org-defkey org-mode-map (kbd "C-c C-x <") #'org-agenda-set-restriction-lock)
    577 (org-defkey org-mode-map (kbd "C-c C-x >") #'org-agenda-remove-restriction-lock)
    578 (org-defkey org-mode-map (kbd "C-c -") #'org-ctrl-c-minus)
    579 (org-defkey org-mode-map (kbd "C-c *") #'org-ctrl-c-star)
    580 (org-defkey org-mode-map (kbd "C-c TAB") #'org-ctrl-c-tab)
    581 (org-defkey org-mode-map (kbd "C-c ^") #'org-sort)
    582 (org-defkey org-mode-map (kbd "C-c C-c") #'org-ctrl-c-ctrl-c)
    583 (org-defkey org-mode-map (kbd "C-c C-k") #'org-kill-note-or-show-branches)
    584 (org-defkey org-mode-map (kbd "C-c #") #'org-update-statistics-cookies)
    585 (org-defkey org-mode-map (kbd "RET") #'org-return)
    586 (org-defkey org-mode-map (kbd "C-j") #'org-return-and-maybe-indent)
    587 (org-defkey org-mode-map (kbd "C-c ?") #'org-table-field-info)
    588 (org-defkey org-mode-map (kbd "C-c +") #'org-table-sum)
    589 (org-defkey org-mode-map (kbd "C-c =") #'org-table-eval-formula)
    590 (org-defkey org-mode-map (kbd "C-c '") #'org-edit-special)
    591 (org-defkey org-mode-map (kbd "C-c `") #'org-table-edit-field)
    592 (org-defkey org-mode-map (kbd "C-c \" a") #'orgtbl-ascii-plot)
    593 (org-defkey org-mode-map (kbd "C-c \" g") #'org-plot/gnuplot)
    594 (org-defkey org-mode-map (kbd "C-c |") #'org-table-create-or-convert-from-region)
    595 (org-defkey org-mode-map (kbd "C-#") #'org-table-rotate-recalc-marks)
    596 (org-defkey org-mode-map (kbd "C-c ~") #'org-table-create-with-table.el)
    597 (org-defkey org-mode-map (kbd "C-c C-a") #'org-attach)
    598 (org-defkey org-mode-map (kbd "C-c }") #'org-table-toggle-coordinate-overlays)
    599 (org-defkey org-mode-map (kbd "C-c {") #'org-table-toggle-formula-debugger)
    600 (org-defkey org-mode-map (kbd "C-c C-e") #'org-export-dispatch)
    601 (org-defkey org-mode-map (kbd "C-c :") #'org-toggle-fixed-width)
    602 (org-defkey org-mode-map (kbd "C-c C-x C-f") #'org-emphasize)
    603 (org-defkey org-mode-map (kbd "C-c C-x f") #'org-footnote-action)
    604 (org-defkey org-mode-map (kbd "C-c @") #'org-mark-subtree)
    605 (org-defkey org-mode-map (kbd "M-h") #'org-mark-element)
    606 (org-defkey org-mode-map (kbd "ESC h") #'org-mark-element)
    607 (org-defkey org-mode-map (kbd "C-c C-*") #'org-list-make-subtree)
    608 (org-defkey org-mode-map (kbd "C-c C-x C-w") #'org-cut-special)
    609 (org-defkey org-mode-map (kbd "C-c C-x M-w") #'org-copy-special)
    610 (org-defkey org-mode-map (kbd "C-c C-x C-y") #'org-paste-special)
    611 (org-defkey org-mode-map (kbd "C-c C-x C-t") #'org-toggle-timestamp-overlays)
    612 (org-defkey org-mode-map (kbd "C-c C-x C-i") #'org-clock-in)
    613 (org-defkey org-mode-map (kbd "C-c C-x C-x") #'org-clock-in-last)
    614 (org-defkey org-mode-map (kbd "C-c C-x C-z") #'org-resolve-clocks)
    615 (org-defkey org-mode-map (kbd "C-c C-x C-o") #'org-clock-out)
    616 (org-defkey org-mode-map (kbd "C-c C-x C-j") #'org-clock-goto)
    617 (org-defkey org-mode-map (kbd "C-c C-x C-q") #'org-clock-cancel)
    618 (org-defkey org-mode-map (kbd "C-c C-x C-d") #'org-clock-display)
    619 (org-defkey org-mode-map (kbd "C-c C-x x") #'org-dynamic-block-insert-dblock)
    620 (org-defkey org-mode-map (kbd "C-c C-x C-u") #'org-dblock-update)
    621 (org-defkey org-mode-map (kbd "C-c C-x C-l") #'org-latex-preview)
    622 (org-defkey org-mode-map (kbd "C-c C-x C-v") #'org-toggle-inline-images)
    623 (org-defkey org-mode-map (kbd "C-c C-x C-M-v") #'org-redisplay-inline-images)
    624 (org-defkey org-mode-map (kbd "C-c C-x \\") #'org-toggle-pretty-entities)
    625 (org-defkey org-mode-map (kbd "C-c C-x C-b") #'org-toggle-checkbox)
    626 (org-defkey org-mode-map (kbd "C-c C-x C-r") #'org-toggle-radio-button)
    627 (org-defkey org-mode-map (kbd "C-c C-x p") #'org-set-property)
    628 (org-defkey org-mode-map (kbd "C-c C-x P") #'org-set-property-and-value)
    629 (org-defkey org-mode-map (kbd "C-c C-x e") #'org-set-effort)
    630 (org-defkey org-mode-map (kbd "C-c C-x E") #'org-inc-effort)
    631 (org-defkey org-mode-map (kbd "C-c C-x o") #'org-toggle-ordered-property)
    632 (org-defkey org-mode-map (kbd "C-c C-,") #'org-insert-structure-template)
    633 (org-defkey org-mode-map (kbd "C-c C-x .") #'org-timer)
    634 (org-defkey org-mode-map (kbd "C-c C-x -") #'org-timer-item)
    635 (org-defkey org-mode-map (kbd "C-c C-x 0") #'org-timer-start)
    636 (org-defkey org-mode-map (kbd "C-c C-x _") #'org-timer-stop)
    637 (org-defkey org-mode-map (kbd "C-c C-x ;") #'org-timer-set-timer)
    638 (org-defkey org-mode-map (kbd "C-c C-x ,") #'org-timer-pause-or-continue)
    639 (org-defkey org-mode-map (kbd "C-c C-x C-c") #'org-columns)
    640 (org-defkey org-mode-map (kbd "C-c C-x !") #'org-reload)
    641 (org-defkey org-mode-map (kbd "C-c C-x g") #'org-feed-update-all)
    642 (org-defkey org-mode-map (kbd "C-c C-x G") #'org-feed-goto-inbox)
    643 (org-defkey org-mode-map (kbd "C-c C-x @") #'org-cite-insert)
    644 (org-defkey org-mode-map (kbd "C-c C-x [") #'org-reftex-citation)
    645 (org-defkey org-mode-map (kbd "C-c C-x I") #'org-info-find-node)
    646 
    647 
    648 ;;; Speed keys
    649 
    650 (defcustom org-use-speed-commands nil
    651   "Non-nil means activate single letter commands at beginning of a headline.
    652 This may also be a function to test for appropriate locations where speed
    653 commands should be active.
    654 
    655 For example, to activate speed commands when the point is on any
    656 star at the beginning of the headline, you can do this:
    657 
    658   (setq org-use-speed-commands
    659       (lambda () (and (looking-at org-outline-regexp) (looking-back \"^\\**\"))))"
    660   :group 'org-structure
    661   :type '(choice
    662 	  (const :tag "Never" nil)
    663 	  (const :tag "At beginning of headline stars" t)
    664 	  (function)))
    665 
    666 (defcustom org-speed-command-hook
    667   '(org-speed-command-activate org-babel-speed-command-activate)
    668   "Hook for activating speed commands at strategic locations.
    669 Hook functions are called in sequence until a valid handler is
    670 found.
    671 
    672 Each hook takes a single argument, a user-pressed command key
    673 which is also a `self-insert-command' from the global map.
    674 
    675 Within the hook, examine the cursor position and the command key
    676 and return nil or a valid handler as appropriate.  Handler could
    677 be one of an interactive command, a function, or a form.
    678 
    679 Set `org-use-speed-commands' to non-nil value to enable this
    680 hook.  The default setting is `org-speed-command-activate'."
    681   :group 'org-structure
    682   :version "24.1"
    683   :type 'hook)
    684 
    685 (defcustom org-speed-commands
    686   '(("Outline Navigation")
    687     ("n" . (org-speed-move-safe 'org-next-visible-heading))
    688     ("p" . (org-speed-move-safe 'org-previous-visible-heading))
    689     ("f" . (org-speed-move-safe 'org-forward-heading-same-level))
    690     ("b" . (org-speed-move-safe 'org-backward-heading-same-level))
    691     ("F" . org-next-block)
    692     ("B" . org-previous-block)
    693     ("u" . (org-speed-move-safe 'outline-up-heading))
    694     ("j" . org-goto)
    695     ("g" . (org-refile '(4)))
    696     ("Outline Visibility")
    697     ("c" . org-cycle)
    698     ("C" . org-shifttab)
    699     (" " . org-display-outline-path)
    700     ("s" . org-toggle-narrow-to-subtree)
    701     ("k" . org-cut-subtree)
    702     ("=" . org-columns)
    703     ("Outline Structure Editing")
    704     ("U" . org-metaup)
    705     ("D" . org-metadown)
    706     ("r" . org-metaright)
    707     ("l" . org-metaleft)
    708     ("R" . org-shiftmetaright)
    709     ("L" . org-shiftmetaleft)
    710     ("i" . (progn (forward-char 1) (call-interactively 'org-insert-heading-respect-content)))
    711     ("^" . org-sort)
    712     ("w" . org-refile)
    713     ("a" . org-archive-subtree-default-with-confirmation)
    714     ("@" . org-mark-subtree)
    715     ("#" . org-toggle-comment)
    716     ("Clock Commands")
    717     ("I" . org-clock-in)
    718     ("O" . org-clock-out)
    719     ("Meta Data Editing")
    720     ("t" . org-todo)
    721     ("," . (org-priority))
    722     ("0" . (org-priority ?\ ))
    723     ("1" . (org-priority ?A))
    724     ("2" . (org-priority ?B))
    725     ("3" . (org-priority ?C))
    726     (":" . org-set-tags-command)
    727     ("e" . org-set-effort)
    728     ("E" . org-inc-effort)
    729     ("W" . (lambda (m) (interactive "sMinutes before warning: ") (org-entry-put (point) "APPT_WARNTIME" m)))
    730     ("Agenda Views etc")
    731     ("v" . org-agenda)
    732     ("/" . org-sparse-tree)
    733     ("Misc")
    734     ("o" . org-open-at-point)
    735     ("?" . org-speed-command-help)
    736     ("<" . (org-agenda-set-restriction-lock 'subtree))
    737     (">" . (org-agenda-remove-restriction-lock)))
    738   "Alist of speed commands.
    739 
    740 The car of each entry is a string with a single letter, which
    741 must be assigned to `self-insert-command' in the global map.
    742 
    743 The cdr is either a command to be called interactively, a
    744 function to be called, or a form to be evaluated.
    745 
    746 An entry that is just a list with a single string will be
    747 interpreted as a descriptive headline that will be added when
    748 listing the speed commands in the Help buffer using the `?' speed
    749 command."
    750   :group 'org-structure
    751   :package-version '(Org . "9.5")
    752   :type '(repeat :value ("k" . ignore)
    753 		 (choice :value ("k" . ignore)
    754 			 (list :tag "Descriptive Headline" (string :tag "Headline"))
    755 			 (cons :tag "Letter and Command"
    756 			       (string :tag "Command letter")
    757 			       (choice
    758 				(function)
    759 				(sexp))))))
    760 
    761 (defun org--print-speed-command (speed-command)
    762   "Print information about SPEED-COMMAND in help buffer.
    763 SPEED-COMMAND is an element of `org-speed-commands'."
    764   (if (> (length (car speed-command)) 1)
    765       (progn
    766 	(princ "\n")
    767 	(princ (car speed-command))
    768 	(princ "\n")
    769 	(princ (make-string (length (car speed-command)) ?-))
    770 	(princ "\n"))
    771     (princ (car speed-command))
    772     (princ "   ")
    773     (if (symbolp (cdr speed-command))
    774 	(princ (symbol-name (cdr speed-command)))
    775       (prin1 (cdr speed-command)))
    776     (princ "\n")))
    777 
    778 (defun org-speed-command-help ()
    779   "Show the available speed commands."
    780   (interactive)
    781   (unless org-use-speed-commands
    782     (user-error "Speed commands are not activated, customize `org-use-speed-commands'"))
    783   (with-output-to-temp-buffer "*Help*"
    784     (princ "Speed commands\n==============\n")
    785     (mapc #'org--print-speed-command org-speed-commands))
    786   (with-current-buffer "*Help*"
    787     (setq truncate-lines t)))
    788 
    789 (defun org-speed-move-safe (cmd)
    790   "Execute CMD, but make sure that the cursor always ends up in a headline.
    791 If not, return to the original position and throw an error."
    792   (interactive)
    793   (let ((pos (point)))
    794     (call-interactively cmd)
    795     (unless (and (bolp) (org-at-heading-p))
    796       (goto-char pos)
    797       (error "Boundary reached while executing %s" cmd))))
    798 
    799 (defun org-speed-command-activate (keys)
    800   "Hook for activating single-letter speed commands.
    801 KEYS is the keys vector as returned by `this-command-keys-vector'.
    802 See `org-speed-commands' for configuring them."
    803   (when (or (and (bolp) (looking-at org-outline-regexp))
    804 	    (and (functionp org-use-speed-commands)
    805 		 (funcall org-use-speed-commands)))
    806     (cdr (assoc keys org-speed-commands))))
    807 
    808 
    809 ;;; Babel speed keys
    810 
    811 (defvar org-babel-key-prefix "\C-c\C-v"
    812   "The key prefix for Babel interactive key-bindings.
    813 See `org-babel-key-bindings' for the list of interactive Babel
    814 functions which are assigned key bindings, and see
    815 `org-babel-map' for the actual babel keymap.")
    816 
    817 (defvar org-babel-map (make-sparse-keymap)
    818   "The keymap for interactive Babel functions.")
    819 
    820 (defvar org-babel-key-bindings
    821   '(("p" . org-babel-previous-src-block)
    822     ("\C-p" . org-babel-previous-src-block)
    823     ("n" . org-babel-next-src-block)
    824     ("\C-n" . org-babel-next-src-block)
    825     ("e" . org-babel-execute-maybe)
    826     ("\C-e" . org-babel-execute-maybe)
    827     ("o" . org-babel-open-src-block-result)
    828     ("\C-o" . org-babel-open-src-block-result)
    829     ("\C-v" . org-babel-expand-src-block)
    830     ("v" . org-babel-expand-src-block)
    831     ("u" . org-babel-goto-src-block-head)
    832     ("\C-u" . org-babel-goto-src-block-head)
    833     ("g" . org-babel-goto-named-src-block)
    834     ("r" . org-babel-goto-named-result)
    835     ("\C-r" . org-babel-goto-named-result)
    836     ("\C-b" . org-babel-execute-buffer)
    837     ("b" . org-babel-execute-buffer)
    838     ("\C-s" . org-babel-execute-subtree)
    839     ("s" . org-babel-execute-subtree)
    840     ("\C-d" . org-babel-demarcate-block)
    841     ("d" . org-babel-demarcate-block)
    842     ("\C-t" . org-babel-tangle)
    843     ("t" . org-babel-tangle)
    844     ("\C-f" . org-babel-tangle-file)
    845     ("f" . org-babel-tangle-file)
    846     ("\C-c" . org-babel-check-src-block)
    847     ("c" . org-babel-check-src-block)
    848     ("\C-j" . org-babel-insert-header-arg)
    849     ("j" . org-babel-insert-header-arg)
    850     ("\C-l" . org-babel-load-in-session)
    851     ("l" . org-babel-load-in-session)
    852     ("\C-i" . org-babel-lob-ingest)
    853     ("i" . org-babel-lob-ingest)
    854     ("\C-I" . org-babel-view-src-block-info)
    855     ("I" . org-babel-view-src-block-info)
    856     ("\C-z" . org-babel-switch-to-session)
    857     ("z" . org-babel-switch-to-session-with-code)
    858     ("\C-a" . org-babel-sha1-hash)
    859     ("a" . org-babel-sha1-hash)
    860     ("h" . org-babel-describe-bindings)
    861     ("\C-x" . org-babel-do-key-sequence-in-edit-buffer)
    862     ("x" . org-babel-do-key-sequence-in-edit-buffer)
    863     ("k" . org-babel-remove-result-one-or-many)
    864     ("\C-\M-h" . org-babel-mark-block))
    865   "Alist of key bindings and interactive Babel functions.
    866 This list associates interactive Babel functions
    867 with keys.  Each element of this list will add an entry to the
    868 `org-babel-map' using the letter key which is the `car' of the
    869 a-list placed behind the generic `org-babel-key-prefix'.")
    870 
    871 (define-key org-mode-map org-babel-key-prefix org-babel-map)
    872 (pcase-dolist (`(,key . ,def) org-babel-key-bindings)
    873   (define-key org-babel-map key def))
    874 
    875 (defun org-babel-speed-command-activate (keys)
    876   "Hook for activating single-letter code block commands.
    877 KEYS is the keys vector as returned by `this-command-keys-vector'."
    878   (when (and (bolp)
    879 	     (let ((case-fold-search t)) (looking-at "[ \t]*#\\+begin_src"))
    880 	     (org-element-type-p (org-element-at-point) 'src-block))
    881     (cdr (assoc keys org-babel-key-bindings))))
    882 
    883 ;;;###autoload
    884 (defun org-babel-describe-bindings ()
    885   "Describe all keybindings behind `org-babel-key-prefix'."
    886   (interactive)
    887   (describe-bindings org-babel-key-prefix))
    888 
    889 (provide 'org-keys)
    890 
    891 ;; Local variables:
    892 ;; generated-autoload-file: "org-loaddefs.el"
    893 ;; End:
    894 
    895 ;;; org-keys.el ends here