Function: org-ctrl-c-ctrl-c
org-ctrl-c-ctrl-c is an interactive and byte-compiled function defined
in org.el.gz.
Signature
(org-ctrl-c-ctrl-c &optional ARG)
Documentation
Set tags in headline, or update according to changed information at point.
This command does many different things, depending on context:
- If column view is active, in agenda or org buffers, quit it.
- If there are highlights, remove them.
- If a function in org-ctrl-c-ctrl-c-hook recognizes this location,
this is what we do.
- If the cursor is on a statistics cookie, update it.
- If the cursor is in a headline, in an agenda or an org buffer,
prompt for tags and insert them into the current line, aligned
to org-tags-column. When called with prefix arg, realign all
tags in the current buffer.
- If the cursor is in one of the special #+KEYWORD lines, this
triggers scanning the buffer for these lines and updating the
information.
- If the cursor is inside a table, realign the table. This command
works even if the automatic table editor has been turned off.
- If the cursor is on a #+TBLFM line, re-apply the formulas to
the entire table.
- If the cursor is at a footnote reference or definition, jump to
the corresponding definition or references, respectively.
- If the cursor is a the beginning of a dynamic block, update it.
- If the current buffer is a capture buffer, close note and file it.
- If the cursor is on a <<<target>>>, update radio targets and
corresponding links in this buffer.
- If the cursor is on a numbered item in a plain list, renumber the
ordered list.
- If the cursor is on a checkbox, toggle it.
- If the cursor is on a code block, evaluate it. The variable
org-confirm-babel-evaluate can be used to control prompting
before code block evaluation, by default every code block
evaluation requires confirmation. Code block evaluation can be
inhibited by setting org-babel-no-eval-on-ctrl-c-ctrl-c.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-ctrl-c-ctrl-c (&optional arg)
"Set tags in headline, or update according to changed information at point.
This command does many different things, depending on context:
- If column view is active, in agenda or org buffers, quit it.
- If there are highlights, remove them.
- If a function in `org-ctrl-c-ctrl-c-hook' recognizes this location,
this is what we do.
- If the cursor is on a statistics cookie, update it.
- If the cursor is in a headline, in an agenda or an org buffer,
prompt for tags and insert them into the current line, aligned
to `org-tags-column'. When called with prefix arg, realign all
tags in the current buffer.
- If the cursor is in one of the special #+KEYWORD lines, this
triggers scanning the buffer for these lines and updating the
information.
- If the cursor is inside a table, realign the table. This command
works even if the automatic table editor has been turned off.
- If the cursor is on a #+TBLFM line, re-apply the formulas to
the entire table.
- If the cursor is at a footnote reference or definition, jump to
the corresponding definition or references, respectively.
- If the cursor is a the beginning of a dynamic block, update it.
- If the current buffer is a capture buffer, close note and file it.
- If the cursor is on a <<<target>>>, update radio targets and
corresponding links in this buffer.
- If the cursor is on a numbered item in a plain list, renumber the
ordered list.
- If the cursor is on a checkbox, toggle it.
- If the cursor is on a code block, evaluate it. The variable
`org-confirm-babel-evaluate' can be used to control prompting
before code block evaluation, by default every code block
evaluation requires confirmation. Code block evaluation can be
inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'."
(interactive "P")
(cond
((bound-and-true-p org-columns-overlays) (org-columns-quit))
((or (bound-and-true-p org-clock-overlays) org-occur-highlights)
(when (boundp 'org-clock-overlays) (org-clock-remove-overlays))
(org-remove-occur-highlights)
(message "Temporary highlights/overlays removed from current buffer"))
((and (local-variable-p 'org-finish-function)
(fboundp org-finish-function))
(funcall org-finish-function))
((org-babel-hash-at-point))
((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
(t
(let* ((context
(org-element-lineage
(org-element-context)
;; Limit to supported contexts.
'(babel-call clock dynamic-block footnote-definition
footnote-reference inline-babel-call inline-src-block
inlinetask item keyword node-property paragraph
plain-list planning property-drawer radio-target
src-block statistics-cookie table table-cell table-row
timestamp)
t))
(radio-list-p (org-at-radio-list-p))
(type (org-element-type context)))
;; For convenience: at the first line of a paragraph on the same
;; line as an item, apply function on that item instead.
(when (eq type 'paragraph)
(let ((parent (org-element-parent context)))
(when (and (org-element-type-p parent 'item)
(= (line-beginning-position)
(org-element-begin parent)))
(setq context parent)
(setq type 'item))))
;; Act according to type of element or object at point.
;;
;; Do nothing on a blank line, except if it is contained in
;; a source block. Hence, we first check if point is in such
;; a block and then if it is at a blank line.
(pcase type
((or `inline-src-block `src-block)
(unless org-babel-no-eval-on-ctrl-c-ctrl-c
(org-babel-eval-wipe-error-buffer)
(org-babel-execute-src-block
current-prefix-arg (org-babel-get-src-block-info nil context))))
((guard (org-match-line "[ \t]*$"))
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
(user-error
(substitute-command-keys
"`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))
((or `babel-call `inline-babel-call)
(let ((info (org-babel-lob-get-info context)))
(when info (org-babel-execute-src-block nil info nil type))))
(`clock
(if (org-at-timestamp-p 'lax)
;; Update the timestamp as well. `org-timestamp-change'
;; will call `org-clock-update-time-maybe'.
(org-timestamp-change 0 'day)
(org-clock-update-time-maybe)))
(`dynamic-block
(save-excursion
(goto-char (org-element-post-affiliated context))
(org-update-dblock)))
(`footnote-definition
(goto-char (org-element-post-affiliated context))
(call-interactively 'org-footnote-action))
(`footnote-reference (call-interactively #'org-footnote-action))
((or `headline `inlinetask)
(save-excursion (goto-char (org-element-begin context))
(call-interactively #'org-set-tags-command)))
(`item
;; At an item: `C-u C-u' sets checkbox to "[-]"
;; unconditionally, whereas `C-u' will toggle its presence.
;; Without a universal argument, if the item has a checkbox,
;; toggle it. Otherwise repair the list.
(if (or radio-list-p
(and (boundp org-list-checkbox-radio-mode)
org-list-checkbox-radio-mode))
(org-toggle-radio-button arg)
(let* ((box (org-element-property :checkbox context))
(struct (org-element-property :structure context))
(old-struct (copy-tree struct))
(parents (org-list-parents-alist struct))
(prevs (org-list-prevs-alist struct))
(orderedp (org-not-nil (org-entry-get nil "ORDERED"))))
(org-list-set-checkbox
(org-element-begin context) struct
(cond ((equal arg '(16)) "[-]")
((and (not box) (equal arg '(4))) "[ ]")
((or (not box) (equal arg '(4))) nil)
((eq box 'on) "[ ]")
(t "[X]")))
;; Mimic `org-list-write-struct' but with grabbing a return
;; value from `org-list-struct-fix-box'.
(org-list-struct-fix-ind struct parents 2)
(org-list-struct-fix-item-end struct)
(org-list-struct-fix-bul struct prevs)
(org-list-struct-fix-ind struct parents)
(let ((block-item
(org-list-struct-fix-box struct parents prevs orderedp)))
(if (and box (equal struct old-struct))
(if (equal arg '(16))
(message "Checkboxes already reset")
(user-error "Cannot toggle this checkbox: %s"
(if (eq box 'on)
"all subitems checked"
"unchecked subitems")))
(org-list-struct-apply-struct struct old-struct)
(org-update-checkbox-count-maybe))
(when block-item
(message "Checkboxes were removed due to empty box at line %d"
(org-current-line block-item)))))))
(`plain-list
;; At a plain list, with a double C-u argument, set
;; checkboxes of each item to "[-]", whereas a single one
;; will toggle their presence according to the state of the
;; first item in the list. Without an argument, repair the
;; list.
(if (or radio-list-p
(and (boundp org-list-checkbox-radio-mode)
org-list-checkbox-radio-mode))
(org-toggle-radio-button arg)
(let* ((begin (org-element-contents-begin context))
(struct (org-element-property :structure context))
(old-struct (copy-tree struct))
(first-box (save-excursion
(goto-char begin)
(looking-at org-list-full-item-re)
(match-string-no-properties 3)))
(new-box (cond ((equal arg '(16)) "[-]")
((equal arg '(4)) (unless first-box "[ ]"))
((equal first-box "[X]") "[ ]")
(t "[X]"))))
(cond
(arg
(dolist (pos
(org-list-get-all-items
begin struct (org-list-prevs-alist struct)))
(org-list-set-checkbox pos struct new-box)))
((and first-box (eq (point) begin))
;; For convenience, when point is at bol on the first
;; item of the list and no argument is provided, simply
;; toggle checkbox of that item, if any.
(org-list-set-checkbox begin struct new-box)))
(when (equal
(org-list-write-struct
struct (org-list-parents-alist struct) old-struct)
old-struct)
(message "Cannot update this checkbox"))
(org-update-checkbox-count-maybe))))
(`keyword
(let ((org-inhibit-startup-visibility-stuff t)
(org-startup-align-all-tables nil))
(when (boundp 'org-table-coordinate-overlays)
(mapc #'delete-overlay org-table-coordinate-overlays)
(setq org-table-coordinate-overlays nil))
(org-save-outline-visibility 'use-markers (org-mode-restart)))
(message "Local setup has been refreshed"))
((or `property-drawer `node-property)
(call-interactively #'org-property-action))
(`radio-target
(call-interactively #'org-update-radio-target-regexp))
(`statistics-cookie
(call-interactively #'org-update-statistics-cookies))
((or `table `table-cell `table-row)
;; At a table, generate a plot if on the #+plot line,
;; recalculate every field and align it otherwise. Also
;; send the table if necessary.
(cond
((and (org-match-line "[ \t]*#\\+plot:")
(< (point) (org-element-post-affiliated context)))
(org-plot/gnuplot))
;; If the table has a `table.el' type, just give up.
((eq (org-element-property :type context) 'table.el)
(message "%s" (substitute-command-keys "\\<org-mode-map>\
Use `\\[org-edit-special]' to edit table.el tables")))
;; At a table row or cell, maybe recalculate line but always
;; align table.
((or (eq type 'table)
;; Check if point is at a TBLFM line.
(and (eq type 'table-row)
(= (point) (org-element-end context))))
(save-excursion
(if (org-at-TBLFM-p)
(progn (require 'org-table)
(org-table-calc-current-TBLFM))
(goto-char (org-element-contents-begin context))
(org-call-with-arg 'org-table-recalculate (or arg t))
(orgtbl-send-table 'maybe))))
(t
(org-table-maybe-eval-formula)
(cond (arg (call-interactively #'org-table-recalculate))
((org-table-maybe-recalculate-line))
(t (org-table-align))))))
((or `timestamp (and `planning (guard (org-at-timestamp-p 'lax))))
(org-timestamp-change 0 'day))
((and `nil (guard (org-at-heading-p)))
;; When point is on an unsupported object type, we can miss
;; the fact that it also is at a heading. Handle it here.
(call-interactively #'org-set-tags-command))
((guard
(run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)))
(_
(user-error
(substitute-command-keys
"`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))))))