Fix link fontification

* lisp/org.el (org-activate-links): Delegate to
  `org-element-link-parser' to handle blanks and link expansion.
This commit is contained in:
Nicolas Goaziou 2017-06-05 23:39:42 +02:00
parent 82db669de6
commit 439fcfbbf2
1 changed files with 7 additions and 12 deletions

View File

@ -137,6 +137,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
(declare-function org-element-copy "org-element" (datum)) (declare-function org-element-copy "org-element" (datum))
(declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-lineage "org-element" (blob &optional types with-self)) (declare-function org-element-lineage "org-element" (blob &optional types with-self))
(declare-function org-element-link-parser "org-element" ())
(declare-function org-element-nested-p "org-element" (elem-a elem-b)) (declare-function org-element-nested-p "org-element" (elem-a elem-b))
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only)) (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
(declare-function org-element-property "org-element" (property element)) (declare-function org-element-property "org-element" (property element))
@ -5973,14 +5974,11 @@ This includes angle, plain, and bracket links."
(max (1- start) (point-min)) 'face))) (max (1- start) (point-min)) 'face)))
(if (consp face) (memq 'org-tag face) (if (consp face) (memq 'org-tag face)
(eq 'org-tag face)))))) (eq 'org-tag face))))))
(let* ((link (pcase type ;extract URL part (let* ((link-object (save-excursion
(`plain (match-string-no-properties 0)) (goto-char start)
(`angle (buffer-substring-no-properties (save-match-data (org-element-link-parser))))
(1+ start) (1- end))) (link (org-element-property :raw-link link-object))
(_ (match-string-no-properties 2)))) (path (org-element-property :path link-object))
(path (save-match-data
(and (string-match ":" link) ;remove type
(substring link (match-end 0)))))
(properties ;for link's visible part (properties ;for link's visible part
(list (list
'face (pcase (org-link-get-parameter type :face) 'face (pcase (org-link-get-parameter type :face)
@ -5995,10 +5993,7 @@ This includes angle, plain, and bracket links."
'help-echo (pcase (org-link-get-parameter type :help-echo) 'help-echo (pcase (org-link-get-parameter type :help-echo)
((and (pred stringp) echo) echo) ((and (pred stringp) echo) echo)
((and (pred functionp) echo) echo) ((and (pred functionp) echo) echo)
(_ (concat "LINK: " (_ (concat "LINK: " link)))
(save-match-data
(org-link-unescape
(org-link-expand-abbrev link))))))
'htmlize-link (pcase (org-link-get-parameter type 'htmlize-link (pcase (org-link-get-parameter type
:htmlize-link) :htmlize-link)
((and (pred functionp) f) (funcall f)) ((and (pred functionp) f) (funcall f))