From f768629404fbb9260a611823b1cc266d1407abc2 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Mon, 26 May 2014 17:33:24 +0200 Subject: [PATCH] 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'. --- lisp/org-footnote.el | 6 ++---- lisp/org.el | 20 +++++--------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 81d148157..54d63a256 100644 --- a/lisp/org-footnote.el +++ b/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) diff --git a/lisp/org.el b/lisp/org.el index 5d79bc537..0ca5cc5ed 100644 --- a/lisp/org.el +++ b/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?" -- 2.11.4.GIT