瀏覽代碼

Tiny refactoring

* lisp/org.el (org-ctrl-c-ctrl-c): Tiny refactoring.
Nicolas Goaziou 10 年之前
父節點
當前提交
ab9e9d2857
共有 1 個文件被更改,包括 10 次插入10 次删除
  1. 10 10
      lisp/org.el

+ 10 - 10
lisp/org.el

@@ -20744,11 +20744,11 @@ This command does many different things, depending on context:
     (funcall org-finish-function))
    ((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
    (t
-    (let* ((context (org-element-context)) (type (org-element-type context)))
-      ;; Test if point is within a blank line.
-      (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"))
+    (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"))
+      (let* ((context (org-element-context))
+	     (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))
@@ -20758,16 +20758,16 @@ This command does many different things, depending on context:
 	  ((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))
-				  '(radio-target paragraph verse-block
-						 table-cell)))))))
+	   (setq context
+		 (org-element-lineage
+		  context '(radio-target paragraph verse-block table-cell)))))
 	;; 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-property :parent context)))
 	    (when (and (eq (org-element-type parent) 'item)
-		       (= (point-at-bol) (org-element-property :begin parent)))
+		       (= (line-beginning-position)
+			  (org-element-property :begin parent)))
 	      (setq context parent type 'item))))
 	;; Act according to type of element or object at point.
 	(case type