contrib/lisp/org-contacts.el: Factorize the construction of the database
* contrib/lisp/org-contacts.el (org-contacts-at-point): New function used to return the contact at point. (org-contacts-db): Factorize the construction of the database using `org-contacts-at-point' and fix a small typo.
This commit is contained in:
parent
36c6b30ec2
commit
74edb70b13
1 changed files with 16 additions and 11 deletions
|
@ -250,7 +250,7 @@ to dead or no buffer."
|
||||||
(let* (todo-only
|
(let* (todo-only
|
||||||
(contacts-matcher
|
(contacts-matcher
|
||||||
(cdr (org-make-tags-matcher org-contacts-matcher)))
|
(cdr (org-make-tags-matcher org-contacts-matcher)))
|
||||||
markers result)
|
result)
|
||||||
(when (org-contacts-db-need-update-p)
|
(when (org-contacts-db-need-update-p)
|
||||||
(let ((progress-reporter
|
(let ((progress-reporter
|
||||||
(make-progress-reporter "Updating Org Contacts Database..." 0 (length org-contacts-files)))
|
(make-progress-reporter "Updating Org Contacts Database..." 0 (length org-contacts-files)))
|
||||||
|
@ -259,21 +259,26 @@ to dead or no buffer."
|
||||||
(org-check-agenda-file file)
|
(org-check-agenda-file file)
|
||||||
(with-current-buffer (org-get-agenda-file-buffer file)
|
(with-current-buffer (org-get-agenda-file-buffer file)
|
||||||
(unless (eq major-mode 'org-mode)
|
(unless (eq major-mode 'org-mode)
|
||||||
(error "File %s is no in `org-mode'" file))
|
(error "File %s is not in `org-mode'" file))
|
||||||
(org-scan-tags
|
(setf result
|
||||||
'(add-to-list 'markers (set-marker (make-marker) (point)))
|
(append result
|
||||||
contacts-matcher
|
(org-scan-tags
|
||||||
todo-only))
|
'org-contacts-at-point
|
||||||
|
contacts-matcher
|
||||||
|
todo-only))))
|
||||||
(progress-reporter-update progress-reporter (setq i (1+ i))))
|
(progress-reporter-update progress-reporter (setq i (1+ i))))
|
||||||
(dolist (marker markers result)
|
|
||||||
(org-with-point-at marker
|
|
||||||
(add-to-list 'result
|
|
||||||
(list (org-get-heading t) marker (org-entry-properties marker 'all)))))
|
|
||||||
(setf org-contacts-db result
|
(setf org-contacts-db result
|
||||||
org-contacts-last-update (current-time))
|
org-contacts-last-update (current-time))
|
||||||
(progress-reporter-done progress-reporter)))
|
(progress-reporter-done progress-reporter)))
|
||||||
org-contacts-db))
|
org-contacts-db))
|
||||||
|
|
||||||
|
(defun org-contacts-at-point (&optional pom)
|
||||||
|
"Return the contacts at point-or-marker POM or current position
|
||||||
|
if nil."
|
||||||
|
(setq pom (or pom (point)))
|
||||||
|
(org-with-point-at pom
|
||||||
|
(list (org-get-heading t) (set-marker (make-marker) pom) (org-entry-properties pom 'all))))
|
||||||
|
|
||||||
(defun org-contacts-filter (&optional name-match tags-match prop-match)
|
(defun org-contacts-filter (&optional name-match tags-match prop-match)
|
||||||
"Search for a contact matching any of NAME-MATCH, TAGS-MATCH, PROP-MATCH.
|
"Search for a contact matching any of NAME-MATCH, TAGS-MATCH, PROP-MATCH.
|
||||||
If all match values are nil, return all contacts.
|
If all match values are nil, return all contacts.
|
||||||
|
|
Loading…
Reference in a new issue