Merge branch 'maint'

Conflicts:
	testing/lisp/test-org-element.el
This commit is contained in:
Nicolas Goaziou 2014-07-26 15:10:22 +02:00
commit 451e20d982
2 changed files with 24 additions and 15 deletions

View File

@ -3012,16 +3012,20 @@ Assume point is at the beginning of the link."
(cond (cond
;; File type. ;; File type.
((or (file-name-absolute-p raw-link) ((or (file-name-absolute-p raw-link)
(string-match "^\\.\\.?/" raw-link)) (string-match "\\`\\.\\.?/" raw-link))
(setq type "file" path raw-link)) (setq type "file" path raw-link))
;; Explicit type (http, irc, bbdb...). See `org-link-types'. ;; Explicit type (http, irc, bbdb...). See `org-link-types'.
((string-match org-link-re-with-space3 raw-link) ((string-match org-link-types-re raw-link)
(setq type (match-string 1 raw-link) path (match-string 2 raw-link))) (setq type (match-string 1 raw-link)
;; According to RFC 3986, extra whitespace should be
;; ignored when a URI is extracted.
path (replace-regexp-in-string
"[ \t]*\n[ \t]*" "" (substring raw-link (match-end 0)))))
;; Id type: PATH is the id. ;; Id type: PATH is the id.
((string-match "^id:\\([-a-f0-9]+\\)" raw-link) ((string-match "\\`id:\\([-a-f0-9]+\\)" raw-link)
(setq type "id" path (match-string 1 raw-link))) (setq type "id" path (match-string 1 raw-link)))
;; Code-ref type: PATH is the name of the reference. ;; Code-ref type: PATH is the name of the reference.
((string-match "^(\\(.*\\))$" raw-link) ((string-match "\\`(\\(.*\\))\\'" raw-link)
(setq type "coderef" path (match-string 1 raw-link))) (setq type "coderef" path (match-string 1 raw-link)))
;; Custom-id type: PATH is the name of the custom id. ;; Custom-id type: PATH is the name of the custom id.
((= (aref raw-link 0) ?#) ((= (aref raw-link 0) ?#)

View File

@ -1474,17 +1474,17 @@ e^{i\\pi}+1=0
(lambda (l) (list (org-element-property :type l) (lambda (l) (list (org-element-property :type l)
(org-element-property :path l) (org-element-property :path l)
(org-element-property :search-option l))))))) (org-element-property :search-option l)))))))
;; ... file-type link with application. ;; ... file-type link with application...
(should (should
(equal (equal
'(("file" "projects.org" "docview")) '("file" "projects.org" "docview")
(org-test-with-temp-text "[[docview:projects.org]]" (org-test-with-temp-text "[[docview:projects.org]]"
(org-element-map (org-element-parse-buffer) 'link (let ((l (org-element-context)))
(lambda (l) (list (org-element-property :type l) (list (org-element-property :type l)
(org-element-property :path l) (org-element-property :path l)
(org-element-property :application l))))))) (org-element-property :application l))))))
;; ... `:path' in a file-type link must be compatible with "file" ;; ... `:path' in a file-type link must be compatible with "file"
;; scheme in URI syntax, even if Org syntax isn't. ;; scheme in URI syntax, even if Org syntax isn't...
(should (should
(org-test-with-temp-text-in-file "" (org-test-with-temp-text-in-file ""
(let ((file (expand-file-name (buffer-file-name)))) (let ((file (expand-file-name (buffer-file-name))))
@ -1502,6 +1502,11 @@ e^{i\\pi}+1=0
(let ((file (file-relative-name (buffer-file-name)))) (let ((file (file-relative-name (buffer-file-name))))
(insert (format "[[file:%s]]" file)) (insert (format "[[file:%s]]" file))
(list (org-element-property :path (org-element-context)) file)))) (list (org-element-property :path (org-element-context)) file))))
;; ... multi-line link.
(should
(equal "//orgmode.org"
(org-test-with-temp-text "[[http://orgmode.\norg]]"
(org-element-property :path (org-element-context)))))
;; Plain link. ;; Plain link.
(should (should
(org-test-with-temp-text "A link: http://orgmode.org" (org-test-with-temp-text "A link: http://orgmode.org"