forked from mirrors/org-mode
Fix `org-ctrl-c-ctrl-c'
* lisp/org.el (org-ctrl-c-ctrl-c): Correctly set tags when called on an unsupported object type (e.g., a code snippet) in a headline or inlinetask.
This commit is contained in:
parent
8d672a2f7d
commit
7b42b4a62e
60
lisp/org.el
60
lisp/org.el
|
@ -21059,9 +21059,8 @@ This command does many different things, depending on context:
|
||||||
inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'."
|
inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(cond
|
(cond
|
||||||
((or (and (boundp 'org-clock-overlays) org-clock-overlays)
|
((or (bound-and-true-p org-clock-overlays) org-occur-highlights)
|
||||||
org-occur-highlights)
|
(when (boundp 'org-clock-overlays) (org-clock-remove-overlays))
|
||||||
(and (boundp 'org-clock-overlays) (org-clock-remove-overlays))
|
|
||||||
(org-remove-occur-highlights)
|
(org-remove-occur-highlights)
|
||||||
(message "Temporary highlights/overlays removed from current buffer"))
|
(message "Temporary highlights/overlays removed from current buffer"))
|
||||||
((and (local-variable-p 'org-finish-function)
|
((and (local-variable-p 'org-finish-function)
|
||||||
|
@ -21071,7 +21070,9 @@ This command does many different things, depending on context:
|
||||||
(t
|
(t
|
||||||
(if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
|
(if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
|
||||||
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
|
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
|
||||||
(user-error "C-c C-c can do nothing useful at this location"))
|
(user-error
|
||||||
|
(substitute-command-keys
|
||||||
|
"`\\[org-ctrl-c-ctrl-c]' can do nothing useful here")))
|
||||||
(let* ((context (org-element-context))
|
(let* ((context (org-element-context))
|
||||||
(type (org-element-type context)))
|
(type (org-element-type context)))
|
||||||
(cl-case type
|
(cl-case type
|
||||||
|
@ -21085,7 +21086,8 @@ This command does many different things, depending on context:
|
||||||
superscript underline verbatim)
|
superscript underline verbatim)
|
||||||
(setq context
|
(setq context
|
||||||
(org-element-lineage
|
(org-element-lineage
|
||||||
context '(radio-target paragraph verse-block table-cell)))))
|
context '(paragraph radio-target table-cell verse-block)))
|
||||||
|
(setq type (org-element-type context))))
|
||||||
;; For convenience: at the first line of a paragraph on the
|
;; For convenience: at the first line of a paragraph on the
|
||||||
;; same line as an item, apply function on that item instead.
|
;; same line as an item, apply function on that item instead.
|
||||||
(when (eq type 'paragraph)
|
(when (eq type 'paragraph)
|
||||||
|
@ -21093,22 +21095,23 @@ This command does many different things, depending on context:
|
||||||
(when (and (eq (org-element-type parent) 'item)
|
(when (and (eq (org-element-type parent) 'item)
|
||||||
(= (line-beginning-position)
|
(= (line-beginning-position)
|
||||||
(org-element-property :begin parent)))
|
(org-element-property :begin parent)))
|
||||||
(setq context parent type 'item))))
|
(setq context parent)
|
||||||
|
(setq type 'item))))
|
||||||
;; Act according to type of element or object at point.
|
;; Act according to type of element or object at point.
|
||||||
(cl-case type
|
(pcase type
|
||||||
(clock (org-clock-update-time-maybe))
|
(`clock (org-clock-update-time-maybe))
|
||||||
(dynamic-block
|
(`dynamic-block
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (org-element-property :post-affiliated context))
|
(goto-char (org-element-property :post-affiliated context))
|
||||||
(org-update-dblock)))
|
(org-update-dblock)))
|
||||||
(footnote-definition
|
(`footnote-definition
|
||||||
(goto-char (org-element-property :post-affiliated context))
|
(goto-char (org-element-property :post-affiliated context))
|
||||||
(call-interactively 'org-footnote-action))
|
(call-interactively 'org-footnote-action))
|
||||||
(footnote-reference (call-interactively 'org-footnote-action))
|
(`footnote-reference (call-interactively 'org-footnote-action))
|
||||||
((headline inlinetask)
|
((or `headline `inlinetask)
|
||||||
(save-excursion (goto-char (org-element-property :begin context))
|
(save-excursion (goto-char (org-element-property :begin context))
|
||||||
(call-interactively 'org-set-tags)))
|
(call-interactively #'org-set-tags)))
|
||||||
(item
|
(`item
|
||||||
;; At an item: a double C-u set checkbox to "[-]"
|
;; At an item: a double C-u set checkbox to "[-]"
|
||||||
;; unconditionally, whereas a single one will toggle its
|
;; unconditionally, whereas a single one will toggle its
|
||||||
;; presence. Without a universal argument, if the item
|
;; presence. Without a universal argument, if the item
|
||||||
|
@ -21146,7 +21149,7 @@ This command does many different things, depending on context:
|
||||||
(when block-item
|
(when block-item
|
||||||
(message "Checkboxes were removed due to empty box at line %d"
|
(message "Checkboxes were removed due to empty box at line %d"
|
||||||
(org-current-line block-item))))))
|
(org-current-line block-item))))))
|
||||||
(keyword
|
(`keyword
|
||||||
(let ((org-inhibit-startup-visibility-stuff t)
|
(let ((org-inhibit-startup-visibility-stuff t)
|
||||||
(org-startup-align-all-tables nil))
|
(org-startup-align-all-tables nil))
|
||||||
(when (boundp 'org-table-coordinate-overlays)
|
(when (boundp 'org-table-coordinate-overlays)
|
||||||
|
@ -21154,7 +21157,7 @@ This command does many different things, depending on context:
|
||||||
(setq org-table-coordinate-overlays nil))
|
(setq org-table-coordinate-overlays nil))
|
||||||
(org-save-outline-visibility 'use-markers (org-mode-restart)))
|
(org-save-outline-visibility 'use-markers (org-mode-restart)))
|
||||||
(message "Local setup has been refreshed"))
|
(message "Local setup has been refreshed"))
|
||||||
(plain-list
|
(`plain-list
|
||||||
;; At a plain list, with a double C-u argument, set
|
;; At a plain list, with a double C-u argument, set
|
||||||
;; checkboxes of each item to "[-]", whereas a single one
|
;; checkboxes of each item to "[-]", whereas a single one
|
||||||
;; will toggle their presence according to the state of the
|
;; will toggle their presence according to the state of the
|
||||||
|
@ -21187,13 +21190,13 @@ This command does many different things, depending on context:
|
||||||
struct (org-list-parents-alist struct) old-struct)
|
struct (org-list-parents-alist struct) old-struct)
|
||||||
(org-update-checkbox-count-maybe)
|
(org-update-checkbox-count-maybe)
|
||||||
(save-excursion (goto-char beginm) (org-list-send-list 'maybe))))
|
(save-excursion (goto-char beginm) (org-list-send-list 'maybe))))
|
||||||
((property-drawer node-property)
|
((or `property-drawer `node-property)
|
||||||
(call-interactively 'org-property-action))
|
(call-interactively #'org-property-action))
|
||||||
((radio-target target)
|
((or `radio-target `target)
|
||||||
(call-interactively 'org-update-radio-target-regexp))
|
(call-interactively #'org-update-radio-target-regexp))
|
||||||
(statistics-cookie
|
(`statistics-cookie
|
||||||
(call-interactively 'org-update-statistics-cookies))
|
(call-interactively #'org-update-statistics-cookies))
|
||||||
((table table-cell table-row)
|
((or `table `table-cell `table-row)
|
||||||
;; At a table, recalculate every field and align it. Also
|
;; At a table, recalculate every field and align it. Also
|
||||||
;; send the table if necessary. If the table has
|
;; send the table if necessary. If the table has
|
||||||
;; a `table.el' type, just give up. At a table row or
|
;; a `table.el' type, just give up. At a table row or
|
||||||
|
@ -21217,11 +21220,16 @@ Use \\[org-edit-special] to edit table.el tables"))
|
||||||
(cond (arg (call-interactively 'org-table-recalculate))
|
(cond (arg (call-interactively 'org-table-recalculate))
|
||||||
((org-table-maybe-recalculate-line))
|
((org-table-maybe-recalculate-line))
|
||||||
(t (org-table-align)))))))
|
(t (org-table-align)))))))
|
||||||
(timestamp (org-timestamp-change 0 'day))
|
(`timestamp (org-timestamp-change 0 'day))
|
||||||
(otherwise
|
((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))
|
||||||
|
(_
|
||||||
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
|
(or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
|
||||||
(user-error
|
(user-error
|
||||||
"C-c C-c can do nothing useful at this location")))))))))
|
(substitute-command-keys
|
||||||
|
"`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))))))))
|
||||||
|
|
||||||
(defun org-mode-restart ()
|
(defun org-mode-restart ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in a new issue