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