branch: externals/org-contacts commit ef6ac66493d998d4f7ff3cd288e08eb820ea45c5 Author: stardiviner <numbch...@gmail.com> Commit: stardiviner <numbch...@gmail.com>
Use `find-file-noselect` to replace `find-file` for non-interactive opening org-contacts file --- org-contacts.el | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/org-contacts.el b/org-contacts.el index de0af29638..5b7a9dd3b3 100644 --- a/org-contacts.el +++ b/org-contacts.el @@ -1472,30 +1472,29 @@ Each element has the form (NAME . (FILE . POSITION))." (car (mapcar (lambda (file) (unless (buffer-live-p (get-buffer (file-name-nondirectory file))) - (find-file file)) - (with-current-buffer (get-buffer (file-name-nondirectory file)) - (org-map-entries - (lambda () - (let* ((name (substring-no-properties (org-get-heading t t t t))) - (file (buffer-file-name)) - (position (point)) - ;; extract properties Org entry headline at `position' as data API for better contacts searching. - (entry-properties (org-entry-properties position 'standard)) - (property-name-chinese (cdr (assoc (upcase "NAME(Chinese)") entry-properties))) - (property-name-english (cdr (assoc (upcase "NAME(English)") entry-properties))) - (property-nick (cdr (assoc "NICK" entry-properties))) - (property-email (cdr (assoc "EMAIL" entry-properties))) - ;; (property-mobile (cdr (assoc "MOBILE" entry-properties))) - (property-wechat (cdr (assoc (upcase "WeChat") entry-properties))) - (property-qq (cdr (assoc "QQ" entry-properties)))) - (list :name name :file file :position position - :name-chinese property-name-chinese - :name-english property-name-english - :nick property-nick - :email property-email - :mobile property-email - :wechat property-wechat - :qq property-qq)))))) + (with-current-buffer (find-file-noselect file) + (org-map-entries + (lambda () + (let* ((name (substring-no-properties (org-get-heading t t t t))) + (file (buffer-file-name)) + (position (point)) + ;; extract properties Org entry headline at `position' as data API for better contacts searching. + (entry-properties (org-entry-properties position 'standard)) + (property-name-chinese (cdr (assoc (upcase "NAME(Chinese)") entry-properties))) + (property-name-english (cdr (assoc (upcase "NAME(English)") entry-properties))) + (property-nick (cdr (assoc "NICK" entry-properties))) + (property-email (cdr (assoc "EMAIL" entry-properties))) + ;; (property-mobile (cdr (assoc "MOBILE" entry-properties))) + (property-wechat (cdr (assoc (upcase "WeChat") entry-properties))) + (property-qq (cdr (assoc "QQ" entry-properties)))) + (list :name name :file file :position position + :name-chinese property-name-chinese + :name-english property-name-english + :nick property-nick + :email property-email + :mobile property-email + :wechat property-wechat + :qq property-qq))))))) (org-contacts-files)))) ;;;###autoload @@ -1503,9 +1502,7 @@ Each element has the form (NAME . (FILE . POSITION))." "Open contacts: link type with jumping or searching." (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)))) + (buf (if (buffer-live-p (get-buffer fname)) (get-buffer fname) (find-file f)))) (cond ;; /query/ format searching ((string-match "/.*/" query)