瀏覽代碼

Simplify comments matching functions

* org.el (org-fontify-entities): Use `org-at-comment-p'.
(org-in-commented-line): Delete.
(org-in-indented-comment-line): Delete.
(org-at-comment-p): Also match indented comments and save
match data.

* org-footnote.el (org-footnote-in-valid-context-p): Use
`org-at-comment-p'.
Bastien Guerry 11 年之前
父節點
當前提交
f768629404
共有 2 個文件被更改,包括 7 次插入19 次删除
  1. 2 4
      lisp/org-footnote.el
  2. 5 15
      lisp/org.el

+ 2 - 4
lisp/org-footnote.el

@@ -46,8 +46,7 @@
 (declare-function org-icompleting-read "org" (&rest args))
 (declare-function org-id-uuid "org-id" ())
 (declare-function org-in-block-p "org" (names))
-(declare-function org-in-commented-line "org" ())
-(declare-function org-in-indented-comment-line "org" ())
+(declare-function org-at-comment-p "org" ())
 (declare-function org-in-regexp "org" (re &optional nlines visually))
 (declare-function org-in-verbatim-emphasis "org" ())
 (declare-function org-inside-LaTeX-fragment-p "org" ())
@@ -192,8 +191,7 @@ extracted will be filled again."
 (defun org-footnote-in-valid-context-p ()
   "Is point in a context where footnotes are allowed?"
   (save-match-data
-    (not (or (org-in-commented-line)
-	     (org-in-indented-comment-line)
+    (not (or (org-at-comment-p)
 	     (org-inside-LaTeX-fragment-p)
 	     ;; Avoid literal example.
 	     (org-in-verbatim-emphasis)

+ 5 - 15
lisp/org.el

@@ -6427,7 +6427,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	(while (re-search-forward
 		"\\\\\\(there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\($\\|{}\\|[^[:alpha:]\n]\\)"
 		limit t)
-	  (if (and (not (org-in-indented-comment-line))
+	  (if (and (not (org-at-comment-p))
 		   (setq ee (org-entity-get (match-string 1)))
 		   (= (length (nth 6 ee)) 1))
 	      (let*
@@ -21526,17 +21526,6 @@ With prefix arg UNCOMPILED, load the uncompiled versions."
 	   (>= (match-end 0) pos)
 	   start))))
 
-(defun org-in-commented-line ()
-  "Is point in a line starting with `#'?"
-  (equal (char-after (point-at-bol)) ?#))
-
-(defun org-in-indented-comment-line ()
-  "Is point in a line starting with `#' after some white space?"
-  (save-excursion
-    (save-match-data
-      (goto-char (point-at-bol))
-      (looking-at "[ \t]*#"))))
-
 (defun org-in-verbatim-emphasis ()
   (save-match-data
     (and (org-in-regexp org-emph-re 2)
@@ -23588,10 +23577,11 @@ unless optional argument NO-INHERITANCE is non-nil."
     (save-excursion (and (org-up-heading-safe) (org-in-commented-heading-p))))))
 
 (defun org-at-comment-p nil
-  "Is cursor in a line starting with a # character?"
+  "Is cursor in a commented line?"
   (save-excursion
-    (beginning-of-line)
-    (looking-at "^#")))
+    (save-match-data
+      (beginning-of-line)
+      (looking-at "^[ \t]*# "))))
 
 (defun org-at-drawer-p nil
   "Is cursor at a drawer keyword?"