summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-03 23:00:21 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-03 23:00:21 +0100
commit55c0708bc40c1fccf5ca7a6b82a1bbeb89a0b99e (patch)
treedf8a4ffb4bd1de48f17eb2b4a47fd930888c5ae9
parent21c73e38e45c90c6c4f36a446f9cb11cb24a2559 (diff)
downloadorg-mode-55c0708bc40c1fccf5ca7a6b82a1bbeb89a0b99e.tar.gz
org-element: Externalize docview links
* lisp/org-element.el (org-element-link-type-is-file): Remove. (org-element-link-parser): Do not treat specially anymore "docview" link type. * testing/lisp/test-org-element.el (test-org-element/link-parser): Update test. * lisp/org-docview.el (org-docview-export): Fix path. "docview" is a custom link type handled in its own library. There is no reason to include it in core parser.
-rw-r--r--lisp/org-docview.el6
-rw-r--r--lisp/org-element.el24
-rw-r--r--testing/lisp/test-org-element.el6
3 files changed, 12 insertions, 24 deletions
diff --git a/lisp/org-docview.el b/lisp/org-docview.el
index b907262..479f4ff 100644
--- a/lisp/org-docview.el
+++ b/lisp/org-docview.el
@@ -1,6 +1,6 @@
;;; org-docview.el --- support for links to doc-view-mode buffers
-;; Copyright (C) 2009-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
;; Author: Jan Böcker <jan.boecker at jboecker dot de>
;; Keywords: outlines, hypermedia, calendar, wp
@@ -54,8 +54,8 @@
(defun org-docview-export (link description format)
"Export a docview link from Org files."
- (let* ((path (when (string-match "\\(.+\\)::.+" link)
- (match-string 1 link)))
+ (let* ((path (if (string-match "\\(.+\\)::.+" link) (match-string 1 link)
+ link))
(desc (or description link)))
(when (stringp path)
(setq path (org-link-escape (expand-file-name path)))
diff --git a/lisp/org-element.el b/lisp/org-element.el
index b92dd6a..7a73fae 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1,6 +1,6 @@
;;; org-element.el --- Parser And Applications for Org syntax
-;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
@@ -260,12 +260,6 @@ specially in `org-element--object-lex'.")
Names must be uppercase. Any block whose name has no association
is parsed with `org-element-special-block-parser'.")
-(defconst org-element-link-type-is-file
- '("file" "file+emacs" "file+sys" "docview")
- "List of link types equivalent to \"file\".
-Only these types can accept search options and an explicit
-application to open them.")
-
(defconst org-element-affiliated-keywords
'("CAPTION" "DATA" "HEADER" "HEADERS" "LABEL" "NAME" "PLOT" "RESNAME" "RESULT"
"RESULTS" "SOURCE" "SRCNAME" "TBLNAME")
@@ -3071,22 +3065,16 @@ Assume point is at the beginning of the link."
(save-excursion
(setq post-blank (progn (goto-char link-end) (skip-chars-forward " \t"))
end (point))
- ;; Special "file" type link processing.
- (when (member type org-element-link-type-is-file)
- ;; Extract opening application and search option.
- (cond ((string-match "^file\\+\\(.*\\)$" type)
- (setq application (match-string 1 type)))
- ((not (string-match "^file" type))
- (setq application type)))
+ ;; Special "file" type link processing. Extract opening
+ ;; application and search option, if any. Also normalize URI.
+ (when (string-match "\\`file\\(?:\\+\\(.+\\)\\)?\\'" type)
+ (setq application (match-string 1 type) type "file")
(when (string-match "::\\(.*\\)\\'" path)
(setq search-option (match-string 1 path)
path (replace-match "" nil nil path)))
- ;; Normalize URI.
(when (and (file-name-absolute-p path)
(not (org-string-match-p "\\`[/~]/" path)))
- (setq path (concat "//" path)))
- ;; Make sure TYPE always reports "file".
- (setq type "file"))
+ (setq path (concat "//" path))))
(list 'link
(list :type type
:path path
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 97e88e6..c9ae6c8 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1,6 +1,6 @@
;;; test-org-element.el --- Tests for org-element.el
-;; Copyright (C) 2012, 2013, 2014 Nicolas Goaziou
+;; Copyright (C) 2012-2015 Nicolas Goaziou
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
@@ -1495,8 +1495,8 @@ e^{i\\pi}+1=0
(require 'org-docview)
(should
(equal
- '("file" "projects.org" "docview")
- (org-test-with-temp-text "[[docview:projects.org]]"
+ '("file" "projects.org" "emacs")
+ (org-test-with-temp-text "[[file+emacs:projects.org]]"
(let ((l (org-element-context)))
(list (org-element-property :type l)
(org-element-property :path l)