Fix link fontification

* lisp/org.el (org-activate-links): Fix link fontification.

Reported-by: John Kitchin <jkitchin@andrew.cmu.edu>
<http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00381.html>
This commit is contained in:
Nicolas Goaziou 2017-06-21 22:55:10 +02:00
parent 112c5ba479
commit 521734d51f

View file

@ -5964,12 +5964,12 @@ This includes angle, plain, and bracket links."
(while (re-search-forward org-any-link-re limit t)
(let* ((start (match-beginning 0))
(end (match-end 0))
(type (cond ((eq ?< (char-after start)) 'angle)
((eq ?\[ (char-after (1+ start))) 'bracket)
(t 'plain))))
(when (and (memq type org-highlight-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 confuse plain links with tags.
(not (and (eq type 'plain)
(not (and (eq style 'plain)
(let ((face (get-text-property
(max (1- start) (point-min)) 'face)))
(if (consp face) (memq 'org-tag face)
@ -5978,6 +5978,7 @@ This includes angle, plain, and bracket links."
(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))
(properties ;for link's visible part
(list
@ -6001,7 +6002,7 @@ This includes angle, plain, and bracket links."
'font-lock-multiline t)))
(org-remove-flyspell-overlays-in start end)
(org-rear-nonsticky-at end)
(if (not (eq 'bracket type))
(if (not (eq 'bracket style))
(add-text-properties start end properties)
;; Handle invisible parts in bracket links.
(remove-text-properties start end '(invisible nil))
@ -6019,7 +6020,7 @@ This includes angle, plain, and bracket links."
(org-rear-nonsticky-at visible-end)))
(let ((f (org-link-get-parameter type :activate-func)))
(when (functionp f)
(funcall f start end path (eq type 'bracket))))
(funcall f start end path (eq style 'bracket))))
(throw :exit t))))) ;signal success
nil))