Browse Source

Fix check-box toggling when point is on a link at an item

* lisp/org.el (org-ctrl-c-ctrl-c): When using C-c C-c at an item with
  point on a link, make sure checkbox, if any, is toggled.

Reported-by: Christoph LANGE <math.semantic.web@gmail.com>
Nicolas Goaziou 4 years ago
parent
commit
79ee98d755
1 changed files with 4 additions and 6 deletions
  1. 4 6
      lisp/org.el

+ 4 - 6
lisp/org.el

@@ -20221,6 +20221,10 @@ 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)))
 	;; 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)
@@ -20228,12 +20232,6 @@ This command does many different things, depending on context:
 	    (when (and (eq (org-element-type parent) 'item)
 		       (= (point-at-bol) (org-element-property :begin parent)))
 	      (setq context parent type 'item))))
-	;; When heading text is a link, treat the heading, not the link,
-	;; as the current element
-	(when (eq type 'link)
-	  (let ((parent (org-element-property :parent context)))
-	    (when (and (eq (org-element-type parent) 'headline))
-	      (setq context parent type 'headline))))
 	;; Act according to type of element or object at point.
 	(case type
 	  (clock (org-clock-update-time-maybe))