Explorar o código

Merge branch 'maint'

Kyle Meyer %!s(int64=4) %!d(string=hai) anos
pai
achega
8d731ad256
Modificáronse 3 ficheiros con 43 adicións e 3 borrados
  1. 2 2
      lisp/ob-tangle.el
  2. 4 1
      lisp/ox-texinfo.el
  3. 37 0
      testing/lisp/test-ob-tangle.el

+ 2 - 2
lisp/ob-tangle.el

@@ -474,9 +474,9 @@ non-nil, return the full association list to be used by
 		  file)
 		(if (and org-babel-tangle-use-relative-file-links
 			 (string-match org-link-types-re link)
-			 (string= (match-string 0 link) "file"))
+			 (string= (match-string 1 link) "file"))
 		    (concat "file:"
-			    (file-relative-name (match-string 1 link)
+			    (file-relative-name (substring link (match-end 0))
 						(file-name-directory
 						 (cdr (assq :tangle params)))))
 		  link)

+ 4 - 1
lisp/ox-texinfo.el

@@ -1047,7 +1047,10 @@ DESC is the description part of the link, or the empty string.
 INFO is a plist holding contextual information.  See
 `org-export-data'."
   (let* ((type (org-element-property :type link))
-	 (raw-path (org-element-property :path link))
+	 (raw-path
+	  (replace-regexp-in-string
+	   "[@{}]" "@\\&"
+	   (org-element-property :path link)))
 	 ;; Ensure DESC really exists, or set it to nil.
 	 (desc (and (not (string= desc "")) desc))
 	 (path (org-texinfo--sanitize-content

+ 37 - 0
testing/lisp/test-ob-tangle.el

@@ -122,6 +122,43 @@ echo 1
                   (search-forward "[H:2]]" nil t))))
        (delete-file "test-ob-tangle.el")))))
 
+(ert-deftest ob-tangle/comment-links-relative-file ()
+  "Test relative file name handling when commenting with links."
+  (should
+   (org-test-with-temp-text-in-file
+       "* H
+#+header: :tangle \"test-ob-tangle.el\" :comments link
+#+begin_src emacs-lisp
+1
+#+end_src"
+     (unwind-protect
+	 (let ((org-babel-tangle-use-relative-file-links t))
+	   (org-babel-tangle)
+	   (with-temp-buffer
+	     (insert-file-contents "test-ob-tangle.el")
+	     (buffer-string)
+	     (goto-char (point-min))
+	     (search-forward
+	      (concat "[file:" (file-name-nondirectory file))
+	      nil t)))
+       (delete-file "test-ob-tangle.el"))))
+  (should
+   (org-test-with-temp-text-in-file
+       "* H
+#+header: :tangle \"test-ob-tangle.el\" :comments link
+#+begin_src emacs-lisp
+1
+#+end_src"
+     (unwind-protect
+	 (let ((org-babel-tangle-use-relative-file-links nil))
+	   (org-babel-tangle)
+	   (with-temp-buffer
+	     (insert-file-contents "test-ob-tangle.el")
+	     (buffer-string)
+	     (goto-char (point-min))
+	     (search-forward (concat "[file:" file) nil t)))
+       (delete-file "test-ob-tangle.el")))))
+
 (ert-deftest ob-tangle/jump-to-org ()
   "Test `org-babel-tangle-jump-to-org' specifications."
   ;; Standard test.