org.el (org-link-escape): Don't escape characters in internal links

* org.el (org-link-escape): Don't escape characters in
internal links.

Thanks to Alan Schmitt for raising this issue.
This commit is contained in:
Bastien Guerry 2014-05-26 16:06:10 +02:00
parent 687a65de70
commit 956c00cce3
1 changed files with 22 additions and 18 deletions

View File

@ -9936,24 +9936,28 @@ Optional argument TABLE is a list with characters that should be
escaped. When nil, `org-link-escape-chars' is used.
If optional argument MERGE is set, merge TABLE into
`org-link-escape-chars'."
(cond
((and table merge)
(mapc (lambda (defchr)
(unless (member defchr table)
(setq table (cons defchr table)))) org-link-escape-chars))
((null table)
(setq table org-link-escape-chars)))
(mapconcat
(lambda (char)
(if (or (member char table)
(and (or (< char 32) (= char ?\%) (> char 126))
org-url-hexify-p))
(mapconcat (lambda (sequence-element)
(format "%%%.2X" sequence-element))
(or (encode-coding-char char 'utf-8)
(error "Unable to percent escape character: %s"
(char-to-string char))) "")
(char-to-string char))) text ""))
;; Don't escape chars in internal links
(if (string-match "^\\*[[:alnum:]]+" text)
text
(cond
((and table merge)
(mapc (lambda (defchr)
(unless (member defchr table)
(setq table (cons defchr table))))
org-link-escape-chars))
((null table)
(setq table org-link-escape-chars)))
(mapconcat
(lambda (char)
(if (or (member char table)
(and (or (< char 32) (= char ?\%) (> char 126))
org-url-hexify-p))
(mapconcat (lambda (sequence-element)
(format "%%%.2X" sequence-element))
(or (encode-coding-char char 'utf-8)
(error "Unable to percent escape character: %s"
(char-to-string char))) "")
(char-to-string char))) text "")))
(defun org-link-escape-browser (text)
"Escape some characters before handing over to the browser.