org.el: New option `org-url-hexify-p'.
* org.el (org-url-hexify-p): New option. When non-nil (the default), hexify URLs when creating a link. Thanks to Gustav Wikström who suggested this.
This commit is contained in:
parent
1ac2552273
commit
341042a09e
45
lisp/org.el
45
lisp/org.el
|
@ -1405,6 +1405,12 @@ description to use."
|
||||||
:tag "Org Store Link"
|
:tag "Org Store Link"
|
||||||
:group 'org-link)
|
:group 'org-link)
|
||||||
|
|
||||||
|
(defcustom org-url-hexify-p t
|
||||||
|
"When non-nil, hexify URL when creating a link."
|
||||||
|
:type 'boolean
|
||||||
|
:version "24.2"
|
||||||
|
:group 'org-link-store)
|
||||||
|
|
||||||
(defcustom org-email-link-description-format "Email %c: %.30s"
|
(defcustom org-email-link-description-format "Email %c: %.30s"
|
||||||
"Format of the description part of a link to an email or usenet message.
|
"Format of the description part of a link to an email or usenet message.
|
||||||
The following %-escapes will be replaced by corresponding information:
|
The following %-escapes will be replaced by corresponding information:
|
||||||
|
@ -9076,8 +9082,6 @@ according to FMT (default from `org-email-link-description-format')."
|
||||||
"List of characters that should be escaped in link.
|
"List of characters that should be escaped in link.
|
||||||
This is the list that is used for internal purposes.")
|
This is the list that is used for internal purposes.")
|
||||||
|
|
||||||
(defvar org-url-encoding-use-url-hexify nil)
|
|
||||||
|
|
||||||
(defconst org-link-escape-chars-browser
|
(defconst org-link-escape-chars-browser
|
||||||
'(?\ )
|
'(?\ )
|
||||||
"List of escapes for characters that are problematic in links.
|
"List of escapes for characters that are problematic in links.
|
||||||
|
@ -9090,25 +9094,24 @@ 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'."
|
||||||
(if (and org-url-encoding-use-url-hexify (not table))
|
(cond
|
||||||
(url-hexify-string text)
|
((and table merge)
|
||||||
(cond
|
(mapc (lambda (defchr)
|
||||||
((and table merge)
|
(unless (member defchr table)
|
||||||
(mapc (lambda (defchr)
|
(setq table (cons defchr table)))) org-link-escape-chars))
|
||||||
(unless (member defchr table)
|
((null table)
|
||||||
(setq table (cons defchr table)))) org-link-escape-chars))
|
(setq table org-link-escape-chars)))
|
||||||
((null table)
|
(mapconcat
|
||||||
(setq table org-link-escape-chars)))
|
(lambda (char)
|
||||||
(mapconcat
|
(if (or (member char table)
|
||||||
(lambda (char)
|
(and (or (< char 32) (= char 37) (> char 126))
|
||||||
(if (or (member char table)
|
org-url-hexify-p))
|
||||||
(< char 32) (= char 37) (> char 126))
|
(mapconcat (lambda (sequence-element)
|
||||||
(mapconcat (lambda (sequence-element)
|
(format "%%%.2X" sequence-element))
|
||||||
(format "%%%.2X" sequence-element))
|
(or (encode-coding-char char 'utf-8)
|
||||||
(or (encode-coding-char char 'utf-8)
|
(error "Unable to percent escape character: %s"
|
||||||
(error "Unable to percent escape character: %s"
|
(char-to-string char))) "")
|
||||||
(char-to-string char))) "")
|
(char-to-string char))) text ""))
|
||||||
(char-to-string char))) text "")))
|
|
||||||
|
|
||||||
(defun org-link-unescape (str)
|
(defun org-link-unescape (str)
|
||||||
"Unhex hexified Unicode strings as returned from the JavaScript function
|
"Unhex hexified Unicode strings as returned from the JavaScript function
|
||||||
|
|
Loading…
Reference in New Issue