Refactor duplicated open org-contacts file and create buffer
This commit is contained in:
parent
bd5093e46b
commit
b7d176dcfb
1 changed files with 16 additions and 18 deletions
|
@ -1301,31 +1301,29 @@ Each element has the form (NAME . (FILE . POSITION))."
|
||||||
(org-contacts-files))))
|
(org-contacts-files))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-contacts-link-open (path)
|
(defun org-contacts-link-open (query)
|
||||||
"Open contacts: link type with jumping or searching."
|
"Open contacts: link type with jumping or searching."
|
||||||
(let ((query path))
|
(let* ((f (car (org-contacts-files)))
|
||||||
|
(fname (file-name-nondirectory f))
|
||||||
|
(buf (progn
|
||||||
|
(unless (buffer-live-p (get-buffer fname)) (find-file f))
|
||||||
|
(get-buffer fname))))
|
||||||
(cond
|
(cond
|
||||||
;; /query/ format searching
|
;; /query/ format searching
|
||||||
((string-match "/.*/" query)
|
((string-match "/.*/" query)
|
||||||
(let* ((f (car (org-contacts-files)))
|
|
||||||
(buf (get-buffer (file-name-nondirectory f))))
|
|
||||||
(unless (buffer-live-p buf) (find-file f))
|
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(string-match "/\\(.*\\)/" query)
|
(string-match "/\\(.*\\)/" query)
|
||||||
(occur (match-string 1 query)))))
|
(occur (match-string 1 query))))
|
||||||
|
|
||||||
;; jump to exact contact headline directly
|
;; jump to exact contact headline directly
|
||||||
(t
|
(t
|
||||||
(let* ((f (car (org-contacts-files)))
|
|
||||||
(_ (find-file f))
|
|
||||||
(buf (get-buffer (file-name-nondirectory f))))
|
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(goto-char (marker-position (org-find-exact-headline-in-buffer query))))
|
(let ((position (org-find-exact-headline-in-buffer query)))
|
||||||
(display-buffer buf '(display-buffer-below-selected)))
|
(goto-char (marker-position position))))
|
||||||
|
(display-buffer buf '(display-buffer-below-selected))
|
||||||
|
|
||||||
;; (let* ((f (car (org-contacts-files)))
|
;; FIXME:
|
||||||
;; (_ (find-file f))
|
;; (let* ((contact-entry (map-filter
|
||||||
;; ;; FIXME:
|
|
||||||
;; (contact-entry (map-filter
|
|
||||||
;; (lambda (contact-plist)
|
;; (lambda (contact-plist)
|
||||||
;; (if (string-equal (plist-get contact-plist :name) query)
|
;; (if (string-equal (plist-get contact-plist :name) query)
|
||||||
;; contact-plist))
|
;; contact-plist))
|
||||||
|
|
Loading…
Reference in a new issue