From 4dbf87d4f30e6cae7cb2f9adeb680a74f6974918 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Fri, 11 Mar 2016 13:29:05 +0900 Subject: [PATCH] Correct beginning of inline code position markdown-regex-code starts with "\(?:\`\|[^\]\)\(\(`+\)...". If cursor is beginning of buffer, "(match-beginning 0)" is on backtick. While cursor is not beginning of buffer, "(match-beginning 0)" is not on backtick and previous point of backtick. --- foo:bar --- `x` In above example, (match-beginning 0) is point of after '---'. That point is a code block and '(markdown-code-block-at-pos pos)' returns non-nil, this causes infinite loop of markdown-match-inline-generic. '(match-beginning 1)' of markdown-regex-code always on backtick. We should use '(match-beginning 1)' instead of '(match-beginning 0') in such case. --- markdown-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown-mode.el b/markdown-mode.el index 5a0cb6f2..f4757103 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -2805,7 +2805,7 @@ Return nil otherwise." (defun markdown-match-inline-generic (regex last) "Match inline REGEX from the point to LAST." (when (re-search-forward regex last t) - (let ((bounds (markdown-code-block-at-pos (match-beginning 0)))) + (let ((bounds (markdown-code-block-at-pos (match-beginning 1)))) (if (null bounds) ;; Not in a code block: keep match data and return t when in bounds (<= (match-end 0) last)