Browse Source

Fix C-c C-c behaviour on some objects

* lisp/org.el (org-ctrl-c-ctrl-c): When point is on an unsupported
  object, look for something to do at a higher level instead of
  bailing out.

For example, C-c C-c should toggle checkbox in the following example
even though X point is technically on a subscript.

  - [ ] a_Xb
Nicolas Goaziou 4 years ago
parent
commit
af6f14d907
1 changed files with 11 additions and 4 deletions
  1. 11 4
      lisp/org.el

+ 11 - 4
lisp/org.el

@@ -20214,10 +20214,17 @@ This command does many different things, depending on context:
       (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
 	  (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"))
-	;; When at a link, act according to the parent instead.
-	(when (eq type 'link)
-	  (setq context (org-element-property :parent context))
-	  (setq type (org-element-type context)))
+	(case type
+	  ;; When at a link, act according to the parent instead.
+	  (link (setq context (org-element-property :parent context))
+		(setq type (org-element-type context)))
+	  ;; Unsupported object types: check parent element instead.
+	  ((bold code entity export-snippet inline-babel-call inline-src-block
+		 italic latex-fragment line-break macro strike-through subscript
+		 superscript underline verbatim)
+	   (while (and (setq context (org-element-property :parent context))
+		       (not (memq (setq type (org-element-type context))
+				  '(paragraph verse-block)))))))
 	;; 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)