Ver Fonte

Merge branch 'master' into next

Nicolas Goaziou há 6 anos atrás
pai
commit
470bf6e27e
2 ficheiros alterados com 14 adições e 3 exclusões
  1. 6 0
      lisp/org-src.el
  2. 8 3
      lisp/org.el

+ 6 - 0
lisp/org-src.el

@@ -283,6 +283,10 @@ However, if `indent-tabs-mode' is nil in that buffer, its value
 is 0.")
 (put 'org-src--tab-width 'permanent-local t)
 
+(defvar-local org-src-source-file-name nil
+  "File name associated to Org source buffer, or nil.")
+(put 'org-src-source-file-name 'permanent-local t)
+
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer."
   (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
@@ -487,6 +491,7 @@ Leave point in edit buffer."
 	(with-current-buffer old-edit-buffer (org-src--remove-overlay))
 	(kill-buffer old-edit-buffer))
       (let* ((org-mode-p (derived-mode-p 'org-mode))
+	     (source-file-name (buffer-file-name (buffer-base-buffer)))
 	     (source-tab-width (if indent-tabs-mode tab-width 0))
 	     (type (org-element-type datum))
 	     (ind (org-with-wide-buffer
@@ -538,6 +543,7 @@ Leave point in edit buffer."
 	(setq org-src--preserve-indentation preserve-ind)
 	(setq org-src--overlay overlay)
 	(setq org-src--allow-write-back write-back)
+	(setq org-src-source-file-name source-file-name)
 	;; Start minor mode.
 	(org-src-mode)
 	;; Move mark and point in edit buffer to the corresponding

+ 8 - 3
lisp/org.el

@@ -9092,7 +9092,12 @@ non-nil."
 
        ;; Store a link from a remote editing buffer.
        ((org-src-edit-buffer-p)
-	(let ((coderef-format (org-src-coderef-format)))
+	(let ((coderef-format (org-src-coderef-format))
+	      (format-link
+	       (lambda (label)
+		 (if org-src-source-file-name
+		     (format "file:%s::(%s)" org-src-source-file-name label)
+		   (format "(%s)" label)))))
 	  (cond
 	   ;; Code references do not exist in this type of buffer.
 	   ;; Pretend we're linking from the source buffer directly.
@@ -9106,7 +9111,7 @@ non-nil."
 	      (re-search-forward (org-src-coderef-regexp coderef-format)
 				 (line-end-position)
 				 t))
-	    (setq link (format "(%s)" (match-string-no-properties 3))))
+	    (setq link (funcall format-link (match-string-no-properties 3))))
 	   ;; No code reference.  Create a new one then store the link
 	   ;; to it, but only in the function is called interactively.
 	   (interactive?
@@ -9118,7 +9123,7 @@ non-nil."
 		  (org-move-to-column gc t)
 		(insert " "))
 	      (insert reference)
-	      (setq link (format "(%s)" label))))
+	      (setq link (funcall format-link label))))
 	   ;; No code reference, and non-interactive call.  Don't know
 	   ;; what to do.  Give up.
 	   (t (setq link nil)))))