From 716e339c9651ca920037906e5affb6049bdaa421 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 6 Apr 2016 11:08:53 +0200 Subject: [PATCH] Allow angular links within link descriptions * lisp/org-element.el (org-element-object-restrictions): (org-element--object-lex): Allow angular links as equivalent to plain links in description. * testing/lisp/test-org-element.el (test-org-element/link-parser): Add test. --- etc/ORG-NEWS | 6 ++++++ lisp/org-element.el | 14 ++++++++------ testing/lisp/test-org-element.el | 10 ++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 08933725f..82d5ad037 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -286,6 +286,12 @@ plain list. *** ~fixltx2e~ is removed from ~org-latex-default-packages-alist~ fixltx2e is obsolete, see LaTeX News 22. ** Miscellaneous +*** Allow angular links within link descriptions +It is now allowed to write, e.g., +~[[http:orgmode.org][]]~ as an equivalent to +~[[http:orgmode.org][file:unicorn.png]]~. The advantage of the former +is that spaces are allowed within the path. + *** Beamer export back-ends uses ~org-latex-prefer-user-labels~ *** ~:preparation-function~ called earlier during publishing diff --git a/lisp/org-element.el b/lisp/org-element.el index bec305d79..d02b36ca5 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -352,10 +352,11 @@ Don't modify it, set `org-element-affiliated-keywords' instead.") (italic ,@standard-set) (item ,@standard-set-no-line-break) (keyword ,@(remq 'footnote-reference standard-set)) - ;; Ignore all links excepted plain links in a link description. - ;; Also ignore radio-targets and line breaks. + ;; Ignore all links excepted plain links and angular links in + ;; a link description. Also ignore radio-targets and line + ;; breaks. (link bold code entity export-snippet inline-babel-call inline-src-block - italic latex-fragment macro plain-link statistics-cookie + italic latex-fragment macro simple-link statistics-cookie strike-through subscript superscript underline verbatim) (paragraph ,@standard-set) ;; Remove any variable object from radio target as it would @@ -4336,7 +4337,8 @@ to an appropriate container (e.g., a paragraph)." (org-element-target-parser))) (or (and (memq 'timestamp restriction) (org-element-timestamp-parser)) - (and (memq 'link restriction) + (and (or (memq 'link restriction) + (memq 'simple-link restriction)) (org-element-link-parser))))) (?\\ (if (eq (aref result 1) ?\\) @@ -4358,8 +4360,8 @@ to an appropriate container (e.g., a paragraph)." (org-element-statistics-cookie-parser))))) ;; This is probably a plain link. (_ (and (or (memq 'link restriction) - (memq 'plain-link restriction)) - (org-element-link-parser))))))) + (memq 'simple-link restriction)) + (org-element-link-parser))))))) (or (eobp) (forward-char)))) (cond (found) ;; Radio link. diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 261474d6a..1ff83f109 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -1688,8 +1688,8 @@ e^{i\\pi}+1=0 (org-element-type (org-element-context))))) (should (equal "//orgmode.org" - (org-test-with-temp-text "A link: " - (org-element-property :path (org-element-context))))) + (org-test-with-temp-text "A link: " + (org-element-property :path (org-element-context))))) ;; Link abbreviation. (should (equal "http" @@ -1712,6 +1712,12 @@ e^{i\\pi}+1=0 (equal "file" (org-test-with-temp-text "[[http://orgmode.org][file:unicorn.jpg]]" (search-forward "file:") + (org-element-property :type (org-element-context))))) + ;; So are angular links. + (should + (equal "file" + (org-test-with-temp-text "[[http://orgmode.org][]]" + (search-forward "file:") (org-element-property :type (org-element-context)))))) -- 2.11.4.GIT