[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-contacts b7d176dcfb 1/2: Refactor duplicated open o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-contacts b7d176dcfb 1/2: Refactor duplicated open org-contacts file and create buffer |
Date: |
Tue, 20 Dec 2022 23:57:58 -0500 (EST) |
branch: externals/org-contacts
commit b7d176dcfbec219dbf3de1ef109ce774bc0e1269
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>
Refactor duplicated open org-contacts file and create buffer
---
org-contacts.el | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/org-contacts.el b/org-contacts.el
index 4dd48b9b6a..004b826803 100644
--- a/org-contacts.el
+++ b/org-contacts.el
@@ -1301,31 +1301,29 @@ Each element has the form (NAME . (FILE . POSITION))."
(org-contacts-files))))
;;;###autoload
-(defun org-contacts-link-open (path)
+(defun org-contacts-link-open (query)
"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
;; /query/ format searching
((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
- (string-match "/\\(.*\\)/" query)
- (occur (match-string 1 query)))))
+ (with-current-buffer buf
+ (string-match "/\\(.*\\)/" query)
+ (occur (match-string 1 query))))
+
;; jump to exact contact headline directly
(t
- (let* ((f (car (org-contacts-files)))
- (_ (find-file f))
- (buf (get-buffer (file-name-nondirectory f))))
- (with-current-buffer buf
- (goto-char (marker-position (org-find-exact-headline-in-buffer
query))))
- (display-buffer buf '(display-buffer-below-selected)))
-
- ;; (let* ((f (car (org-contacts-files)))
- ;; (_ (find-file f))
- ;; ;; FIXME:
- ;; (contact-entry (map-filter
+ (with-current-buffer buf
+ (let ((position (org-find-exact-headline-in-buffer query)))
+ (goto-char (marker-position position))))
+ (display-buffer buf '(display-buffer-below-selected))
+
+ ;; FIXME:
+ ;; (let* ((contact-entry (map-filter
;; (lambda (contact-plist)
;; (if (string-equal (plist-get contact-plist
:name) query)
;; contact-plist))