org.el: Add a 'htmlize-link text property to plain and bracket links

* org.el (org-activate-plain-links)
(org-activate-bracket-links): Add a new 'htmlize-link text
property, so that htmlize (> version 1.42) can linkify the
links.

Thanks to Hrvoje Nikšić for suggesting this.
This commit is contained in:
Bastien Guerry 2012-09-25 16:04:51 +02:00
parent 1e6263354e
commit 50091a849e
1 changed files with 12 additions and 8 deletions

View File

@ -5435,16 +5435,18 @@ will be prompted for."
(defun org-activate-plain-links (limit) (defun org-activate-plain-links (limit)
"Run through the buffer and add overlays to links." "Run through the buffer and add overlays to links."
(catch 'exit (catch 'exit
(let (f) (let (f hl)
(when (re-search-forward (concat org-plain-link-re) limit t) (when (re-search-forward (concat org-plain-link-re) limit t)
(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
(setq f (get-text-property (match-beginning 0) 'face)) (setq f (get-text-property (match-beginning 0) 'face))
(setq hl (org-match-string-no-properties 0))
(if (or (eq f 'org-tag) (if (or (eq f 'org-tag)
(and (listp f) (memq 'org-tag f))) (and (listp f) (memq 'org-tag f)))
nil nil
(add-text-properties (match-beginning 0) (match-end 0) (add-text-properties (match-beginning 0) (match-end 0)
(list 'mouse-face 'highlight (list 'mouse-face 'highlight
'face 'org-link 'face 'org-link
'htmlize-link `(:uri ,hl)
'keymap org-mouse-map)) 'keymap org-mouse-map))
(org-rear-nonsticky-at (match-end 0))) (org-rear-nonsticky-at (match-end 0)))
t)))) t))))
@ -5625,17 +5627,19 @@ by a #."
(defun org-activate-bracket-links (limit) (defun org-activate-bracket-links (limit)
"Run through the buffer and add overlays to bracketed links." "Run through the buffer and add overlays to bracketed links."
(if (re-search-forward org-bracket-link-regexp limit t) (if (re-search-forward org-bracket-link-regexp limit t)
(let* ((help (concat "LINK: " (let* ((hl (org-match-string-no-properties 1))
(org-match-string-no-properties 1))) (help (concat "LINK: " hl))
;; FIXME: above we should remove the escapes. ;; FIXME: Above we should remove the escapes. But that
;; but that requires another match, protecting match data, ;; requires another match, protecting match data, a lot
;; a lot of overhead for font-lock. ;; of overhead for font-lock.
(ip (org-maybe-intangible (ip (org-maybe-intangible
(list 'invisible 'org-link (list 'invisible 'org-link
'keymap org-mouse-map 'mouse-face 'highlight 'keymap org-mouse-map 'mouse-face 'highlight
'font-lock-multiline t 'help-echo help))) 'font-lock-multiline t 'help-echo help
'htmlize-link `(:uri ,hl))))
(vp (list 'keymap org-mouse-map 'mouse-face 'highlight (vp (list 'keymap org-mouse-map 'mouse-face 'highlight
'font-lock-multiline t 'help-echo help))) 'font-lock-multiline t 'help-echo help
'htmlize-link `(:uri ,hl))))
;; We need to remove the invisible property here. Table narrowing ;; We need to remove the invisible property here. Table narrowing
;; may have made some of this invisible. ;; may have made some of this invisible.
(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))