فهرست منبع

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.
Nicolas Goaziou 10 سال پیش
والد
کامیت
55c0708bc4
3فایلهای تغییر یافته به همراه12 افزوده شده و 24 حذف شده
  1. 3 3
      lisp/org-docview.el
  2. 6 18
      lisp/org-element.el
  3. 3 3
      testing/lisp/test-org-element.el

+ 3 - 3
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)))

+ 6 - 18
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

+ 3 - 3
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)