diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-07-20 12:45:58 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-07-20 13:51:18 +0200 |
commit | 21dd83661b5d4fb7cae90d69e610bdb832972673 (patch) | |
tree | 9e63d2adc53b66d5dfd3502150fae44d21eab85d | |
parent | 40b44e4505c95c29630906ae9a2ea654d885f5b0 (diff) | |
download | org-mode-21dd83661b5d4fb7cae90d69e610bdb832972673.tar.gz |
org-element: Do not url-decode parsed links
* lisp/org-element.el (org-element-link-parser): Do not url-decode
parsed links.
The function now assumes link at point is correctly encoded if needed.
`org-insert-link' already automatically url-encode generated links,
and link types not handled by this function (e.g., custom-id links) do
not need such encoding.
-rw-r--r-- | lisp/org-element.el | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lisp/org-element.el b/lisp/org-element.el index e6f4a46..c08ccb1 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3052,42 +3052,42 @@ Assume point is at the beginning of the link." ;; abbreviation in it. raw-link (org-translate-link (org-link-expand-abbrev - (org-match-string-no-properties 1))) - link (org-link-unescape raw-link)) + (org-match-string-no-properties 1)))) ;; Determine TYPE of link and set PATH accordingly. (cond ;; File type. - ((or (file-name-absolute-p link) (string-match "^\\.\\.?/" link)) - (setq type "file" path link)) + ((or (file-name-absolute-p raw-link) + (string-match "^\\.\\.?/" raw-link)) + (setq type "file" path raw-link)) ;; Explicit type (http, irc, bbdb...). See `org-link-types'. - ((string-match org-link-re-with-space3 link) - (setq type (match-string 1 link) path (match-string 2 link))) + ((string-match org-link-re-with-space3 raw-link) + (setq type (match-string 1 raw-link) path (match-string 2 raw-link))) ;; Id type: PATH is the id. - ((string-match "^id:\\([-a-f0-9]+\\)" link) - (setq type "id" path (match-string 1 link))) + ((string-match "^id:\\([-a-f0-9]+\\)" raw-link) + (setq type "id" path (match-string 1 raw-link))) ;; Code-ref type: PATH is the name of the reference. - ((string-match "^(\\(.*\\))$" link) - (setq type "coderef" path (match-string 1 link))) + ((string-match "^(\\(.*\\))$" raw-link) + (setq type "coderef" path (match-string 1 raw-link))) ;; Custom-id type: PATH is the name of the custom id. - ((= (aref link 0) ?#) - (setq type "custom-id" path (substring link 1))) + ((= (aref raw-link 0) ?#) + (setq type "custom-id" path (substring raw-link 1))) ;; Fuzzy type: Internal link either matches a target, an ;; headline name or nothing. PATH is the target or ;; headline's name. - (t (setq type "fuzzy" path link)))) + (t (setq type "fuzzy" path raw-link)))) ;; Type 3: Plain link, i.e. http://orgmode.org ((looking-at org-plain-link-re) (setq raw-link (org-match-string-no-properties 0) type (org-match-string-no-properties 1) - path (org-match-string-no-properties 2) - link-end (match-end 0))) + link-end (match-end 0) + path (org-match-string-no-properties 2))) ;; Type 4: Angular link, i.e. <http://orgmode.org> ((looking-at org-angle-link-re) (setq raw-link (buffer-substring-no-properties (match-beginning 1) (match-end 2)) type (org-match-string-no-properties 1) - path (org-match-string-no-properties 2) - link-end (match-end 0)))) + link-end (match-end 0) + path (org-match-string-no-properties 2)))) ;; In any case, deduce end point after trailing white space from ;; LINK-END variable. (setq post-blank (progn (goto-char link-end) (skip-chars-forward " \t")) @@ -3104,7 +3104,7 @@ Assume point is at the beginning of the link." (when (string-match "::\\(.*\\)$" path) (setq search-option (match-string 1 path) path (replace-match "" nil nil path))) - ;; Make sure TYPE always report "file". + ;; Make sure TYPE always reports "file". (setq type "file")) (list 'link (list :type type |