Fix can't get-buffer when file is not opened which caused buf is nil.

This commit is contained in:
stardiviner 2022-02-26 00:49:34 +08:00
parent fe466ab2ae
commit 7ed94bcf72

View file

@ -1300,8 +1300,8 @@ Each element has the form (NAME . (FILE . POSITION))."
;; jump to contact headline directly ;; jump to contact headline directly
(t (t
(let* ((f (car org-contacts-files)) (let* ((f (car org-contacts-files))
(_ (find-file f))
(buf (get-buffer (file-name-nondirectory f)))) (buf (get-buffer (file-name-nondirectory f))))
(unless (buffer-live-p buf) (find-file f))
(with-current-buffer buf (with-current-buffer buf
(goto-char (marker-position (org-find-exact-headline-in-buffer query)))) (goto-char (marker-position (org-find-exact-headline-in-buffer query))))
(display-buffer buf '(display-buffer-below-selected))) (display-buffer buf '(display-buffer-below-selected)))