Clean nil and empty string "" from result

This commit is contained in:
stardiviner 2023-07-10 19:47:58 +08:00
parent 3f62975e74
commit 7231f8b2b8

View file

@ -1363,27 +1363,30 @@ Each element has the form (NAME . (FILE . POSITION))."
(defun org-contacts-mailto-link--get-all-emails () (defun org-contacts-mailto-link--get-all-emails ()
"Retrieve all org-contacts EMAIL property values." "Retrieve all org-contacts EMAIL property values."
(mapcar (setq org-contacts-emails-list
(lambda (contact) (mapcar
(let* ((org-contacts-buffer (find-file-noselect (car (org-contacts-files)))) (lambda (contact)
(name (plist-get contact :name)) (let* ((org-contacts-buffer (find-file-noselect (car (org-contacts-files))))
(position (plist-get contact :position)) (name (plist-get contact :name))
(email (save-excursion (position (plist-get contact :position))
(with-current-buffer org-contacts-buffer (email (save-excursion
(goto-char position) (with-current-buffer org-contacts-buffer
;; (symbol-name (org-property-or-variable-value 'EMAIL)) (goto-char position)
(when-let ((pvalue (org-entry-get (point) "EMAIL"))) ;; (symbol-name (org-property-or-variable-value 'EMAIL))
;; handle `mailto:' link. e.g. "[[mailto:yantar92@posteo.net]]", "[[mailto:yantar92@posteo.net][yantar92@posteo.net]]" (when-let ((pvalue (org-entry-get (point) "EMAIL")))
;; Reference the testing file `test-org-contacts.el'. ;; handle `mailto:' link. e.g. "[[mailto:yantar92@posteo.net]]", "[[mailto:yantar92@posteo.net][yantar92@posteo.net]]"
(if (string-match ;; Reference the testing file `test-org-contacts.el'.
"\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\(,\\ *\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\)" (if (string-match
pvalue) "\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\(,\\ *\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\)"
(match-string 1 pvalue) pvalue)
pvalue)))))) (match-string 1 pvalue)
(ignore name) pvalue))))))
;; (cons name email) (ignore name)
email)) ;; (cons name email)
(org-contacts--all-contacts))) email))
(org-contacts--all-contacts)))
;; clean nil and empty string "" from result.
(delq "" (delq nil org-contacts-emails-list)))
(defun org-contacts-mailto-link-completion (&optional _arg) (defun org-contacts-mailto-link-completion (&optional _arg)
"Org mode link `mailto:' completion with org-contacts emails." "Org mode link `mailto:' completion with org-contacts emails."