Sfoglia il codice sorgente

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 mesi fa
parent
commit
318f7c8f44
Non sono state trovate chiavi note per questa firma nel database
1 ha cambiato i file con 6 aggiunte e 3 eliminazioni
  1. 6
    3
      site-lisp/db-org.el

+ 6
- 3
site-lisp/db-org.el Vedi File

@@ -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"))))))

Loading…
Annulla
Salva