branch: externals/org
commit ded231f7010ef1f1f4fc6e4815558a28e1689488
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>
org-activate-links: Fix edge case when false match fall through real link
* lisp/org.el (org-activate-links): When `org-link-any-re' matches
across paragraph boundaries, do not continue search from the end of
the match, but instead come back and re-start regexp search from char
after the beginning of the false match.
Reported-by: Michael <[email protected]>
Link:
https://orgmode.org/list/NuK_eoZBump2H-07JoUWWbUUXISNxTi4fleswJUNV8WtWRhNOznxaUSRCDRG8np4EHf80xROvWqDmDtlhxpQQLFQTFHNj0W06u7exbM9I2s=@proton.me
---
lisp/org.el | 120 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 61 insertions(+), 59 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 67d9679fe6..440e72e9e4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5500,66 +5500,68 @@ This includes angle, plain, and bracket links."
(style (cond ((eq ?< (char-after start)) 'angle)
((eq ?\[ (char-after (1+ start))) 'bracket)
(t 'plain))))
- (when (and (memq style org-highlight-links)
- ;; Do not span over paragraph boundaries.
- (not (string-match-p org-element-paragraph-separate
- (match-string 0)))
- ;; Do not confuse plain links with tags.
- (not (and (eq style 'plain)
- (let ((face (get-text-property
- (max (1- start) (point-min)) 'face)))
- (if (consp face) (memq 'org-tag face)
- (eq 'org-tag face))))))
- (let* ((link-object (save-excursion
- (goto-char start)
- (save-match-data (org-element-link-parser))))
- (link (org-element-property :raw-link link-object))
- (type (org-element-property :type link-object))
- (path (org-element-property :path link-object))
- (face-property (pcase (org-link-get-parameter type :face)
- ((and (pred functionp) face) (funcall face
path))
- ((and (pred facep) face) face)
- ((and (pred consp) face) face) ;anonymous
- (_ 'org-link)))
- (properties ;for link's visible part
- (list 'mouse-face (or (org-link-get-parameter type
:mouse-face)
- 'highlight)
- 'keymap (or (org-link-get-parameter type :keymap)
- org-mouse-map)
- 'help-echo (pcase (org-link-get-parameter type
:help-echo)
- ((and (pred stringp) echo) echo)
- ((and (pred functionp) echo) echo)
- (_ (concat "LINK: " link)))
- 'htmlize-link (pcase (org-link-get-parameter type
-
:htmlize-link)
- ((and (pred functionp) f) (funcall f))
- (_ `(:uri ,link)))
- 'font-lock-multiline t)))
- (org-remove-flyspell-overlays-in start end)
- (org-rear-nonsticky-at end)
- (if (not (eq 'bracket style))
- (progn
+ (if (and (memq style org-highlight-links)
+ ;; Do not span over paragraph boundaries.
+ (not (string-match-p org-element-paragraph-separate
+ (match-string 0)))
+ ;; Do not confuse plain links with tags.
+ (not (and (eq style 'plain)
+ (let ((face (get-text-property
+ (max (1- start) (point-min)) 'face)))
+ (if (consp face) (memq 'org-tag face)
+ (eq 'org-tag face))))))
+ (let* ((link-object (save-excursion
+ (goto-char start)
+ (save-match-data (org-element-link-parser))))
+ (link (org-element-property :raw-link link-object))
+ (type (org-element-property :type link-object))
+ (path (org-element-property :path link-object))
+ (face-property (pcase (org-link-get-parameter type :face)
+ ((and (pred functionp) face) (funcall face
path))
+ ((and (pred facep) face) face)
+ ((and (pred consp) face) face) ;anonymous
+ (_ 'org-link)))
+ (properties ;for link's visible part
+ (list 'mouse-face (or (org-link-get-parameter type
:mouse-face)
+ 'highlight)
+ 'keymap (or (org-link-get-parameter type :keymap)
+ org-mouse-map)
+ 'help-echo (pcase (org-link-get-parameter type
:help-echo)
+ ((and (pred stringp) echo) echo)
+ ((and (pred functionp) echo) echo)
+ (_ (concat "LINK: " link)))
+ 'htmlize-link (pcase (org-link-get-parameter type
+
:htmlize-link)
+ ((and (pred functionp) f) (funcall f))
+ (_ `(:uri ,link)))
+ 'font-lock-multiline t)))
+ (org-remove-flyspell-overlays-in start end)
+ (org-rear-nonsticky-at end)
+ (if (not (eq 'bracket style))
+ (progn
+ (add-face-text-property start end face-property)
+ (add-text-properties start end properties))
+ ;; Handle invisible parts in bracket links.
+ (remove-text-properties start end '(invisible nil))
+ (let ((hidden
+ (if org-link-descriptive
+ (append `(invisible
+ ,(or (org-link-get-parameter type :display)
+ 'org-link))
+ properties)
+ properties)))
+ (add-text-properties start visible-start hidden)
(add-face-text-property start end face-property)
- (add-text-properties start end properties))
- ;; Handle invisible parts in bracket links.
- (remove-text-properties start end '(invisible nil))
- (let ((hidden
- (if org-link-descriptive
- (append `(invisible
- ,(or (org-link-get-parameter type :display)
- 'org-link))
- properties)
- properties)))
- (add-text-properties start visible-start hidden)
- (add-face-text-property start end face-property)
- (add-text-properties visible-start visible-end properties)
- (add-text-properties visible-end end hidden)
- (org-rear-nonsticky-at visible-start)
- (org-rear-nonsticky-at visible-end)))
- (let ((f (org-link-get-parameter type :activate-func)))
- (when (functionp f)
- (funcall f start end path (eq style 'bracket))))
- (throw :exit t))))) ;signal success
+ (add-text-properties visible-start visible-end properties)
+ (add-text-properties visible-end end hidden)
+ (org-rear-nonsticky-at visible-start)
+ (org-rear-nonsticky-at visible-end)))
+ (let ((f (org-link-get-parameter type :activate-func)))
+ (when (functionp f)
+ (funcall f start end path (eq style 'bracket))))
+ (throw :exit t)) ;signal success
+ ;; Not a real link, move forward one char and repeat the search.
+ (goto-char (1+ (match-beginning 0))))))
nil))
(defun org-activate-code (limit)