Pārlūkot izejas kodu

Fix reference to wrong buffer when creating links to other items

When finding the location of an Org mode item to link to,
`org-refile-get-location` may return a point even if the target buffer is not
the default buffer.  Resolving point in the default buffer thus yields a false
marker and the inserted link is wrong.  To remedy this, also consider the file
name returned by `org-refile-get-location` to resolve point in the file buffer
for that file.
master
Daniel 2 mēnešus atpakaļ
vecāks
revīzija
318f7c8f44
Šim parakstam datu bāzē netika atrasta zināma atslēga
1 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 6
    3
      site-lisp/db-org.el

+ 6
- 3
site-lisp/db-org.el Parādīt failu

@@ -689,13 +689,16 @@ linking to any item."
689 689
                                       :maxlevel . 9)
690 690
                                      (nil :maxlevel . 9))
691 691
                                  '((nil :maxlevel . 9))))
692
-           (pom (nth 3 (org-refile-get-location nil default-buffer))))
692
+           (target-pointer (org-refile-get-location))
693
+           (pom (nth 3 target-pointer)))
693 694
       (cond
694 695
        ((markerp pom) pom)
695 696
        ((integerp pom)
696
-        ;; Convert point to marker to ensure we are always in the correct buffer
697
+        ;; Convert point to marker to ensure we are always in the correct
698
+        ;; buffer; the second element of `target-pointer' contains the path to
699
+        ;; the target file
697 700
         (save-mark-and-excursion
698
-          (with-current-buffer default-buffer
701
+          (with-current-buffer (find-file-noselect (nth 1 target-pointer))
699 702
             (goto-char pom)
700 703
             (point-marker))))
701 704
        (t (user-error "Invalid location"))))))

Notiek ielāde…
Atcelt
Saglabāt