Warning user that the custom variable `org-contacts-files' is nil.
If `org-contacts-files' is nil, will revert to `org-agenda-files'.
This commit is contained in:
parent
05522de61d
commit
f5394bc0b6
1 changed files with 12 additions and 9 deletions
|
@ -217,7 +217,10 @@ A regexp matching strings of whitespace, `,' and `;'.")
|
||||||
|
|
||||||
(defun org-contacts-files ()
|
(defun org-contacts-files ()
|
||||||
"Return list of Org files to use for contact management."
|
"Return list of Org files to use for contact management."
|
||||||
(or org-contacts-files (org-agenda-files t 'ifmode)))
|
(if org-contacts-files
|
||||||
|
org-contacts-files
|
||||||
|
(message "[ERROR] Your custom variable `org-contacts-files' is nil. Revert to `org-agenda-files' now.")
|
||||||
|
(org-agenda-files t 'ifmode)))
|
||||||
|
|
||||||
(defun org-contacts-db-need-update-p ()
|
(defun org-contacts-db-need-update-p ()
|
||||||
"Determine whether `org-contacts-db' needs to be refreshed."
|
"Determine whether `org-contacts-db' needs to be refreshed."
|
||||||
|
@ -247,7 +250,7 @@ buffer."
|
||||||
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))))
|
||||||
(i 0))
|
(i 0))
|
||||||
(dolist (file (org-contacts-files))
|
(dolist (file (org-contacts-files))
|
||||||
(if (catch 'nextfile
|
(if (catch 'nextfile
|
||||||
|
@ -973,7 +976,7 @@ address."
|
||||||
;; Use `org-contacts-icon-property'
|
;; Use `org-contacts-icon-property'
|
||||||
(let* ((link-matcher-regexp
|
(let* ((link-matcher-regexp
|
||||||
"\\[\\[\\([^]]*\\)\\]\\(\\[\\(.*\\)\\]\\)?\\]")
|
"\\[\\[\\([^]]*\\)\\]\\(\\[\\(.*\\)\\]\\)?\\]")
|
||||||
(contacts-dir (file-name-directory (car org-contacts-files)))
|
(contacts-dir (file-name-directory (car (org-contacts-files))))
|
||||||
(image-path
|
(image-path
|
||||||
(if-let ((avatar (org-entry-get pom org-contacts-icon-property)))
|
(if-let ((avatar (org-entry-get pom org-contacts-icon-property)))
|
||||||
(cond
|
(cond
|
||||||
|
@ -1263,7 +1266,7 @@ are effectively trimmed). If nil, all zero-length substrings are retained."
|
||||||
"Store the contact in `org-contacts-files' with a link."
|
"Store the contact in `org-contacts-files' with a link."
|
||||||
(when (and (eq major-mode 'org-mode)
|
(when (and (eq major-mode 'org-mode)
|
||||||
(member (buffer-file-name)
|
(member (buffer-file-name)
|
||||||
(mapcar #'expand-file-name org-contacts-files)))
|
(mapcar #'expand-file-name (org-contacts-files))))
|
||||||
(if (bound-and-true-p org-id-link-to-org-use-id)
|
(if (bound-and-true-p org-id-link-to-org-use-id)
|
||||||
(org-id-store-link)
|
(org-id-store-link)
|
||||||
(let ((headline-str (substring-no-properties (org-get-heading t t t t))))
|
(let ((headline-str (substring-no-properties (org-get-heading t t t t))))
|
||||||
|
@ -1290,7 +1293,7 @@ Each element has the form (NAME . (FILE . POSITION))."
|
||||||
(file (buffer-file-name))
|
(file (buffer-file-name))
|
||||||
(position (point)))
|
(position (point)))
|
||||||
`(:name ,name :file ,file :position ,position))))))
|
`(:name ,name :file ,file :position ,position))))))
|
||||||
org-contacts-files)))
|
(org-contacts-files))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun org-contacts-link-open (path)
|
(defun org-contacts-link-open (path)
|
||||||
|
@ -1299,7 +1302,7 @@ Each element has the form (NAME . (FILE . POSITION))."
|
||||||
(cond
|
(cond
|
||||||
;; /query/ format searching
|
;; /query/ format searching
|
||||||
((string-match "/.*/" query)
|
((string-match "/.*/" query)
|
||||||
(let* ((f (car org-contacts-files))
|
(let* ((f (car (org-contacts-files)))
|
||||||
(buf (get-buffer (file-name-nondirectory f))))
|
(buf (get-buffer (file-name-nondirectory f))))
|
||||||
(unless (buffer-live-p buf) (find-file f))
|
(unless (buffer-live-p buf) (find-file f))
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
|
@ -1307,14 +1310,14 @@ Each element has the form (NAME . (FILE . POSITION))."
|
||||||
(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))
|
(let* ((f (car (org-contacts-files)))
|
||||||
(_ (find-file f))
|
(_ (find-file f))
|
||||||
(buf (get-buffer (file-name-nondirectory 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))))
|
(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)))
|
||||||
|
|
||||||
;; (let* ((f (car org-contacts-files))
|
;; (let* ((f (car (org-contacts-files)))
|
||||||
;; (_ (find-file f))
|
;; (_ (find-file f))
|
||||||
;; ;; FIXME:
|
;; ;; FIXME:
|
||||||
;; (contact-entry (map-filter
|
;; (contact-entry (map-filter
|
||||||
|
@ -1356,7 +1359,7 @@ Each element has the form (NAME . (FILE . POSITION))."
|
||||||
"Retrieve all org-contacts EMAIL property values."
|
"Retrieve all org-contacts EMAIL property values."
|
||||||
(mapcar
|
(mapcar
|
||||||
(lambda (contact)
|
(lambda (contact)
|
||||||
(let* ((org-contacts-buffer (find-file-noselect (car org-contacts-files)))
|
(let* ((org-contacts-buffer (find-file-noselect (car (org-contacts-files))))
|
||||||
(name (plist-get contact :name))
|
(name (plist-get contact :name))
|
||||||
(position (plist-get contact :position))
|
(position (plist-get contact :position))
|
||||||
(email (save-excursion
|
(email (save-excursion
|
||||||
|
|
Loading…
Reference in a new issue